ROOT logo
#ifndef ALIMUONVDIGIT_H
#define ALIMUONVDIGIT_H

/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice                               */

// $Id$

/// \ingroup base
/// \class AliMUONVDigit
/// \brief ABC of a MUON digit
// Author Laurent Aphecetche, Subatech

#ifndef ROOT_TObject
#  include "TObject.h"
#endif

class AliMUONVDigit : public TObject
{
public:
  AliMUONVDigit();
  AliMUONVDigit(Int_t detElemId, Int_t manuId, Int_t manuChannel, Int_t cathode);
  virtual ~AliMUONVDigit();
  
  virtual Bool_t IsEqual(const TObject* object) const;
  /// Advertise that we can be sorted in TCollections
  virtual Bool_t IsSortable() const { return kTRUE; }
  virtual Int_t Compare(const TObject* object) const;
  
  virtual const char* GetName() const;
  
  /// The detection element this digit belongs to
  virtual Int_t DetElemId() const=0;
  /// The x-index of this digit (>=0)
  virtual Int_t PadX() const=0;
  /// The y-index of this digit (>=0)
  virtual Int_t PadY() const=0;
  /// Cathode number this digit is on (0 or 1)
  virtual Int_t Cathode() const=0;
  
  /// The charge of this digit, calibrated or not depending on IsCalibrated()
  virtual Float_t Charge() const=0;
  
  /// Raw ADC value of this digit
  virtual Int_t ADC() const = 0;
  
  /// The electronic card id this digit belongs to (manuId for tracker, localboardId for trigger)
  virtual Int_t ManuId() const = 0;
  /// The channel within ManuId() this digit belongs to (manuChannel for tracker, localBoardChannel for trigger)
  virtual Int_t ManuChannel() const=0;
  
  /// Whether the ADC has saturated
  virtual Bool_t IsSaturated() const=0;
  /// Set the saturation status
  virtual void Saturated(Bool_t saturated=kTRUE)=0;
  
  /// Whether this (simulated) digit is purely noise
  virtual Bool_t IsNoiseOnly() const=0;
  /// Set the noiseOnly status
  virtual void NoiseOnly(Bool_t /*value*/=kTRUE) { }
  
  /// Whether this (simulated) digit got corrected by chamber efficiency
  virtual Bool_t IsEfficiencyApplied() const=0;
  /// Set the efficiencyApplied status
  virtual void EfficiencyApplied(Bool_t /*value*/=kTRUE) {}
  
  /// Whether this digit has been calibrated or not (see note 1 in AliMUONVDigit.cxx)
  virtual Bool_t IsCalibrated() const=0;
  /// Set the calibrated status (see note 1 in AliMUONVDigit.cxx)
  virtual void Calibrated(Bool_t value)=0;

  /// Whether this digit has charge in femto coulomb (see note 1 in AliMUONVDigit.cxx)
  virtual Bool_t IsChargeInFC() const { return kFALSE; }
  /// Set the unit value (see note 1 in AliMUONVDigit.cxx)
  virtual void ChargeInFC(Bool_t value=kTRUE)=0;

  /// Whether or not this digit was obtained from a conversion (e.g. real to simulated)
  virtual Bool_t IsConverted() const { return kFALSE; }

  /// Whether this digit is used somewhere (typically in a cluster)
  virtual Bool_t IsUsed() const = 0;
  /// Set the used status
  virtual void Used(Bool_t value) = 0;
  
  /// A word describing the status of the neighbours of this digit
  virtual UInt_t StatusMap() const=0;
  /// Set the statusMap
  virtual void SetStatusMap(UInt_t statusMap)=0;
  
  /// Set the ADC value
  virtual void SetADC(Int_t adc)=0;
  /// Set the ix and iy of this digit
  virtual void SetPadXY(Int_t padx, Int_t pady)=0;
  /// Set the charge of this digit
  virtual void SetCharge(Float_t q)=0;
  /// Add a charge
  virtual void AddCharge(Float_t q) { SetCharge(Charge()+q); }
  
  /// Merge this with other
  virtual Bool_t MergeWith(const AliMUONVDigit& other)=0;
  
  /// Whether this digit is a tracker digit (false if belongs to trigger)
  virtual Bool_t IsTracker() const { return !IsTrigger(); }
  /** FIXME: how to get this information w/o hard-coding, yet being efficient ?
    Use one fFlags that must be set when creating the digit for instance ?
    */
  virtual Bool_t IsTrigger() const { return DetElemId()>=1100; }
  
  virtual void Print(Option_t* opt="") const;
  
  /// Below are methods only relevant for MC digigts.
  
  /// Whether we implement MC methods.
  virtual Bool_t HasMCInformation() const = 0; 
  
  /// Hit number that contributed to this simulated digit
  virtual Int_t Hit() const { return 0; }
  /// Set the hit number
  virtual void SetHit(Int_t /*n*/) { }
  /// Hit age
    virtual Float_t Time() const       {return 0;}
  /// Set hit age
      virtual void SetTime(Float_t /*t*/) { } 
  /// Number of tracks contributing to this digit
  virtual Int_t Ntracks() const { return 0; }
  /// Add a track (and its charge) to the list of tracks we handle
  virtual void AddTrack(Int_t /*trackNumber*/, Float_t /*trackCharge*/) {}
  /// Return the i-th track number
  virtual Int_t Track(Int_t /*i*/) const { return 0; }
  /// Return the i-th track charge
  virtual Float_t TrackCharge(Int_t /*i*/) const { return 0; }
  /// Patch track with a mask
  virtual void PatchTracks(Int_t /*mask*/) {}
  
  static UInt_t BuildUniqueID(Int_t detElemId, Int_t manuId, 
                              Int_t manuChannel, Int_t cathode);
  
  static void DecodeUniqueID(UInt_t uniqueID,
                             Int_t& detElemId, Int_t& manuId, 
                             Int_t& manuChannel, Int_t& cathode);
  
  static Int_t DetElemId(UInt_t uniqueID);
  static Int_t ManuId(UInt_t uniqueID);
  static Int_t ManuChannel(UInt_t uniqueID);
  static Int_t Cathode(UInt_t uniqueID);

  /// Return the localBoardNumber from the uniqueID  
  static Int_t LocalBoardNumber(UInt_t uniqueID) { return ManuId(uniqueID); }
  /// Return the localBoardChannel from the uniqueID
  static Int_t LocalBoardChannel(UInt_t uniqueID) { return ManuChannel(uniqueID); }
  
  
  ClassDef(AliMUONVDigit,0) // ABC of a MUON Digit
};

#endif
 AliMUONVDigit.h:1
 AliMUONVDigit.h:2
 AliMUONVDigit.h:3
 AliMUONVDigit.h:4
 AliMUONVDigit.h:5
 AliMUONVDigit.h:6
 AliMUONVDigit.h:7
 AliMUONVDigit.h:8
 AliMUONVDigit.h:9
 AliMUONVDigit.h:10
 AliMUONVDigit.h:11
 AliMUONVDigit.h:12
 AliMUONVDigit.h:13
 AliMUONVDigit.h:14
 AliMUONVDigit.h:15
 AliMUONVDigit.h:16
 AliMUONVDigit.h:17
 AliMUONVDigit.h:18
 AliMUONVDigit.h:19
 AliMUONVDigit.h:20
 AliMUONVDigit.h:21
 AliMUONVDigit.h:22
 AliMUONVDigit.h:23
 AliMUONVDigit.h:24
 AliMUONVDigit.h:25
 AliMUONVDigit.h:26
 AliMUONVDigit.h:27
 AliMUONVDigit.h:28
 AliMUONVDigit.h:29
 AliMUONVDigit.h:30
 AliMUONVDigit.h:31
 AliMUONVDigit.h:32
 AliMUONVDigit.h:33
 AliMUONVDigit.h:34
 AliMUONVDigit.h:35
 AliMUONVDigit.h:36
 AliMUONVDigit.h:37
 AliMUONVDigit.h:38
 AliMUONVDigit.h:39
 AliMUONVDigit.h:40
 AliMUONVDigit.h:41
 AliMUONVDigit.h:42
 AliMUONVDigit.h:43
 AliMUONVDigit.h:44
 AliMUONVDigit.h:45
 AliMUONVDigit.h:46
 AliMUONVDigit.h:47
 AliMUONVDigit.h:48
 AliMUONVDigit.h:49
 AliMUONVDigit.h:50
 AliMUONVDigit.h:51
 AliMUONVDigit.h:52
 AliMUONVDigit.h:53
 AliMUONVDigit.h:54
 AliMUONVDigit.h:55
 AliMUONVDigit.h:56
 AliMUONVDigit.h:57
 AliMUONVDigit.h:58
 AliMUONVDigit.h:59
 AliMUONVDigit.h:60
 AliMUONVDigit.h:61
 AliMUONVDigit.h:62
 AliMUONVDigit.h:63
 AliMUONVDigit.h:64
 AliMUONVDigit.h:65
 AliMUONVDigit.h:66
 AliMUONVDigit.h:67
 AliMUONVDigit.h:68
 AliMUONVDigit.h:69
 AliMUONVDigit.h:70
 AliMUONVDigit.h:71
 AliMUONVDigit.h:72
 AliMUONVDigit.h:73
 AliMUONVDigit.h:74
 AliMUONVDigit.h:75
 AliMUONVDigit.h:76
 AliMUONVDigit.h:77
 AliMUONVDigit.h:78
 AliMUONVDigit.h:79
 AliMUONVDigit.h:80
 AliMUONVDigit.h:81
 AliMUONVDigit.h:82
 AliMUONVDigit.h:83
 AliMUONVDigit.h:84
 AliMUONVDigit.h:85
 AliMUONVDigit.h:86
 AliMUONVDigit.h:87
 AliMUONVDigit.h:88
 AliMUONVDigit.h:89
 AliMUONVDigit.h:90
 AliMUONVDigit.h:91
 AliMUONVDigit.h:92
 AliMUONVDigit.h:93
 AliMUONVDigit.h:94
 AliMUONVDigit.h:95
 AliMUONVDigit.h:96
 AliMUONVDigit.h:97
 AliMUONVDigit.h:98
 AliMUONVDigit.h:99
 AliMUONVDigit.h:100
 AliMUONVDigit.h:101
 AliMUONVDigit.h:102
 AliMUONVDigit.h:103
 AliMUONVDigit.h:104
 AliMUONVDigit.h:105
 AliMUONVDigit.h:106
 AliMUONVDigit.h:107
 AliMUONVDigit.h:108
 AliMUONVDigit.h:109
 AliMUONVDigit.h:110
 AliMUONVDigit.h:111
 AliMUONVDigit.h:112
 AliMUONVDigit.h:113
 AliMUONVDigit.h:114
 AliMUONVDigit.h:115
 AliMUONVDigit.h:116
 AliMUONVDigit.h:117
 AliMUONVDigit.h:118
 AliMUONVDigit.h:119
 AliMUONVDigit.h:120
 AliMUONVDigit.h:121
 AliMUONVDigit.h:122
 AliMUONVDigit.h:123
 AliMUONVDigit.h:124
 AliMUONVDigit.h:125
 AliMUONVDigit.h:126
 AliMUONVDigit.h:127
 AliMUONVDigit.h:128
 AliMUONVDigit.h:129
 AliMUONVDigit.h:130
 AliMUONVDigit.h:131
 AliMUONVDigit.h:132
 AliMUONVDigit.h:133
 AliMUONVDigit.h:134
 AliMUONVDigit.h:135
 AliMUONVDigit.h:136
 AliMUONVDigit.h:137
 AliMUONVDigit.h:138
 AliMUONVDigit.h:139
 AliMUONVDigit.h:140
 AliMUONVDigit.h:141
 AliMUONVDigit.h:142
 AliMUONVDigit.h:143
 AliMUONVDigit.h:144
 AliMUONVDigit.h:145
 AliMUONVDigit.h:146
 AliMUONVDigit.h:147
 AliMUONVDigit.h:148
 AliMUONVDigit.h:149
 AliMUONVDigit.h:150
 AliMUONVDigit.h:151
 AliMUONVDigit.h:152
 AliMUONVDigit.h:153
 AliMUONVDigit.h:154
 AliMUONVDigit.h:155
 AliMUONVDigit.h:156