]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDigit.cxx
Adding comment lines to class description needed for Root documentation,
[u/mrichter/AliRoot.git] / MUON / AliMUONDigit.cxx
CommitLineData
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 34ClassImp(AliMUONDigit)
5398f946 35/// \endcond
5350e3a6 36
61adb9bd 37//_____________________________________________________________________________
81b31073 38AliMUONDigit::AliMUONDigit()
5350e3a6 39:
5a91ea86 40AliMUONVDigit(),
41fDetElemId(0),
42fManuId(0),
43fManuChannel(0),
8a92eee6 44fSignal(0.0),
5350e3a6 45fPadX(-1),
46fPadY(-1),
5a91ea86 47fCathode(0),
81b31073 48fADC(0),
5350e3a6 49fFlags(0),
50fNtracks(0),
51fTcharges(0x0),
52fTracks(0x0),
aaf7adc0 53fHit(0),
54fStatusMap(0)
61adb9bd 55{
5398f946 56 /// Default constructor
81b31073 57}
61adb9bd 58
5a91ea86 59//_____________________________________________________________________________
60AliMUONDigit::AliMUONDigit(Int_t detElemId, Int_t manuId,
61 Int_t manuChannel, Int_t cathode)
62:
63AliMUONVDigit(detElemId,manuId,manuChannel,cathode),
64fDetElemId(detElemId),
65fManuId(manuId),
66fManuChannel(manuChannel),
67fSignal(0.0),
68fPadX(-1),
69fPadY(-1),
70fCathode(cathode),
71fADC(0),
72fFlags(0),
73fNtracks(0),
74fTcharges(0x0),
75fTracks(0x0),
76fHit(0),
77fStatusMap(0)
78{
79 /// Normal constructor
80}
81
82
81b31073 83//_____________________________________________________________________________
84AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
5a91ea86 85: AliMUONVDigit(),
86fDetElemId(0),
87fManuId(0),
88fManuChannel(0),
8a92eee6 89fSignal(0.0),
5350e3a6 90fPadX(-1),
91fPadY(-1),
5a91ea86 92fCathode(0),
5350e3a6 93fADC(0),
94fFlags(0),
95fNtracks(0),
96fTcharges(0x0),
97fTracks(0x0),
aaf7adc0 98fHit(0),
99fStatusMap(0)
81b31073 100{
5398f946 101 /// Copy constructor
102
81b31073 103 (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
61adb9bd 104}
105
5350e3a6 106//_____________________________________________________________________________
107AliMUONDigit::~AliMUONDigit()
108{
5398f946 109 /// Destructor
110
5350e3a6 111 delete[] fTcharges;
112 delete[] fTracks;
113}
114
115//_____________________________________________________________________________
116void
8a92eee6 117AliMUONDigit::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//_____________________________________________________________________________
157void
158AliMUONDigit::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//_____________________________________________________________________________
170Int_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//______________________________________________________________________________
214void
215AliMUONDigit::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//_____________________________________________________________________________
256Bool_t
257AliMUONDigit::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//_____________________________________________________________________________
265Bool_t
266AliMUONDigit::IsSaturated() const
267{
5398f946 268 /// Whether this digit is saturated or not.
269
b1d79ad7 270 return (fFlags & fgkSaturatedMask );
271}
272
5a91ea86 273//_____________________________________________________________________________
274Bool_t
275AliMUONDigit::IsCalibrated() const
276{
277 /// Whether this digit is calibrated or not
278
279 return (fFlags & fgkCalibratedMask );
280}
281
282
283//_____________________________________________________________________________
284Bool_t
285AliMUONDigit::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 293Bool_t
294AliMUONDigit::IsEfficiencyApplied() const
295{
296 /// Whether this digit had efficiency applied or not
297
298 return (fFlags & fgkEfficiencyMask );
299}
300
5a91ea86 301//_____________________________________________________________________________
302void
303AliMUONDigit::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//_____________________________________________________________________________
318void
319AliMUONDigit::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//_____________________________________________________________________________
334void
335AliMUONDigit::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//_____________________________________________________________________________
350Bool_t
351AliMUONDigit::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 373void
374AliMUONDigit::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//_____________________________________________________________________________
389AliMUONDigit&
390AliMUONDigit::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//_____________________________________________________________________________
400void
401AliMUONDigit::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//_____________________________________________________________________________
412void
5350e3a6 413AliMUONDigit::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 428Int_t
429AliMUONDigit::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 442Float_t
5350e3a6 443AliMUONDigit::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//_____________________________________________________________________________
456UInt_t
457AliMUONDigit::GetUniqueID() const
458{
459 /// Return a single integer with id information
460
461 return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode());
462}