]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUONDigit.cxx
- Update and add new ESD QA histograms
[u/mrichter/AliRoot.git] / MUON / AliMUONDigit.cxx
... / ...
CommitLineData
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
16/* $Id$ */
17
18#include "AliMUONDigit.h"
19
20//-----------------------------------------------------------------------------
21/// \class AliMUONDigit
22/// A class representing a digit (with MC information if possible)
23/// in the MUON spectrometer either in tracking or trigger chambers.
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,
29/// with no electronic noise whatsoever) or digits (simulated ones but
30/// including electronic noise and de-calibration, to closely ressemble real ones).
31//-----------------------------------------------------------------------------
32
33/// \cond CLASSIMP
34ClassImp(AliMUONDigit)
35/// \endcond
36
37//_____________________________________________________________________________
38AliMUONDigit::AliMUONDigit()
39:
40AliMUONVDigit(),
41fDetElemId(0),
42fManuId(0),
43fManuChannel(0),
44fSignal(0.0),
45fPadX(-1),
46fPadY(-1),
47fCathode(0),
48fADC(0),
49fFlags(0),
50fNtracks(0),
51fTcharges(0x0),
52fTracks(0x0),
53fHit(0),
54fStatusMap(0)
55{
56 /// Default constructor
57}
58
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
83//_____________________________________________________________________________
84AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
85: AliMUONVDigit(),
86fDetElemId(0),
87fManuId(0),
88fManuChannel(0),
89fSignal(0.0),
90fPadX(-1),
91fPadY(-1),
92fCathode(0),
93fADC(0),
94fFlags(0),
95fNtracks(0),
96fTcharges(0x0),
97fTracks(0x0),
98fHit(0),
99fStatusMap(0)
100{
101 /// Copy constructor
102
103 (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
104}
105
106//_____________________________________________________________________________
107AliMUONDigit::~AliMUONDigit()
108{
109 /// Destructor
110
111 delete[] fTcharges;
112 delete[] fTracks;
113}
114
115//_____________________________________________________________________________
116void
117AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge)
118{
119 /// Add 1 track information to the track list we keep.
120 /// The implementation below is dumb, you've been warned !
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];
136 Float_t* newTcharges = new Float_t[fNtracks+1];
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{
160 /// Reset this digit, in particular the internal arrays are deleted.
161
162 delete[] fTracks;
163 delete[] fTcharges;
164 fTracks=0x0;
165 fTcharges=0x0;
166 fNtracks=0;
167}
168
169//______________________________________________________________________________
170void
171AliMUONDigit::Copy(TObject& obj) const
172{
173 /// Copy this line to line.
174
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 {
196 digit.fTcharges = new Float_t[fNtracks];
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
206 digit.fHit = fHit;
207 digit.fStatusMap = fStatusMap;
208}
209
210
211//_____________________________________________________________________________
212Bool_t
213AliMUONDigit::IsNoiseOnly() const
214{
215 /// Whether this (simulated only) digit is only due to noise.
216
217 return (fFlags & fgkNoiseOnlyMask );
218}
219
220//_____________________________________________________________________________
221Bool_t
222AliMUONDigit::IsSaturated() const
223{
224 /// Whether this digit is saturated or not.
225
226 return (fFlags & fgkSaturatedMask );
227}
228
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
248//_____________________________________________________________________________
249Bool_t
250AliMUONDigit::IsEfficiencyApplied() const
251{
252 /// Whether this digit had efficiency applied or not
253
254 return (fFlags & fgkEfficiencyMask );
255}
256
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 {
269 fFlags &= ~fgkUsedMask;
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 {
285 fFlags &= ~fgkCalibratedMask;
286 }
287}
288
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 {
301 fFlags &= ~fgkEfficiencyMask;
302 }
303}
304
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
328//_____________________________________________________________________________
329void
330AliMUONDigit::NoiseOnly(Bool_t value)
331{
332 /// Set the NoiseOnly status of this digit.
333
334 if ( value )
335 {
336 fFlags |= fgkNoiseOnlyMask;
337 }
338 else
339 {
340 fFlags &= ~fgkNoiseOnlyMask;
341 }
342}
343
344//_____________________________________________________________________________
345AliMUONDigit&
346AliMUONDigit::operator=(const AliMUONDigit& digit)
347{
348 /// Assignement operator.
349
350 if ( this != &digit )
351 {
352 digit.Copy(*this);
353 }
354 return *this;
355}
356
357//_____________________________________________________________________________
358void
359AliMUONDigit::PatchTracks(Int_t mask)
360{
361 /// Add mask to each track number.
362
363 for ( Int_t i = 0; i < Ntracks(); ++i )
364 {
365 fTracks[i] += mask;
366 }
367}
368
369//_____________________________________________________________________________
370void
371AliMUONDigit::Saturated(Bool_t value)
372{
373 /// Set the saturation status of this digit.
374
375 if ( value )
376 {
377 fFlags |= fgkSaturatedMask;
378 }
379 else
380 {
381 fFlags &= ~fgkSaturatedMask;
382 }
383}
384
385//_____________________________________________________________________________
386Int_t
387AliMUONDigit::Track(Int_t i) const
388{
389 /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
390
391 if ( i >= 0 && i < fNtracks )
392 {
393 return fTracks[i];
394 }
395
396 return -1;
397}
398
399//_____________________________________________________________________________
400Float_t
401AliMUONDigit::TrackCharge(Int_t i) const
402{
403 /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
404
405 if ( i >= 0 && i < fNtracks )
406 {
407 return fTcharges[i];
408 }
409
410 return -1;
411}
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}