]>
Commit | Line | Data |
---|---|---|
a9e2aefa | 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 | ||
88cb7938 | 16 | /* $Id$ */ |
a9e2aefa | 17 | |
18 | #include "AliMUONDigit.h" | |
19 | ||
5398f946 | 20 | /// \class AliMUONDigit |
5a91ea86 | 21 | /// A class representing a digit (with MC information if possible) |
22 | /// in the MUON spectrometer either in tracking or trigger chambers. | |
b1d79ad7 | 23 | /// |
24 | /// A digit holds the signal (proportional to a charge) on a pad | |
25 | /// (or strip). | |
26 | /// | |
27 | /// This class is used to represent either sdigits (purely simulated digit, | |
5a91ea86 | 28 | /// with no electronic noise whatsoever) or digits (simulated ones but |
29 | /// including electronic noise and de-calibration, to closely ressemble real ones). | |
81b31073 | 30 | |
5398f946 | 31 | /// \cond CLASSIMP |
b1d79ad7 | 32 | ClassImp(AliMUONDigit) |
5398f946 | 33 | /// \endcond |
5350e3a6 | 34 | |
61adb9bd | 35 | //_____________________________________________________________________________ |
81b31073 | 36 | AliMUONDigit::AliMUONDigit() |
5350e3a6 | 37 | : |
5a91ea86 | 38 | AliMUONVDigit(), |
39 | fDetElemId(0), | |
40 | fManuId(0), | |
41 | fManuChannel(0), | |
8a92eee6 | 42 | fSignal(0.0), |
5350e3a6 | 43 | fPadX(-1), |
44 | fPadY(-1), | |
5a91ea86 | 45 | fCathode(0), |
81b31073 | 46 | fADC(0), |
5350e3a6 | 47 | fFlags(0), |
48 | fNtracks(0), | |
49 | fTcharges(0x0), | |
50 | fTracks(0x0), | |
aaf7adc0 | 51 | fHit(0), |
52 | fStatusMap(0) | |
61adb9bd | 53 | { |
5398f946 | 54 | /// Default constructor |
81b31073 | 55 | } |
61adb9bd | 56 | |
5a91ea86 | 57 | //_____________________________________________________________________________ |
58 | AliMUONDigit::AliMUONDigit(Int_t detElemId, Int_t manuId, | |
59 | Int_t manuChannel, Int_t cathode) | |
60 | : | |
61 | AliMUONVDigit(detElemId,manuId,manuChannel,cathode), | |
62 | fDetElemId(detElemId), | |
63 | fManuId(manuId), | |
64 | fManuChannel(manuChannel), | |
65 | fSignal(0.0), | |
66 | fPadX(-1), | |
67 | fPadY(-1), | |
68 | fCathode(cathode), | |
69 | fADC(0), | |
70 | fFlags(0), | |
71 | fNtracks(0), | |
72 | fTcharges(0x0), | |
73 | fTracks(0x0), | |
74 | fHit(0), | |
75 | fStatusMap(0) | |
76 | { | |
77 | /// Normal constructor | |
78 | } | |
79 | ||
80 | ||
81b31073 | 81 | //_____________________________________________________________________________ |
82 | AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit) | |
5a91ea86 | 83 | : AliMUONVDigit(), |
84 | fDetElemId(0), | |
85 | fManuId(0), | |
86 | fManuChannel(0), | |
8a92eee6 | 87 | fSignal(0.0), |
5350e3a6 | 88 | fPadX(-1), |
89 | fPadY(-1), | |
5a91ea86 | 90 | fCathode(0), |
5350e3a6 | 91 | fADC(0), |
92 | fFlags(0), | |
93 | fNtracks(0), | |
94 | fTcharges(0x0), | |
95 | fTracks(0x0), | |
aaf7adc0 | 96 | fHit(0), |
97 | fStatusMap(0) | |
81b31073 | 98 | { |
5398f946 | 99 | /// Copy constructor |
100 | ||
81b31073 | 101 | (static_cast<const AliMUONDigit&>(digit)).Copy(*this); |
61adb9bd | 102 | } |
103 | ||
5350e3a6 | 104 | //_____________________________________________________________________________ |
105 | AliMUONDigit::~AliMUONDigit() | |
106 | { | |
5398f946 | 107 | /// Destructor |
108 | ||
5350e3a6 | 109 | delete[] fTcharges; |
110 | delete[] fTracks; | |
111 | } | |
112 | ||
113 | //_____________________________________________________________________________ | |
114 | void | |
8a92eee6 | 115 | AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge) |
5350e3a6 | 116 | { |
5398f946 | 117 | /// Add 1 track information to the track list we keep. |
118 | /// The implementation below is dumb, you've been warned ! | |
5350e3a6 | 119 | |
120 | // First check if track is already there, in which | |
121 | // case we simply increment its charge. | |
122 | for ( Int_t i = 0; i < Ntracks(); ++i ) | |
123 | { | |
124 | if ( Track(i) == trackNumber ) | |
125 | { | |
126 | fTcharges[i] += trackCharge; | |
127 | return; | |
128 | } | |
129 | } | |
130 | ||
131 | // Nope. It's a brand new track. Make a new array to get space | |
132 | // for it, copy the old array into new one, and add the track. | |
133 | Int_t* newTracks = new Int_t[fNtracks+1]; | |
8a92eee6 | 134 | Float_t* newTcharges = new Float_t[fNtracks+1]; |
5350e3a6 | 135 | |
136 | for ( Int_t i = 0; i < fNtracks; ++i ) | |
137 | { | |
138 | newTracks[i] = fTracks[i]; | |
139 | newTcharges[i] = fTcharges[i]; | |
140 | } | |
141 | ||
142 | newTracks[fNtracks] = trackNumber; | |
143 | newTcharges[fNtracks] = trackCharge; | |
144 | ||
145 | delete[] fTracks; | |
146 | delete[] fTcharges; | |
147 | ||
148 | fTracks = newTracks; | |
149 | fTcharges = newTcharges; | |
150 | ||
151 | ++fNtracks; | |
152 | } | |
153 | ||
154 | //_____________________________________________________________________________ | |
155 | void | |
156 | AliMUONDigit::Clear(Option_t*) | |
157 | { | |
5398f946 | 158 | /// Reset this digit, in particular the internal arrays are deleted. |
159 | ||
5350e3a6 | 160 | delete[] fTracks; |
161 | delete[] fTcharges; | |
162 | fTracks=0x0; | |
163 | fTcharges=0x0; | |
164 | fNtracks=0; | |
a9e2aefa | 165 | } |
166 | ||
81b31073 | 167 | //_____________________________________________________________________________ |
168 | Int_t AliMUONDigit::Compare(const TObject *obj) const | |
a9e2aefa | 169 | { |
5398f946 | 170 | /// The order defined below is first by DE, then Signal, then |
171 | /// manuId, and then manuChannel, i.e. it should be a total ordering... | |
81b31073 | 172 | |
5350e3a6 | 173 | const AliMUONDigit* d = static_cast<const AliMUONDigit*>(obj); |
174 | ||
175 | if ( DetElemId() > d->DetElemId() ) | |
176 | { | |
177 | return 1; | |
178 | } | |
179 | else if ( DetElemId() < d->DetElemId() ) | |
180 | { | |
181 | return -1; | |
182 | } | |
183 | else | |
184 | { | |
5a91ea86 | 185 | if ( Charge() > d->Charge() ) |
5350e3a6 | 186 | { |
187 | return 1; | |
188 | } | |
5a91ea86 | 189 | else if ( Charge() < d->Charge() ) |
5350e3a6 | 190 | { |
191 | return -1; | |
192 | } | |
193 | else | |
194 | { | |
195 | if ( ManuId() < d->ManuId() ) | |
196 | { | |
197 | return 1; | |
198 | } | |
199 | else if ( ManuId() > d->ManuId() ) | |
200 | { | |
201 | return -1; | |
202 | } | |
203 | else | |
204 | { | |
205 | return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1; | |
206 | } | |
207 | } | |
208 | } | |
209 | } | |
210 | ||
211 | //______________________________________________________________________________ | |
212 | void | |
213 | AliMUONDigit::Copy(TObject& obj) const | |
214 | { | |
5398f946 | 215 | /// Copy this line to line. |
216 | ||
5350e3a6 | 217 | TObject::Copy(obj); |
218 | AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj); | |
219 | ||
220 | digit.fDetElemId = fDetElemId; | |
221 | digit.fManuId = fManuId; | |
222 | digit.fManuChannel = fManuChannel; | |
223 | digit.fSignal = fSignal; | |
224 | ||
225 | digit.fPadX = fPadX; | |
226 | digit.fPadY = fPadY; | |
227 | digit.fCathode = fCathode; | |
228 | digit.fADC = fADC; | |
229 | digit.fFlags = fFlags; | |
230 | ||
231 | digit.fNtracks = fNtracks; | |
232 | ||
233 | delete[] digit.fTcharges; | |
234 | delete[] digit.fTracks; | |
235 | ||
236 | if ( fNtracks ) | |
237 | { | |
8a92eee6 | 238 | digit.fTcharges = new Float_t[fNtracks]; |
5350e3a6 | 239 | digit.fTracks = new Int_t[fNtracks]; |
240 | } | |
241 | ||
242 | for ( Int_t i=0; i<fNtracks; ++i ) | |
243 | { | |
244 | digit.fTcharges[i] = fTcharges[i]; | |
245 | digit.fTracks[i] = fTracks[i]; | |
246 | } | |
247 | ||
5350e3a6 | 248 | digit.fHit = fHit; |
aaf7adc0 | 249 | digit.fStatusMap = fStatusMap; |
5350e3a6 | 250 | } |
81b31073 | 251 | |
5a91ea86 | 252 | |
b1d79ad7 | 253 | //_____________________________________________________________________________ |
254 | Bool_t | |
255 | AliMUONDigit::IsNoiseOnly() const | |
256 | { | |
5398f946 | 257 | /// Whether this (simulated only) digit is only due to noise. |
258 | ||
b1d79ad7 | 259 | return (fFlags & fgkNoiseOnlyMask ); |
260 | } | |
261 | ||
5350e3a6 | 262 | //_____________________________________________________________________________ |
263 | Bool_t | |
264 | AliMUONDigit::IsSaturated() const | |
265 | { | |
5398f946 | 266 | /// Whether this digit is saturated or not. |
267 | ||
b1d79ad7 | 268 | return (fFlags & fgkSaturatedMask ); |
269 | } | |
270 | ||
5a91ea86 | 271 | //_____________________________________________________________________________ |
272 | Bool_t | |
273 | AliMUONDigit::IsCalibrated() const | |
274 | { | |
275 | /// Whether this digit is calibrated or not | |
276 | ||
277 | return (fFlags & fgkCalibratedMask ); | |
278 | } | |
279 | ||
280 | ||
281 | //_____________________________________________________________________________ | |
282 | Bool_t | |
283 | AliMUONDigit::IsUsed() const | |
284 | { | |
285 | /// Whether this digit is used or not (in a cluster, for instance) | |
286 | ||
287 | return (fFlags & fgkUsedMask ); | |
288 | } | |
289 | ||
b1d79ad7 | 290 | //_____________________________________________________________________________ |
1d4e6965 | 291 | Bool_t |
292 | AliMUONDigit::IsEfficiencyApplied() const | |
293 | { | |
294 | /// Whether this digit had efficiency applied or not | |
295 | ||
296 | return (fFlags & fgkEfficiencyMask ); | |
297 | } | |
298 | ||
5a91ea86 | 299 | //_____________________________________________________________________________ |
300 | void | |
301 | AliMUONDigit::Used(Bool_t value) | |
302 | { | |
303 | /// Set the Used status of this digit. | |
304 | ||
305 | if ( value ) | |
306 | { | |
307 | fFlags |= fgkUsedMask; | |
308 | } | |
309 | else | |
310 | { | |
311 | fFlags ^= fgkUsedMask; | |
312 | } | |
313 | } | |
314 | ||
315 | //_____________________________________________________________________________ | |
316 | void | |
317 | AliMUONDigit::Calibrated(Bool_t value) | |
318 | { | |
319 | /// Set the Calibrated status of this digit. | |
320 | ||
321 | if ( value ) | |
322 | { | |
323 | fFlags |= fgkCalibratedMask; | |
324 | } | |
325 | else | |
326 | { | |
327 | fFlags ^= fgkCalibratedMask; | |
328 | } | |
329 | } | |
330 | ||
1d4e6965 | 331 | //_____________________________________________________________________________ |
332 | void | |
333 | AliMUONDigit::EfficiencyApplied(Bool_t value) | |
334 | { | |
335 | /// Set the EfficiencyApplied status of this digit. | |
336 | ||
337 | if ( value ) | |
338 | { | |
339 | fFlags |= fgkEfficiencyMask; | |
340 | } | |
341 | else | |
342 | { | |
343 | fFlags ^= fgkEfficiencyMask; | |
344 | } | |
345 | } | |
346 | ||
5a91ea86 | 347 | //_____________________________________________________________________________ |
348 | Bool_t | |
349 | AliMUONDigit::MergeWith(const AliMUONVDigit& src) | |
350 | { | |
351 | /// Merge with src. | |
352 | ||
353 | Bool_t check = ( src.DetElemId() == DetElemId() && | |
354 | src.PadX() == PadX() && | |
355 | src.PadY() == PadY() && | |
356 | src.Cathode() == Cathode() ); | |
357 | if (!check) | |
358 | { | |
359 | return kFALSE; | |
360 | } | |
361 | ||
362 | AddCharge(src.Charge()); | |
363 | for ( Int_t i = 0; i < src.Ntracks(); ++i ) | |
364 | { | |
365 | AddTrack(src.Track(i),src.TrackCharge(i)); | |
366 | } | |
367 | return kTRUE; | |
368 | } | |
369 | ||
1d4e6965 | 370 | //_____________________________________________________________________________ |
b1d79ad7 | 371 | void |
372 | AliMUONDigit::NoiseOnly(Bool_t value) | |
373 | { | |
5398f946 | 374 | /// Set the NoiseOnly status of this digit. |
375 | ||
b1d79ad7 | 376 | if ( value ) |
377 | { | |
378 | fFlags |= fgkNoiseOnlyMask; | |
379 | } | |
380 | else | |
381 | { | |
382 | fFlags ^= fgkNoiseOnlyMask; | |
383 | } | |
5350e3a6 | 384 | } |
81b31073 | 385 | |
5350e3a6 | 386 | //_____________________________________________________________________________ |
387 | AliMUONDigit& | |
388 | AliMUONDigit::operator=(const AliMUONDigit& digit) | |
389 | { | |
5398f946 | 390 | /// Assignement operator. |
391 | ||
5350e3a6 | 392 | AliMUONDigit a(digit); |
393 | a.Copy(*this); | |
394 | return *this; | |
395 | } | |
396 | ||
397 | //_____________________________________________________________________________ | |
398 | void | |
399 | AliMUONDigit::PatchTracks(Int_t mask) | |
400 | { | |
5398f946 | 401 | /// Add mask to each track number. |
402 | ||
5350e3a6 | 403 | for ( Int_t i = 0; i < Ntracks(); ++i ) |
404 | { | |
405 | fTracks[i] += mask; | |
406 | } | |
a9e2aefa | 407 | } |
61adb9bd | 408 | |
81b31073 | 409 | //_____________________________________________________________________________ |
410 | void | |
5350e3a6 | 411 | AliMUONDigit::Saturated(Bool_t value) |
81b31073 | 412 | { |
5398f946 | 413 | /// Set the saturation status of this digit. |
414 | ||
5350e3a6 | 415 | if ( value ) |
416 | { | |
b1d79ad7 | 417 | fFlags |= fgkSaturatedMask; |
5350e3a6 | 418 | } |
419 | else | |
420 | { | |
b1d79ad7 | 421 | fFlags ^= fgkSaturatedMask; |
5350e3a6 | 422 | } |
81b31073 | 423 | } |
a713db22 | 424 | |
81b31073 | 425 | //_____________________________________________________________________________ |
5350e3a6 | 426 | Int_t |
427 | AliMUONDigit::Track(Int_t i) const | |
81b31073 | 428 | { |
5398f946 | 429 | /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1. |
430 | ||
5350e3a6 | 431 | if ( i >= 0 && i < fNtracks ) |
432 | { | |
433 | return fTracks[i]; | |
434 | } | |
435 | ||
436 | return -1; | |
81b31073 | 437 | } |
438 | ||
5350e3a6 | 439 | //_____________________________________________________________________________ |
8a92eee6 | 440 | Float_t |
5350e3a6 | 441 | AliMUONDigit::TrackCharge(Int_t i) const |
442 | { | |
5398f946 | 443 | /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1. |
444 | ||
5350e3a6 | 445 | if ( i >= 0 && i < fNtracks ) |
446 | { | |
447 | return fTcharges[i]; | |
448 | } | |
81b31073 | 449 | |
5350e3a6 | 450 | return -1; |
451 | } | |
5a91ea86 | 452 | |
453 | //_____________________________________________________________________________ | |
454 | UInt_t | |
455 | AliMUONDigit::GetUniqueID() const | |
456 | { | |
457 | /// Return a single integer with id information | |
458 | ||
459 | return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode()); | |
460 | } |