1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 /// \class AliMUONVDigit
20 /// This is the base class of a MUON digit that most client code should deal with.
21 /// There should be no reason to have to use a concrete class in most cases.
23 /// All digits have basic features, like :
25 /// - a way to identify it : detection element, electronics card and
26 /// channel, cathode. Note that some static methods exists to compact
27 /// those 4 informations into a single 4 bytes integer (stored in the
28 /// fUniqueID data member present in all TObjects).
32 /// - a set of boolean methods to indicate whether the digit has been calibrated, etc...
34 /// In addition, if HasMCInformation is true, the digit store also the list
35 /// of MC tracks that contributed to its charge
37 /// Also, if HasGeometryInformation is true, the digit knows the position and
38 /// the (half) dimensions (in cm) of the pad it corresponds to.
40 /// \author Laurent Aphecetche, Subatech
42 #include "AliMUONVDigit.h"
44 #include <Riostream.h>
48 ClassImp(AliMUONVDigit)
51 //_____________________________________________________________________________
52 AliMUONVDigit::AliMUONVDigit(Int_t detElemId, Int_t eCardId,
53 Int_t eCardChannel, Int_t cathode)
56 /// Normal constructor for trigger digits
57 SetUniqueID(BuildUniqueID(detElemId,eCardId,eCardChannel,cathode));
60 //_____________________________________________________________________________
61 AliMUONVDigit::AliMUONVDigit()
66 //_____________________________________________________________________________
67 AliMUONVDigit::~AliMUONVDigit()
72 //_____________________________________________________________________________
74 AliMUONVDigit::IsEqual(const TObject* object) const
76 const AliMUONVDigit* d = static_cast<const AliMUONVDigit*>(object);
78 return ( DetElemId() == d->DetElemId() &&
79 Cathode() == d->Cathode() &&
80 ManuId() == d->ManuId() &&
81 ManuChannel() == d->ManuChannel() );
84 //_____________________________________________________________________________
86 AliMUONVDigit::Compare(const TObject* object) const
88 const AliMUONVDigit* d = static_cast<const AliMUONVDigit*>(object);
90 if ( DetElemId() > d->DetElemId() )
94 else if ( DetElemId() < d->DetElemId() )
100 if ( Charge() > d->Charge() )
104 else if ( Charge() < d->Charge() )
110 if ( ManuId() < d->ManuId() )
114 else if ( ManuId() > d->ManuId() )
120 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
127 //_____________________________________________________________________________
129 AliMUONVDigit::BuildUniqueID(Int_t detElemId, Int_t manuId,
130 Int_t manuChannel, Int_t cathode)
132 /// Build a single integer with id information
133 return ( ( detElemId ) | ( manuId << 12 ) | ( manuChannel << 24 )
134 | ( cathode << 30 ) );
137 //_____________________________________________________________________________
139 AliMUONVDigit::DetElemId(UInt_t uniqueID)
141 /// Return detection element id part of the uniqueID
142 return uniqueID & 0xFFF;
145 //_____________________________________________________________________________
147 AliMUONVDigit::ManuChannel(UInt_t uniqueID)
149 /// Return manuChannel part of the uniqueID
150 return ( uniqueID & 0x3F000000 ) >> 24;
153 //_____________________________________________________________________________
155 AliMUONVDigit::ManuId(UInt_t uniqueID)
157 /// Return manuId part of the uniqueID
158 return ( uniqueID & 0xFFF000 ) >> 12;
161 //_____________________________________________________________________________
163 AliMUONVDigit::Cathode(UInt_t uniqueID)
165 /// Return the cathode part of the uniqueID
166 return ( uniqueID & 0x40000000 ) >> 30;
169 //_____________________________________________________________________________
171 AliMUONVDigit::DecodeUniqueID(UInt_t uniqueID,
172 Int_t& detElemId, Int_t& manuId,
173 Int_t& manuChannel, Int_t& cathode)
175 /// Unpack uniqueID into 4 elements
176 detElemId = DetElemId(uniqueID);
177 manuId = ManuId(uniqueID);
178 manuChannel = ManuChannel(uniqueID);
179 cathode = Cathode(uniqueID);
182 //_____________________________________________________________________________
184 AliMUONVDigit::GetName() const
186 /// Return the name of this digit, composed of its id parts.
187 return Form("DE%04d-%04d-%02d-%d",
188 DetElemId(),ManuId(),ManuChannel(),Cathode());
191 //_____________________________________________________________________________
193 AliMUONVDigit::Print(Option_t* opt) const
196 /// If opt=="tracks", info on tracks are printed too.
198 cout << Form("<%s>: ID %12u DE %4d Cath %d (Ix,Iy)=(%3d,%3d) (Manu,Channel)=(%4d,%2d)"
200 ClassName(),GetUniqueID(),
201 DetElemId(),Cathode(),PadX(),PadY(),ManuId(),ManuChannel(),Charge());
211 if ( IsCalibrated() )
229 cout << Form(" ADC=%4d StatusMap=%04x",ADC(),StatusMap());
231 TString options(opt);
233 if ( options.Contains("tracks") && HasMCInformation() )
235 cout << " Hit " << setw(3) << Hit();
236 Int_t ntracks = Ntracks();
239 cout << " Tracks : " << setw(2) << ntracks;
240 for ( Int_t i = 0; i < ntracks; ++i )
242 cout << " Track(" << i << ")=" << setw(3) << Track(i)
243 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
248 cout << " no track info.";