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