#include "AliMUONDigit.h"
-#include "Riostream.h"
-#include "TString.h"
+//-----------------------------------------------------------------------------
+/// \class AliMUONDigit
+/// A class representing a digit (with MC information if possible)
+/// in the MUON spectrometer either in tracking or trigger chambers.
+///
+/// A digit holds the signal (proportional to a charge) on a pad
+/// (or strip).
+///
+/// This class is used to represent either sdigits (purely simulated digit,
+/// with no electronic noise whatsoever) or digits (simulated ones but
+/// including electronic noise and de-calibration, to closely ressemble real ones).
+//-----------------------------------------------------------------------------
+/// \cond CLASSIMP
ClassImp(AliMUONDigit)
+/// \endcond
//_____________________________________________________________________________
AliMUONDigit::AliMUONDigit()
-: TObject(),
-fPadX(0),
-fPadY(0),
+:
+AliMUONVDigit(),
+fDetElemId(0),
+fManuId(0),
+fManuChannel(0),
+fSignal(0.0),
+fPadX(-1),
+fPadY(-1),
fCathode(0),
-fSignal(0),
-fPhysics(0),
+fADC(0),
+fFlags(0),
+fNtracks(0),
+fTcharges(0x0),
+fTracks(0x0),
fHit(0),
-fDetElemId(0),
-fManuId(-1),
-fManuChannel(-1),
+fTime(0),
+fStatusMap(0)
+{
+ /// Default constructor
+}
+
+//_____________________________________________________________________________
+AliMUONDigit::AliMUONDigit(Int_t detElemId, Int_t manuId,
+ Int_t manuChannel, Int_t cathode)
+:
+AliMUONVDigit(detElemId,manuId,manuChannel,cathode),
+fDetElemId(detElemId),
+fManuId(manuId),
+fManuChannel(manuChannel),
+fSignal(0.0),
+fPadX(-1),
+fPadY(-1),
+fCathode(cathode),
fADC(0),
-fIsSaturated(kFALSE)
+fFlags(0),
+fNtracks(0),
+fTcharges(0x0),
+fTracks(0x0),
+fHit(0),
+fTime(0),
+fStatusMap(0)
{
- // Default constructor
-
- for ( Int_t i=0; i<kMAXTRACKS; ++i )
- {
- fTcharges[i] = 0;
- fTracks[i] = 0;
- }
+ /// Normal constructor
}
+
//_____________________________________________________________________________
AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
- : TObject(digit)
+: AliMUONVDigit(),
+fDetElemId(0),
+fManuId(0),
+fManuChannel(0),
+fSignal(0.0),
+fPadX(-1),
+fPadY(-1),
+fCathode(0),
+fADC(0),
+fFlags(0),
+fNtracks(0),
+fTcharges(0x0),
+fTracks(0x0),
+fHit(0),
+fTime(0),
+fStatusMap(0)
{
- // copy constructor
-
+ /// Copy constructor
+
(static_cast<const AliMUONDigit&>(digit)).Copy(*this);
}
-
//_____________________________________________________________________________
AliMUONDigit::~AliMUONDigit()
{
- // Destructor
+ /// Destructor
+
+ delete[] fTcharges;
+ delete[] fTracks;
}
//_____________________________________________________________________________
-AliMUONDigit&
-AliMUONDigit::operator=(const AliMUONDigit& digit)
+void
+AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge)
{
- AliMUONDigit a(digit);
- a.Copy(*this);
- return *this;
+ /// Add 1 track information to the track list we keep.
+ /// The implementation below is dumb, you've been warned !
+
+ // First check if track is already there, in which
+ // case we simply increment its charge.
+ for ( Int_t i = 0; i < Ntracks(); ++i )
+ {
+ if ( Track(i) == trackNumber )
+ {
+ fTcharges[i] += trackCharge;
+ return;
+ }
+ }
+
+ // Nope. It's a brand new track. Make a new array to get space
+ // for it, copy the old array into new one, and add the track.
+ Int_t* newTracks = new Int_t[fNtracks+1];
+ Float_t* newTcharges = new Float_t[fNtracks+1];
+
+ for ( Int_t i = 0; i < fNtracks; ++i )
+ {
+ newTracks[i] = fTracks[i];
+ newTcharges[i] = fTcharges[i];
+ }
+
+ newTracks[fNtracks] = trackNumber;
+ newTcharges[fNtracks] = trackCharge;
+
+ delete[] fTracks;
+ delete[] fTcharges;
+
+ fTracks = newTracks;
+ fTcharges = newTcharges;
+
+ ++fNtracks;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONDigit::Clear(Option_t*)
+{
+ /// Reset this digit, in particular the internal arrays are deleted.
+
+ delete[] fTracks;
+ delete[] fTcharges;
+ fTracks=0x0;
+ fTcharges=0x0;
+ fNtracks=0;
}
//______________________________________________________________________________
void
AliMUONDigit::Copy(TObject& obj) const
{
- // Copy this line to line.
-
+ /// Copy this line to line.
+
TObject::Copy(obj);
AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
- digit.fPadX = fPadX;
- digit.fPadY = fPadY;
- digit.fCathode = fCathode;
- digit.fSignal = fSignal;
- digit.fHit = fHit;
+
digit.fDetElemId = fDetElemId;
digit.fManuId = fManuId;
digit.fManuChannel = fManuChannel;
+ digit.fSignal = fSignal;
+
+ digit.fPadX = fPadX;
+ digit.fPadY = fPadY;
+ digit.fCathode = fCathode;
digit.fADC = fADC;
- digit.fIsSaturated = fIsSaturated;
+ digit.fFlags = fFlags;
+
+ digit.fNtracks = fNtracks;
+
+ delete[] digit.fTcharges;
+ delete[] digit.fTracks;
+
+ if ( fNtracks )
+ {
+ digit.fTcharges = new Float_t[fNtracks];
+ digit.fTracks = new Int_t[fNtracks];
+ }
+
+ for ( Int_t i=0; i<fNtracks; ++i )
+ {
+ digit.fTcharges[i] = fTcharges[i];
+ digit.fTracks[i] = fTracks[i];
+ }
+
+ digit.fHit = fHit;
+ digit.fTime = fTime;
+ digit.fStatusMap = fStatusMap;
}
//_____________________________________________________________________________
-AliMUONDigit::AliMUONDigit(Int_t *digits)
+Bool_t
+AliMUONDigit::IsNoiseOnly() const
{
- //
- // Creates a MUON digit object to be updated
- //
- fPadX = digits[0];
- fPadY = digits[1];
- fCathode = digits[2];
- fSignal = digits[3];
- fPhysics = digits[4];
- fHit = digits[5];
- fDetElemId = digits[6];
- fManuId = -1;
- fManuChannel = -1;
- fADC=0;
- fIsSaturated = kFALSE;
+ /// Whether this (simulated only) digit is only due to noise.
+
+ return (fFlags & fgkNoiseOnlyMask );
}
+
//_____________________________________________________________________________
-AliMUONDigit::AliMUONDigit(Int_t *tracks, Int_t *charges, Int_t *digits)
+Bool_t
+AliMUONDigit::IsSaturated() const
{
- //
- // Creates a MUON digit object
- //
- fPadX = digits[0];
- fPadY = digits[1];
- fCathode = digits[2];
- fSignal = digits[3];
- fPhysics = digits[4];
- fHit = digits[5];
- fDetElemId = digits[6];
- fManuId = -1;
- fManuChannel = -1;
- fADC=0;
- for(Int_t i=0; i<kMAXTRACKS; i++) {
- fTcharges[i] = charges[i];
- fTracks[i] = tracks[i];
- }
- fIsSaturated=kFALSE;
+ /// Whether this digit is saturated or not.
+
+ return (fFlags & fgkSaturatedMask );
}
//_____________________________________________________________________________
-Int_t AliMUONDigit::Compare(const TObject *obj) const
+Bool_t
+AliMUONDigit::IsCalibrated() const
{
-// sort by idDE
+ /// Whether this digit is calibrated or not
+
+ return (fFlags & fgkCalibratedMask );
+}
- AliMUONDigit* d = (AliMUONDigit*) obj;
- return ( fDetElemId > d->DetElemId()) ? 1 : -1;
+//_____________________________________________________________________________
+Bool_t
+AliMUONDigit::IsUsed() const
+{
+ /// Whether this digit is used or not (in a cluster, for instance)
+
+ return (fFlags & fgkUsedMask );
+}
+
+//_____________________________________________________________________________
+Bool_t
+AliMUONDigit::IsEfficiencyApplied() const
+{
+ /// Whether this digit had efficiency applied or not
+
+ return (fFlags & fgkEfficiencyMask );
+}
+//_____________________________________________________________________________
+void
+AliMUONDigit::Used(Bool_t value)
+{
+ /// Set the Used status of this digit.
+
+ if ( value )
+ {
+ fFlags |= fgkUsedMask;
+ }
+ else
+ {
+ fFlags &= ~fgkUsedMask;
+ }
}
//_____________________________________________________________________________
void
-AliMUONDigit::Print(Option_t* opt) const
+AliMUONDigit::Calibrated(Bool_t value)
{
- cout << "DetEle " << setw(5) << DetElemId()
- << " Cath " << setw(2) << Cathode()
- << " (Ix,Iy)=(" << setw(3) << PadX() << "," << setw(3) << PadY()
- << ") "
- << " (Manu,Channel)=(" << setw(4) << ManuId()
- << "," << setw(3) << ManuChannel() << ")"
- << " Signal=" << setw(6) << Signal()
- << " Physics=" << setw(4) << Physics();
- if ( fIsSaturated )
+ /// Set the Calibrated status of this digit.
+
+ if ( value )
{
- cout << "(S)";
+ fFlags |= fgkCalibratedMask;
}
else
{
- cout << " ";
+ fFlags &= ~fgkCalibratedMask;
}
- cout << " ADC=" << setw(4) << ADC();
- TString options(opt);
- options.ToLower();
- if ( options.Contains("tracks") )
+}
+
+//_____________________________________________________________________________
+void
+AliMUONDigit::EfficiencyApplied(Bool_t value)
+{
+ /// Set the EfficiencyApplied status of this digit.
+
+ if ( value )
+ {
+ fFlags |= fgkEfficiencyMask;
+ }
+ else
{
- cout << " Track0=" << setw(3) << Track(0)
- << " Charge0=" << setw(4) << TrackCharge(0)
- << " Track1=" << setw(3) << Track(1)
- << " Charge1=" << setw(4) << TrackCharge(1);
+ fFlags &= ~fgkEfficiencyMask;
}
- cout << endl;
}
//_____________________________________________________________________________
Bool_t
-AliMUONDigit::IsSaturated() const
+AliMUONDigit::MergeWith(const AliMUONVDigit& src)
{
- return fIsSaturated;
+ /// Merge with src.
+
+ Bool_t check = ( src.DetElemId() == DetElemId() &&
+ src.PadX() == PadX() &&
+ src.PadY() == PadY() &&
+ src.Cathode() == Cathode() );
+ if (!check)
+ {
+ return kFALSE;
+ }
+
+ AddCharge(src.Charge());
+ for ( Int_t i = 0; i < src.Ntracks(); ++i )
+ {
+ AddTrack(src.Track(i),src.TrackCharge(i));
+ }
+ return kTRUE;
}
//_____________________________________________________________________________
-Int_t
-AliMUONDigit::ManuId() const
+void
+AliMUONDigit::NoiseOnly(Bool_t value)
{
- return fManuId;
+ /// Set the NoiseOnly status of this digit.
+
+ if ( value )
+ {
+ fFlags |= fgkNoiseOnlyMask;
+ }
+ else
+ {
+ fFlags &= ~fgkNoiseOnlyMask;
+ }
}
//_____________________________________________________________________________
-Int_t
-AliMUONDigit::ManuChannel() const
+AliMUONDigit&
+AliMUONDigit::operator=(const AliMUONDigit& digit)
{
- return fManuChannel;
+ /// Assignement operator.
+
+ if ( this != &digit )
+ {
+ digit.Copy(*this);
+ }
+ return *this;
}
//_____________________________________________________________________________
-Int_t
-AliMUONDigit::ADC() const
+void
+AliMUONDigit::PatchTracks(Int_t mask)
{
- return fADC;
+ /// Add mask to each track number.
+
+ for ( Int_t i = 0; i < Ntracks(); ++i )
+ {
+ fTracks[i] += mask;
+ }
}
//_____________________________________________________________________________
void
-AliMUONDigit::SetADC(Int_t adc)
+AliMUONDigit::Saturated(Bool_t value)
{
- fADC = adc;
+ /// Set the saturation status of this digit.
+
+ if ( value )
+ {
+ fFlags |= fgkSaturatedMask;
+ }
+ else
+ {
+ fFlags &= ~fgkSaturatedMask;
+ }
}
//_____________________________________________________________________________
-void
-AliMUONDigit::SetElectronics(Int_t manuId, Int_t manuChannel)
+Int_t
+AliMUONDigit::Track(Int_t i) const
{
- //
- //FIXME: should we check that the values are ok here ??
- //
- fManuId=manuId;
- fManuChannel=manuChannel;
+ /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
+
+ if ( i >= 0 && i < fNtracks )
+ {
+ return fTracks[i];
+ }
+
+ return -1;
}
//_____________________________________________________________________________
-void
-AliMUONDigit::Saturated(Bool_t saturated)
+Float_t
+AliMUONDigit::TrackCharge(Int_t i) const
{
- fIsSaturated=saturated;
+ /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
+
+ if ( i >= 0 && i < fNtracks )
+ {
+ return fTcharges[i];
+ }
+
+ return -1;
}
+//_____________________________________________________________________________
+UInt_t
+AliMUONDigit::GetUniqueID() const
+{
+ /// Return a single integer with id information
+ return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode());
+}