]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDigit.cxx
Adding links to README pages
[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
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 32ClassImp(AliMUONDigit)
5398f946 33/// \endcond
5350e3a6 34
61adb9bd 35//_____________________________________________________________________________
81b31073 36AliMUONDigit::AliMUONDigit()
5350e3a6 37:
5a91ea86 38AliMUONVDigit(),
39fDetElemId(0),
40fManuId(0),
41fManuChannel(0),
8a92eee6 42fSignal(0.0),
5350e3a6 43fPadX(-1),
44fPadY(-1),
5a91ea86 45fCathode(0),
81b31073 46fADC(0),
5350e3a6 47fFlags(0),
48fNtracks(0),
49fTcharges(0x0),
50fTracks(0x0),
aaf7adc0 51fHit(0),
52fStatusMap(0)
61adb9bd 53{
5398f946 54 /// Default constructor
81b31073 55}
61adb9bd 56
5a91ea86 57//_____________________________________________________________________________
58AliMUONDigit::AliMUONDigit(Int_t detElemId, Int_t manuId,
59 Int_t manuChannel, Int_t cathode)
60:
61AliMUONVDigit(detElemId,manuId,manuChannel,cathode),
62fDetElemId(detElemId),
63fManuId(manuId),
64fManuChannel(manuChannel),
65fSignal(0.0),
66fPadX(-1),
67fPadY(-1),
68fCathode(cathode),
69fADC(0),
70fFlags(0),
71fNtracks(0),
72fTcharges(0x0),
73fTracks(0x0),
74fHit(0),
75fStatusMap(0)
76{
77 /// Normal constructor
78}
79
80
81b31073 81//_____________________________________________________________________________
82AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
5a91ea86 83: AliMUONVDigit(),
84fDetElemId(0),
85fManuId(0),
86fManuChannel(0),
8a92eee6 87fSignal(0.0),
5350e3a6 88fPadX(-1),
89fPadY(-1),
5a91ea86 90fCathode(0),
5350e3a6 91fADC(0),
92fFlags(0),
93fNtracks(0),
94fTcharges(0x0),
95fTracks(0x0),
aaf7adc0 96fHit(0),
97fStatusMap(0)
81b31073 98{
5398f946 99 /// Copy constructor
100
81b31073 101 (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
61adb9bd 102}
103
5350e3a6 104//_____________________________________________________________________________
105AliMUONDigit::~AliMUONDigit()
106{
5398f946 107 /// Destructor
108
5350e3a6 109 delete[] fTcharges;
110 delete[] fTracks;
111}
112
113//_____________________________________________________________________________
114void
8a92eee6 115AliMUONDigit::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//_____________________________________________________________________________
155void
156AliMUONDigit::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//_____________________________________________________________________________
168Int_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//______________________________________________________________________________
212void
213AliMUONDigit::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//_____________________________________________________________________________
254Bool_t
255AliMUONDigit::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//_____________________________________________________________________________
263Bool_t
264AliMUONDigit::IsSaturated() const
265{
5398f946 266 /// Whether this digit is saturated or not.
267
b1d79ad7 268 return (fFlags & fgkSaturatedMask );
269}
270
5a91ea86 271//_____________________________________________________________________________
272Bool_t
273AliMUONDigit::IsCalibrated() const
274{
275 /// Whether this digit is calibrated or not
276
277 return (fFlags & fgkCalibratedMask );
278}
279
280
281//_____________________________________________________________________________
282Bool_t
283AliMUONDigit::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 291Bool_t
292AliMUONDigit::IsEfficiencyApplied() const
293{
294 /// Whether this digit had efficiency applied or not
295
296 return (fFlags & fgkEfficiencyMask );
297}
298
5a91ea86 299//_____________________________________________________________________________
300void
301AliMUONDigit::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//_____________________________________________________________________________
316void
317AliMUONDigit::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//_____________________________________________________________________________
332void
333AliMUONDigit::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//_____________________________________________________________________________
348Bool_t
349AliMUONDigit::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 371void
372AliMUONDigit::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//_____________________________________________________________________________
387AliMUONDigit&
388AliMUONDigit::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//_____________________________________________________________________________
398void
399AliMUONDigit::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//_____________________________________________________________________________
410void
5350e3a6 411AliMUONDigit::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 426Int_t
427AliMUONDigit::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 440Float_t
5350e3a6 441AliMUONDigit::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//_____________________________________________________________________________
454UInt_t
455AliMUONDigit::GetUniqueID() const
456{
457 /// Return a single integer with id information
458
459 return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode());
460}