]>
Commit | Line | Data |
---|---|---|
d6c3334d | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | // $Id$ | |
17 | ||
18 | /// \class AliMUONVDigit | |
19 | /// | |
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. | |
22 | /// | |
23 | /// All digits have basic features, like : | |
24 | /// | |
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). | |
29 | /// | |
30 | /// - its charge | |
31 | /// | |
32 | /// - a set of boolean methods to indicate whether the digit has been calibrated, etc... | |
33 | /// | |
34 | /// In addition, if HasMCInformation is true, the digit store also the list | |
35 | /// of MC tracks that contributed to its charge | |
36 | /// | |
37 | /// Also, if HasGeometryInformation is true, the digit knows the position and | |
38 | /// the (half) dimensions (in cm) of the pad it corresponds to. | |
39 | /// | |
40 | /// \author Laurent Aphecetche, Subatech | |
41 | ||
42 | #include "AliMUONVDigit.h" | |
43 | ||
44 | #include <Riostream.h> | |
45 | #include <TClass.h> | |
46 | ||
47 | /// \cond CLASSIMP | |
48 | ClassImp(AliMUONVDigit) | |
49 | /// \endcond | |
50 | ||
51 | //_____________________________________________________________________________ | |
52 | AliMUONVDigit::AliMUONVDigit(Int_t detElemId, Int_t eCardId, | |
53 | Int_t eCardChannel, Int_t cathode) | |
54 | : TObject() | |
55 | { | |
56 | /// Normal constructor for trigger digits | |
57 | SetUniqueID(BuildUniqueID(detElemId,eCardId,eCardChannel,cathode)); | |
58 | } | |
59 | ||
60 | //_____________________________________________________________________________ | |
61 | AliMUONVDigit::AliMUONVDigit() | |
62 | { | |
63 | /// Default ctor | |
64 | } | |
65 | ||
66 | //_____________________________________________________________________________ | |
67 | AliMUONVDigit::~AliMUONVDigit() | |
68 | { | |
69 | /// dtor | |
70 | } | |
71 | ||
36a01415 | 72 | //_____________________________________________________________________________ |
73 | Bool_t | |
74 | AliMUONVDigit::IsEqual(const TObject* object) const | |
75 | { | |
22dce0e3 | 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...) | |
79 | ||
36a01415 | 80 | const AliMUONVDigit* d = static_cast<const AliMUONVDigit*>(object); |
81 | ||
82 | return ( DetElemId() == d->DetElemId() && | |
83 | Cathode() == d->Cathode() && | |
84 | ManuId() == d->ManuId() && | |
85 | ManuChannel() == d->ManuChannel() ); | |
86 | } | |
87 | ||
88 | //_____________________________________________________________________________ | |
89 | Int_t | |
90 | AliMUONVDigit::Compare(const TObject* object) const | |
91 | { | |
22dce0e3 | 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... | |
94 | /// | |
36a01415 | 95 | const AliMUONVDigit* d = static_cast<const AliMUONVDigit*>(object); |
96 | ||
97 | if ( DetElemId() > d->DetElemId() ) | |
98 | { | |
99 | return 1; | |
100 | } | |
101 | else if ( DetElemId() < d->DetElemId() ) | |
102 | { | |
103 | return -1; | |
104 | } | |
105 | else | |
106 | { | |
107 | if ( Charge() > d->Charge() ) | |
108 | { | |
109 | return 1; | |
110 | } | |
111 | else if ( Charge() < d->Charge() ) | |
112 | { | |
113 | return -1; | |
114 | } | |
115 | else | |
116 | { | |
117 | if ( ManuId() < d->ManuId() ) | |
118 | { | |
119 | return 1; | |
120 | } | |
121 | else if ( ManuId() > d->ManuId() ) | |
122 | { | |
123 | return -1; | |
124 | } | |
125 | else | |
126 | { | |
127 | return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1; | |
128 | } | |
129 | } | |
130 | } | |
131 | return 0; | |
132 | } | |
133 | ||
d6c3334d | 134 | //_____________________________________________________________________________ |
135 | UInt_t | |
136 | AliMUONVDigit::BuildUniqueID(Int_t detElemId, Int_t manuId, | |
137 | Int_t manuChannel, Int_t cathode) | |
138 | { | |
139 | /// Build a single integer with id information | |
140 | return ( ( detElemId ) | ( manuId << 12 ) | ( manuChannel << 24 ) | |
141 | | ( cathode << 30 ) ); | |
142 | } | |
143 | ||
144 | //_____________________________________________________________________________ | |
145 | Int_t | |
146 | AliMUONVDigit::DetElemId(UInt_t uniqueID) | |
147 | { | |
148 | /// Return detection element id part of the uniqueID | |
149 | return uniqueID & 0xFFF; | |
150 | } | |
151 | ||
152 | //_____________________________________________________________________________ | |
153 | Int_t | |
154 | AliMUONVDigit::ManuChannel(UInt_t uniqueID) | |
155 | { | |
156 | /// Return manuChannel part of the uniqueID | |
157 | return ( uniqueID & 0x3F000000 ) >> 24; | |
158 | } | |
159 | ||
160 | //_____________________________________________________________________________ | |
161 | Int_t | |
162 | AliMUONVDigit::ManuId(UInt_t uniqueID) | |
163 | { | |
164 | /// Return manuId part of the uniqueID | |
165 | return ( uniqueID & 0xFFF000 ) >> 12; | |
166 | } | |
167 | ||
168 | //_____________________________________________________________________________ | |
169 | Int_t | |
170 | AliMUONVDigit::Cathode(UInt_t uniqueID) | |
171 | { | |
172 | /// Return the cathode part of the uniqueID | |
173 | return ( uniqueID & 0x40000000 ) >> 30; | |
174 | } | |
175 | ||
176 | //_____________________________________________________________________________ | |
177 | void | |
178 | AliMUONVDigit::DecodeUniqueID(UInt_t uniqueID, | |
179 | Int_t& detElemId, Int_t& manuId, | |
180 | Int_t& manuChannel, Int_t& cathode) | |
181 | { | |
182 | /// Unpack uniqueID into 4 elements | |
183 | detElemId = DetElemId(uniqueID); | |
184 | manuId = ManuId(uniqueID); | |
185 | manuChannel = ManuChannel(uniqueID); | |
186 | cathode = Cathode(uniqueID); | |
187 | } | |
188 | ||
189 | //_____________________________________________________________________________ | |
190 | const char* | |
191 | AliMUONVDigit::GetName() const | |
192 | { | |
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()); | |
196 | } | |
197 | ||
198 | //_____________________________________________________________________________ | |
199 | void | |
200 | AliMUONVDigit::Print(Option_t* opt) const | |
201 | { | |
202 | /// Dump to screen. | |
203 | /// If opt=="tracks", info on tracks are printed too. | |
204 | ||
205 | cout << Form("<%s>: ID %12u DE %4d Cath %d (Ix,Iy)=(%3d,%3d) (Manu,Channel)=(%4d,%2d)" | |
206 | ", Charge=%7.2f", | |
207 | ClassName(),GetUniqueID(), | |
208 | DetElemId(),Cathode(),PadX(),PadY(),ManuId(),ManuChannel(),Charge()); | |
209 | if ( IsSaturated() ) | |
210 | { | |
211 | cout << "(S)"; | |
212 | } | |
213 | else | |
214 | { | |
215 | cout << " "; | |
216 | } | |
217 | ||
218 | if ( IsCalibrated() ) | |
219 | { | |
220 | cout << "(C)"; | |
221 | } | |
222 | else | |
223 | { | |
224 | cout << " "; | |
225 | } | |
226 | ||
227 | if ( IsUsed() ) | |
228 | { | |
229 | cout << "(U)"; | |
230 | } | |
231 | else | |
232 | { | |
233 | cout << " "; | |
234 | } | |
235 | ||
236 | cout << Form(" ADC=%4d StatusMap=%04x",ADC(),StatusMap()); | |
237 | ||
238 | TString options(opt); | |
239 | options.ToLower(); | |
240 | if ( options.Contains("tracks") && HasMCInformation() ) | |
241 | { | |
242 | cout << " Hit " << setw(3) << Hit(); | |
243 | Int_t ntracks = Ntracks(); | |
244 | if (ntracks) | |
245 | { | |
246 | cout << " Tracks : " << setw(2) << ntracks; | |
247 | for ( Int_t i = 0; i < ntracks; ++i ) | |
248 | { | |
249 | cout << " Track(" << i << ")=" << setw(3) << Track(i) | |
250 | << " Charge(" << i << ")=" << setw(5) << TrackCharge(i); | |
251 | } | |
252 | } | |
253 | else | |
254 | { | |
255 | cout << " no track info."; | |
256 | } | |
257 | } | |
258 | cout << endl; | |
259 | } |