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