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 //-----------------------------------------------------------------------------
19 /// \class AliMUONVDigit
21 /// This is the base class of a MUON digit that most client code should deal with.
22 /// There should be no reason to have to use a concrete class in most cases.
24 /// All digits have basic features, like :
26 /// - a way to identify it : detection element, electronics card and
27 /// channel, cathode. Note that some static methods exists to compact
28 /// those 4 informations into a single 4 bytes integer (stored in the
29 /// fUniqueID data member present in all TObjects).
33 /// - a set of boolean methods to indicate whether the digit has been calibrated, etc...
35 /// In addition, if HasMCInformation is true, the digit store also the list
36 /// of MC tracks that contributed to its charge
38 /// Also, if HasGeometryInformation is true, the digit knows the position and
39 /// the (half) dimensions (in cm) of the pad it corresponds to.
41 /// \author Laurent Aphecetche, Subatech
42 //-----------------------------------------------------------------------------
44 #include "AliMUONVDigit.h"
46 #include <Riostream.h>
50 ClassImp(AliMUONVDigit)
53 //_____________________________________________________________________________
54 AliMUONVDigit::AliMUONVDigit(Int_t detElemId, Int_t eCardId,
55 Int_t eCardChannel, Int_t cathode)
58 /// Normal constructor for trigger digits
59 SetUniqueID(BuildUniqueID(detElemId,eCardId,eCardChannel,cathode));
62 //_____________________________________________________________________________
63 AliMUONVDigit::AliMUONVDigit()
68 //_____________________________________________________________________________
69 AliMUONVDigit::~AliMUONVDigit()
74 //_____________________________________________________________________________
76 AliMUONVDigit::IsEqual(const TObject* object) const
78 /// Whether we're equal to object.
79 /// WARNING : only based on our identifiers (de,manu,channel,cathode), not our
80 /// content (i.e. charge, status...)
82 const AliMUONVDigit* d = static_cast<const AliMUONVDigit*>(object);
84 return ( DetElemId() == d->DetElemId() &&
85 Cathode() == d->Cathode() &&
86 ManuId() == d->ManuId() &&
87 ManuChannel() == d->ManuChannel() );
90 //_____________________________________________________________________________
92 AliMUONVDigit::Compare(const TObject* object) const
94 /// Compare two digits, trying to get as complete an order as possible.
95 /// We sort by DE, then by charge, then by manu, etc...
97 const AliMUONVDigit* d = static_cast<const AliMUONVDigit*>(object);
99 if ( DetElemId() > d->DetElemId() )
103 else if ( DetElemId() < d->DetElemId() )
109 if ( Charge() > d->Charge() )
113 else if ( Charge() < d->Charge() )
119 if ( ManuId() > d->ManuId() )
123 else if ( ManuId() < d->ManuId() )
129 if ( ManuChannel() > d->ManuChannel() )
133 else if ( ManuChannel() < d->ManuChannel() )
143 //_____________________________________________________________________________
145 AliMUONVDigit::BuildUniqueID(Int_t detElemId, Int_t manuId,
146 Int_t manuChannel, Int_t cathode)
148 /// Build a single integer with id information
149 return ( ( detElemId ) | ( manuId << 12 ) | ( manuChannel << 24 )
150 | ( cathode << 30 ) );
153 //_____________________________________________________________________________
155 AliMUONVDigit::DetElemId(UInt_t uniqueID)
157 /// Return detection element id part of the uniqueID
158 return uniqueID & 0xFFF;
161 //_____________________________________________________________________________
163 AliMUONVDigit::ManuChannel(UInt_t uniqueID)
165 /// Return manuChannel part of the uniqueID
166 return ( uniqueID & 0x3F000000 ) >> 24;
169 //_____________________________________________________________________________
171 AliMUONVDigit::ManuId(UInt_t uniqueID)
173 /// Return manuId part of the uniqueID
174 return ( uniqueID & 0xFFF000 ) >> 12;
177 //_____________________________________________________________________________
179 AliMUONVDigit::Cathode(UInt_t uniqueID)
181 /// Return the cathode part of the uniqueID
182 return ( uniqueID & 0x40000000 ) >> 30;
185 //_____________________________________________________________________________
187 AliMUONVDigit::DecodeUniqueID(UInt_t uniqueID,
188 Int_t& detElemId, Int_t& manuId,
189 Int_t& manuChannel, Int_t& cathode)
191 /// Unpack uniqueID into 4 elements
192 detElemId = DetElemId(uniqueID);
193 manuId = ManuId(uniqueID);
194 manuChannel = ManuChannel(uniqueID);
195 cathode = Cathode(uniqueID);
198 //_____________________________________________________________________________
200 AliMUONVDigit::GetName() const
202 /// Return the name of this digit, composed of its id parts.
203 return Form("DE%04d-%04d-%02d-%d",
204 DetElemId(),ManuId(),ManuChannel(),Cathode());
207 //_____________________________________________________________________________
209 AliMUONVDigit::Print(Option_t* opt) const
212 /// If opt=="tracks", info on tracks are printed too.
214 cout << Form("<%s>: ID %12u DE %4d Cath %d (Ix,Iy)=(%3d,%3d) (Manu,Channel)=(%4d,%2d)"
216 ClassName(),GetUniqueID(),
217 DetElemId(),Cathode(),PadX(),PadY(),ManuId(),ManuChannel(),Charge());
227 if ( IsCalibrated() )
245 cout << Form(" ADC=%4d StatusMap=%04x",ADC(),StatusMap());
247 TString options(opt);
249 if ( options.Contains("tracks") && HasMCInformation() )
251 cout << " Hit " << setw(3) << Hit();
252 Int_t ntracks = Ntracks();
255 cout << " Tracks : " << setw(2) << ntracks;
256 for ( Int_t i = 0; i < ntracks; ++i )
258 cout << " Track(" << i << ")=" << setw(3) << Track(i)
259 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
264 cout << " no track info.";