]>
Commit | Line | Data |
---|---|---|
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 | |
34 | ClassImp(AliMUONDigit) | |
35 | /// \endcond | |
36 | ||
37 | //_____________________________________________________________________________ | |
38 | AliMUONDigit::AliMUONDigit() | |
39 | : | |
40 | AliMUONVDigit(), | |
41 | fDetElemId(0), | |
42 | fManuId(0), | |
43 | fManuChannel(0), | |
44 | fSignal(0.0), | |
45 | fPadX(-1), | |
46 | fPadY(-1), | |
47 | fCathode(0), | |
48 | fADC(0), | |
49 | fFlags(0), | |
50 | fNtracks(0), | |
51 | fTcharges(0x0), | |
52 | fTracks(0x0), | |
53 | fHit(0), | |
54 | fStatusMap(0) | |
55 | { | |
56 | /// Default constructor | |
57 | } | |
58 | ||
59 | //_____________________________________________________________________________ | |
60 | AliMUONDigit::AliMUONDigit(Int_t detElemId, Int_t manuId, | |
61 | Int_t manuChannel, Int_t cathode) | |
62 | : | |
63 | AliMUONVDigit(detElemId,manuId,manuChannel,cathode), | |
64 | fDetElemId(detElemId), | |
65 | fManuId(manuId), | |
66 | fManuChannel(manuChannel), | |
67 | fSignal(0.0), | |
68 | fPadX(-1), | |
69 | fPadY(-1), | |
70 | fCathode(cathode), | |
71 | fADC(0), | |
72 | fFlags(0), | |
73 | fNtracks(0), | |
74 | fTcharges(0x0), | |
75 | fTracks(0x0), | |
76 | fHit(0), | |
77 | fStatusMap(0) | |
78 | { | |
79 | /// Normal constructor | |
80 | } | |
81 | ||
82 | ||
83 | //_____________________________________________________________________________ | |
84 | AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit) | |
85 | : AliMUONVDigit(), | |
86 | fDetElemId(0), | |
87 | fManuId(0), | |
88 | fManuChannel(0), | |
89 | fSignal(0.0), | |
90 | fPadX(-1), | |
91 | fPadY(-1), | |
92 | fCathode(0), | |
93 | fADC(0), | |
94 | fFlags(0), | |
95 | fNtracks(0), | |
96 | fTcharges(0x0), | |
97 | fTracks(0x0), | |
98 | fHit(0), | |
99 | fStatusMap(0) | |
100 | { | |
101 | /// Copy constructor | |
102 | ||
103 | (static_cast<const AliMUONDigit&>(digit)).Copy(*this); | |
104 | } | |
105 | ||
106 | //_____________________________________________________________________________ | |
107 | AliMUONDigit::~AliMUONDigit() | |
108 | { | |
109 | /// Destructor | |
110 | ||
111 | delete[] fTcharges; | |
112 | delete[] fTracks; | |
113 | } | |
114 | ||
115 | //_____________________________________________________________________________ | |
116 | void | |
117 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
157 | void | |
158 | AliMUONDigit::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 | //______________________________________________________________________________ | |
170 | void | |
171 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
212 | Bool_t | |
213 | AliMUONDigit::IsNoiseOnly() const | |
214 | { | |
215 | /// Whether this (simulated only) digit is only due to noise. | |
216 | ||
217 | return (fFlags & fgkNoiseOnlyMask ); | |
218 | } | |
219 | ||
220 | //_____________________________________________________________________________ | |
221 | Bool_t | |
222 | AliMUONDigit::IsSaturated() const | |
223 | { | |
224 | /// Whether this digit is saturated or not. | |
225 | ||
226 | return (fFlags & fgkSaturatedMask ); | |
227 | } | |
228 | ||
229 | //_____________________________________________________________________________ | |
230 | Bool_t | |
231 | AliMUONDigit::IsCalibrated() const | |
232 | { | |
233 | /// Whether this digit is calibrated or not | |
234 | ||
235 | return (fFlags & fgkCalibratedMask ); | |
236 | } | |
237 | ||
238 | ||
239 | //_____________________________________________________________________________ | |
240 | Bool_t | |
241 | AliMUONDigit::IsUsed() const | |
242 | { | |
243 | /// Whether this digit is used or not (in a cluster, for instance) | |
244 | ||
245 | return (fFlags & fgkUsedMask ); | |
246 | } | |
247 | ||
248 | //_____________________________________________________________________________ | |
249 | Bool_t | |
250 | AliMUONDigit::IsEfficiencyApplied() const | |
251 | { | |
252 | /// Whether this digit had efficiency applied or not | |
253 | ||
254 | return (fFlags & fgkEfficiencyMask ); | |
255 | } | |
256 | ||
257 | //_____________________________________________________________________________ | |
258 | void | |
259 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
274 | void | |
275 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
290 | void | |
291 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
306 | Bool_t | |
307 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
329 | void | |
330 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
345 | AliMUONDigit& | |
346 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
358 | void | |
359 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
370 | void | |
371 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
386 | Int_t | |
387 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
400 | Float_t | |
401 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
414 | UInt_t | |
415 | AliMUONDigit::GetUniqueID() const | |
416 | { | |
417 | /// Return a single integer with id information | |
418 | ||
419 | return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode()); | |
420 | } |