]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDigit.cxx
Adding a protection
[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
5350e3a6 169//______________________________________________________________________________
170void
171AliMUONDigit::Copy(TObject& obj) const
172{
5398f946 173 /// Copy this line to line.
174
5350e3a6 175 TObject::Copy(obj);
176 AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
177
178 digit.fDetElemId = fDetElemId;
179 digit.fManuId = fManuId;
180 digit.fManuChannel = fManuChannel;
181 digit.fSignal = fSignal;
182
183 digit.fPadX = fPadX;
184 digit.fPadY = fPadY;
185 digit.fCathode = fCathode;
186 digit.fADC = fADC;
187 digit.fFlags = fFlags;
188
189 digit.fNtracks = fNtracks;
190
191 delete[] digit.fTcharges;
192 delete[] digit.fTracks;
193
194 if ( fNtracks )
195 {
8a92eee6 196 digit.fTcharges = new Float_t[fNtracks];
5350e3a6 197 digit.fTracks = new Int_t[fNtracks];
198 }
199
200 for ( Int_t i=0; i<fNtracks; ++i )
201 {
202 digit.fTcharges[i] = fTcharges[i];
203 digit.fTracks[i] = fTracks[i];
204 }
205
5350e3a6 206 digit.fHit = fHit;
aaf7adc0 207 digit.fStatusMap = fStatusMap;
5350e3a6 208}
81b31073 209
5a91ea86 210
b1d79ad7 211//_____________________________________________________________________________
212Bool_t
213AliMUONDigit::IsNoiseOnly() const
214{
5398f946 215 /// Whether this (simulated only) digit is only due to noise.
216
b1d79ad7 217 return (fFlags & fgkNoiseOnlyMask );
218}
219
5350e3a6 220//_____________________________________________________________________________
221Bool_t
222AliMUONDigit::IsSaturated() const
223{
5398f946 224 /// Whether this digit is saturated or not.
225
b1d79ad7 226 return (fFlags & fgkSaturatedMask );
227}
228
5a91ea86 229//_____________________________________________________________________________
230Bool_t
231AliMUONDigit::IsCalibrated() const
232{
233 /// Whether this digit is calibrated or not
234
235 return (fFlags & fgkCalibratedMask );
236}
237
238
239//_____________________________________________________________________________
240Bool_t
241AliMUONDigit::IsUsed() const
242{
243 /// Whether this digit is used or not (in a cluster, for instance)
244
245 return (fFlags & fgkUsedMask );
246}
247
b1d79ad7 248//_____________________________________________________________________________
1d4e6965 249Bool_t
250AliMUONDigit::IsEfficiencyApplied() const
251{
252 /// Whether this digit had efficiency applied or not
253
254 return (fFlags & fgkEfficiencyMask );
255}
256
5a91ea86 257//_____________________________________________________________________________
258void
259AliMUONDigit::Used(Bool_t value)
260{
261 /// Set the Used status of this digit.
262
263 if ( value )
264 {
265 fFlags |= fgkUsedMask;
266 }
267 else
268 {
b742a45b 269 fFlags &= ~fgkUsedMask;
5a91ea86 270 }
271}
272
273//_____________________________________________________________________________
274void
275AliMUONDigit::Calibrated(Bool_t value)
276{
277 /// Set the Calibrated status of this digit.
278
279 if ( value )
280 {
281 fFlags |= fgkCalibratedMask;
282 }
283 else
284 {
b742a45b 285 fFlags &= ~fgkCalibratedMask;
5a91ea86 286 }
287}
288
1d4e6965 289//_____________________________________________________________________________
290void
291AliMUONDigit::EfficiencyApplied(Bool_t value)
292{
293 /// Set the EfficiencyApplied status of this digit.
294
295 if ( value )
296 {
297 fFlags |= fgkEfficiencyMask;
298 }
299 else
300 {
b742a45b 301 fFlags &= ~fgkEfficiencyMask;
1d4e6965 302 }
303}
304
5a91ea86 305//_____________________________________________________________________________
306Bool_t
307AliMUONDigit::MergeWith(const AliMUONVDigit& src)
308{
309 /// Merge with src.
310
311 Bool_t check = ( src.DetElemId() == DetElemId() &&
312 src.PadX() == PadX() &&
313 src.PadY() == PadY() &&
314 src.Cathode() == Cathode() );
315 if (!check)
316 {
317 return kFALSE;
318 }
319
320 AddCharge(src.Charge());
321 for ( Int_t i = 0; i < src.Ntracks(); ++i )
322 {
323 AddTrack(src.Track(i),src.TrackCharge(i));
324 }
325 return kTRUE;
326}
327
1d4e6965 328//_____________________________________________________________________________
b1d79ad7 329void
330AliMUONDigit::NoiseOnly(Bool_t value)
331{
5398f946 332 /// Set the NoiseOnly status of this digit.
333
b1d79ad7 334 if ( value )
335 {
336 fFlags |= fgkNoiseOnlyMask;
337 }
338 else
339 {
b742a45b 340 fFlags &= ~fgkNoiseOnlyMask;
b1d79ad7 341 }
5350e3a6 342}
81b31073 343
5350e3a6 344//_____________________________________________________________________________
345AliMUONDigit&
346AliMUONDigit::operator=(const AliMUONDigit& digit)
347{
5398f946 348 /// Assignement operator.
349
0c8556b9 350 if ( this != &digit )
351 {
352 digit.Copy(*this);
353 }
5350e3a6 354 return *this;
355}
356
357//_____________________________________________________________________________
358void
359AliMUONDigit::PatchTracks(Int_t mask)
360{
5398f946 361 /// Add mask to each track number.
362
5350e3a6 363 for ( Int_t i = 0; i < Ntracks(); ++i )
364 {
365 fTracks[i] += mask;
366 }
a9e2aefa 367}
61adb9bd 368
81b31073 369//_____________________________________________________________________________
370void
5350e3a6 371AliMUONDigit::Saturated(Bool_t value)
81b31073 372{
5398f946 373 /// Set the saturation status of this digit.
374
5350e3a6 375 if ( value )
376 {
b1d79ad7 377 fFlags |= fgkSaturatedMask;
5350e3a6 378 }
379 else
380 {
b742a45b 381 fFlags &= ~fgkSaturatedMask;
5350e3a6 382 }
81b31073 383}
a713db22 384
81b31073 385//_____________________________________________________________________________
5350e3a6 386Int_t
387AliMUONDigit::Track(Int_t i) const
81b31073 388{
5398f946 389 /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
390
5350e3a6 391 if ( i >= 0 && i < fNtracks )
392 {
393 return fTracks[i];
394 }
395
396 return -1;
81b31073 397}
398
5350e3a6 399//_____________________________________________________________________________
8a92eee6 400Float_t
5350e3a6 401AliMUONDigit::TrackCharge(Int_t i) const
402{
5398f946 403 /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
404
5350e3a6 405 if ( i >= 0 && i < fNtracks )
406 {
407 return fTcharges[i];
408 }
81b31073 409
5350e3a6 410 return -1;
411}
5a91ea86 412
413//_____________________________________________________________________________
414UInt_t
415AliMUONDigit::GetUniqueID() const
416{
417 /// Return a single integer with id information
418
419 return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode());
420}