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 /// Whether we're equal to object.
77 /// WARNING : only based on our identifiers (de,manu,channel,cathode), not our
78 /// content (i.e. charge, status...)
80 const AliMUONVDigit* d = static_cast<const AliMUONVDigit*>(object);
82 return ( DetElemId() == d->DetElemId() &&
83 Cathode() == d->Cathode() &&
84 ManuId() == d->ManuId() &&
85 ManuChannel() == d->ManuChannel() );
88 //_____________________________________________________________________________
90 AliMUONVDigit::Compare(const TObject* object) const
92 /// Compare two digits, trying to get as complete an order as possible.
93 /// We sort by DE, then by charge, then by manu, etc...
95 const AliMUONVDigit* d = static_cast<const AliMUONVDigit*>(object);
97 if ( DetElemId() > d->DetElemId() )
101 else if ( DetElemId() < d->DetElemId() )
107 if ( Charge() > d->Charge() )
111 else if ( Charge() < d->Charge() )
117 if ( ManuId() < d->ManuId() )
121 else if ( ManuId() > d->ManuId() )
127 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
134 //_____________________________________________________________________________
136 AliMUONVDigit::BuildUniqueID(Int_t detElemId, Int_t manuId,
137 Int_t manuChannel, Int_t cathode)
139 /// Build a single integer with id information
140 return ( ( detElemId ) | ( manuId << 12 ) | ( manuChannel << 24 )
141 | ( cathode << 30 ) );
144 //_____________________________________________________________________________
146 AliMUONVDigit::DetElemId(UInt_t uniqueID)
148 /// Return detection element id part of the uniqueID
149 return uniqueID & 0xFFF;
152 //_____________________________________________________________________________
154 AliMUONVDigit::ManuChannel(UInt_t uniqueID)
156 /// Return manuChannel part of the uniqueID
157 return ( uniqueID & 0x3F000000 ) >> 24;
160 //_____________________________________________________________________________
162 AliMUONVDigit::ManuId(UInt_t uniqueID)
164 /// Return manuId part of the uniqueID
165 return ( uniqueID & 0xFFF000 ) >> 12;
168 //_____________________________________________________________________________
170 AliMUONVDigit::Cathode(UInt_t uniqueID)
172 /// Return the cathode part of the uniqueID
173 return ( uniqueID & 0x40000000 ) >> 30;
176 //_____________________________________________________________________________
178 AliMUONVDigit::DecodeUniqueID(UInt_t uniqueID,
179 Int_t& detElemId, Int_t& manuId,
180 Int_t& manuChannel, Int_t& cathode)
182 /// Unpack uniqueID into 4 elements
183 detElemId = DetElemId(uniqueID);
184 manuId = ManuId(uniqueID);
185 manuChannel = ManuChannel(uniqueID);
186 cathode = Cathode(uniqueID);
189 //_____________________________________________________________________________
191 AliMUONVDigit::GetName() const
193 /// Return the name of this digit, composed of its id parts.
194 return Form("DE%04d-%04d-%02d-%d",
195 DetElemId(),ManuId(),ManuChannel(),Cathode());
198 //_____________________________________________________________________________
200 AliMUONVDigit::Print(Option_t* opt) const
203 /// If opt=="tracks", info on tracks are printed too.
205 cout << Form("<%s>: ID %12u DE %4d Cath %d (Ix,Iy)=(%3d,%3d) (Manu,Channel)=(%4d,%2d)"
207 ClassName(),GetUniqueID(),
208 DetElemId(),Cathode(),PadX(),PadY(),ManuId(),ManuChannel(),Charge());
218 if ( IsCalibrated() )
236 cout << Form(" ADC=%4d StatusMap=%04x",ADC(),StatusMap());
238 TString options(opt);
240 if ( options.Contains("tracks") && HasMCInformation() )
242 cout << " Hit " << setw(3) << Hit();
243 Int_t ntracks = Ntracks();
246 cout << " Tracks : " << setw(2) << ntracks;
247 for ( Int_t i = 0; i < ntracks; ++i )
249 cout << " Track(" << i << ")=" << setw(3) << Track(i)
250 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
255 cout << " no track info.";