Line data Source code
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 18 : ClassImp(AliMUONDigit)
35 : /// \endcond
36 :
37 : //_____________________________________________________________________________
38 : AliMUONDigit::AliMUONDigit()
39 : :
40 1336 : AliMUONVDigit(),
41 1336 : fDetElemId(0),
42 1336 : fManuId(0),
43 1336 : fManuChannel(0),
44 1336 : fSignal(0.0),
45 1336 : fPadX(-1),
46 1336 : fPadY(-1),
47 1336 : fCathode(0),
48 1336 : fADC(0),
49 1336 : fFlags(0),
50 1336 : fNtracks(0),
51 1336 : fTcharges(0x0),
52 1336 : fTracks(0x0),
53 1336 : fHit(0),
54 1336 : fTime(0),
55 1336 : fStatusMap(0)
56 6680 : {
57 : /// Default constructor
58 2672 : }
59 :
60 : //_____________________________________________________________________________
61 : AliMUONDigit::AliMUONDigit(Int_t detElemId, Int_t manuId,
62 : Int_t manuChannel, Int_t cathode)
63 : :
64 974 : AliMUONVDigit(detElemId,manuId,manuChannel,cathode),
65 974 : fDetElemId(detElemId),
66 974 : fManuId(manuId),
67 974 : fManuChannel(manuChannel),
68 974 : fSignal(0.0),
69 974 : fPadX(-1),
70 974 : fPadY(-1),
71 974 : fCathode(cathode),
72 974 : fADC(0),
73 974 : fFlags(0),
74 974 : fNtracks(0),
75 974 : fTcharges(0x0),
76 974 : fTracks(0x0),
77 974 : fHit(0),
78 974 : fTime(0),
79 974 : fStatusMap(0)
80 4870 : {
81 : /// Normal constructor
82 1948 : }
83 :
84 :
85 : //_____________________________________________________________________________
86 : AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
87 2758 : : AliMUONVDigit(),
88 2758 : fDetElemId(0),
89 2758 : fManuId(0),
90 2758 : fManuChannel(0),
91 2758 : fSignal(0.0),
92 2758 : fPadX(-1),
93 2758 : fPadY(-1),
94 2758 : fCathode(0),
95 2758 : fADC(0),
96 2758 : fFlags(0),
97 2758 : fNtracks(0),
98 2758 : fTcharges(0x0),
99 2758 : fTracks(0x0),
100 2758 : fHit(0),
101 2758 : fTime(0),
102 2758 : fStatusMap(0)
103 13790 : {
104 : /// Copy constructor
105 :
106 2758 : (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
107 5516 : }
108 :
109 : //_____________________________________________________________________________
110 : AliMUONDigit::~AliMUONDigit()
111 18624 : {
112 : /// Destructor
113 :
114 5132 : delete[] fTcharges;
115 5132 : delete[] fTracks;
116 9312 : }
117 :
118 : //_____________________________________________________________________________
119 : void
120 : AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge)
121 : {
122 : /// Add 1 track information to the track list we keep.
123 : /// The implementation below is dumb, you've been warned !
124 :
125 : // First check if track is already there, in which
126 : // case we simply increment its charge.
127 3926 : for ( Int_t i = 0; i < Ntracks(); ++i )
128 : {
129 5 : if ( Track(i) == trackNumber )
130 : {
131 0 : fTcharges[i] += trackCharge;
132 0 : return;
133 : }
134 : }
135 :
136 : // Nope. It's a brand new track. Make a new array to get space
137 : // for it, copy the old array into new one, and add the track.
138 979 : Int_t* newTracks = new Int_t[fNtracks+1];
139 979 : Float_t* newTcharges = new Float_t[fNtracks+1];
140 :
141 1968 : for ( Int_t i = 0; i < fNtracks; ++i )
142 : {
143 5 : newTracks[i] = fTracks[i];
144 5 : newTcharges[i] = fTcharges[i];
145 : }
146 :
147 979 : newTracks[fNtracks] = trackNumber;
148 979 : newTcharges[fNtracks] = trackCharge;
149 :
150 984 : delete[] fTracks;
151 984 : delete[] fTcharges;
152 :
153 979 : fTracks = newTracks;
154 979 : fTcharges = newTcharges;
155 :
156 979 : ++fNtracks;
157 1958 : }
158 :
159 : //_____________________________________________________________________________
160 : void
161 : AliMUONDigit::Clear(Option_t*)
162 : {
163 : /// Reset this digit, in particular the internal arrays are deleted.
164 :
165 12939 : delete[] fTracks;
166 8626 : delete[] fTcharges;
167 4313 : fTracks=0x0;
168 4313 : fTcharges=0x0;
169 4313 : fNtracks=0;
170 4313 : }
171 :
172 : //______________________________________________________________________________
173 : void
174 : AliMUONDigit::Copy(TObject& obj) const
175 : {
176 : /// Copy this line to line.
177 :
178 5516 : TObject::Copy(obj);
179 2758 : AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
180 :
181 2758 : digit.fDetElemId = fDetElemId;
182 2758 : digit.fManuId = fManuId;
183 2758 : digit.fManuChannel = fManuChannel;
184 2758 : digit.fSignal = fSignal;
185 :
186 2758 : digit.fPadX = fPadX;
187 2758 : digit.fPadY = fPadY;
188 2758 : digit.fCathode = fCathode;
189 2758 : digit.fADC = fADC;
190 2758 : digit.fFlags = fFlags;
191 :
192 2758 : digit.fNtracks = fNtracks;
193 :
194 2758 : delete[] digit.fTcharges;
195 2758 : delete[] digit.fTracks;
196 :
197 2758 : if ( fNtracks )
198 : {
199 2758 : digit.fTcharges = new Float_t[fNtracks];
200 2758 : digit.fTracks = new Int_t[fNtracks];
201 2758 : }
202 :
203 11052 : for ( Int_t i=0; i<fNtracks; ++i )
204 : {
205 2768 : digit.fTcharges[i] = fTcharges[i];
206 2768 : digit.fTracks[i] = fTracks[i];
207 : }
208 :
209 2758 : digit.fHit = fHit;
210 2758 : digit.fTime = fTime;
211 2758 : digit.fStatusMap = fStatusMap;
212 2758 : }
213 :
214 :
215 : //_____________________________________________________________________________
216 : Bool_t
217 : AliMUONDigit::IsNoiseOnly() const
218 : {
219 : /// Whether this (simulated only) digit is only due to noise.
220 :
221 1714 : return (fFlags & fgkNoiseOnlyMask );
222 : }
223 :
224 : //_____________________________________________________________________________
225 : Bool_t
226 : AliMUONDigit::IsSaturated() const
227 : {
228 : /// Whether this digit is saturated or not.
229 :
230 1324 : return (fFlags & fgkSaturatedMask );
231 : }
232 :
233 : //_____________________________________________________________________________
234 : Bool_t
235 : AliMUONDigit::IsCalibrated() const
236 : {
237 : /// Whether this digit is calibrated or not
238 :
239 1424 : return (fFlags & fgkCalibratedMask );
240 : }
241 :
242 : //_____________________________________________________________________________
243 : Bool_t
244 : AliMUONDigit::IsConverted() const
245 : {
246 : /// Whether this digit is converted or not
247 :
248 1714 : return (fFlags & fgkConverted);
249 : }
250 :
251 : //_____________________________________________________________________________
252 : Bool_t
253 : AliMUONDigit::IsChargeInFC() const
254 : {
255 : /// Whether this digit is converted or not
256 :
257 1714 : return (fFlags & fgkChargeInFC);
258 : }
259 :
260 :
261 : //_____________________________________________________________________________
262 : Bool_t
263 : AliMUONDigit::IsUsed() const
264 : {
265 : /// Whether this digit is used or not (in a cluster, for instance)
266 :
267 0 : return (fFlags & fgkUsedMask );
268 : }
269 :
270 : //_____________________________________________________________________________
271 : Bool_t
272 : AliMUONDigit::IsEfficiencyApplied() const
273 : {
274 : /// Whether this digit had efficiency applied or not
275 :
276 0 : return (fFlags & fgkEfficiencyMask );
277 : }
278 :
279 : //_____________________________________________________________________________
280 : void
281 : AliMUONDigit::Used(Bool_t value)
282 : {
283 : /// Set the Used status of this digit.
284 :
285 0 : if ( value )
286 : {
287 0 : fFlags |= fgkUsedMask;
288 0 : }
289 : else
290 : {
291 0 : fFlags &= ~fgkUsedMask;
292 : }
293 0 : }
294 :
295 : //_____________________________________________________________________________
296 : void
297 : AliMUONDigit::Calibrated(Bool_t value)
298 : {
299 : /// Set the Calibrated status of this digit.
300 :
301 1416 : if ( value )
302 : {
303 1416 : fFlags |= fgkCalibratedMask;
304 708 : }
305 : else
306 : {
307 0 : fFlags &= ~fgkCalibratedMask;
308 : }
309 708 : }
310 :
311 : //_____________________________________________________________________________
312 : void
313 : AliMUONDigit::EfficiencyApplied(Bool_t value)
314 : {
315 : /// Set the EfficiencyApplied status of this digit.
316 :
317 0 : if ( value )
318 : {
319 0 : fFlags |= fgkEfficiencyMask;
320 0 : }
321 : else
322 : {
323 0 : fFlags &= ~fgkEfficiencyMask;
324 : }
325 0 : }
326 :
327 : //_____________________________________________________________________________
328 : Bool_t
329 : AliMUONDigit::MergeWith(const AliMUONVDigit& src)
330 : {
331 : /// Merge with src.
332 :
333 15 : Bool_t check = ( src.DetElemId() == DetElemId() &&
334 5 : src.PadX() == PadX() &&
335 5 : src.PadY() == PadY() &&
336 5 : src.Cathode() == Cathode() );
337 5 : if (!check)
338 : {
339 0 : return kFALSE;
340 : }
341 :
342 5 : AddCharge(src.Charge());
343 20 : for ( Int_t i = 0; i < src.Ntracks(); ++i )
344 : {
345 5 : AddTrack(src.Track(i),src.TrackCharge(i));
346 : }
347 5 : return kTRUE;
348 5 : }
349 :
350 : //_____________________________________________________________________________
351 : void
352 : AliMUONDigit::NoiseOnly(Bool_t value)
353 : {
354 : /// Set the NoiseOnly status of this digit.
355 :
356 0 : if ( value )
357 : {
358 0 : fFlags |= fgkNoiseOnlyMask;
359 0 : }
360 : else
361 : {
362 0 : fFlags &= ~fgkNoiseOnlyMask;
363 : }
364 0 : }
365 :
366 : //_____________________________________________________________________________
367 : AliMUONDigit&
368 : AliMUONDigit::operator=(const AliMUONDigit& digit)
369 : {
370 : /// Assignement operator.
371 :
372 0 : if ( this != &digit )
373 : {
374 0 : digit.Copy(*this);
375 0 : }
376 0 : return *this;
377 : }
378 :
379 : //_____________________________________________________________________________
380 : void
381 : AliMUONDigit::PatchTracks(Int_t mask)
382 : {
383 : /// Add mask to each track number.
384 :
385 0 : for ( Int_t i = 0; i < Ntracks(); ++i )
386 : {
387 0 : fTracks[i] += mask;
388 : }
389 0 : }
390 :
391 : //_____________________________________________________________________________
392 : void
393 : AliMUONDigit::Saturated(Bool_t value)
394 : {
395 : /// Set the saturation status of this digit.
396 :
397 1416 : if ( value )
398 : {
399 708 : fFlags |= fgkSaturatedMask;
400 0 : }
401 : else
402 : {
403 708 : fFlags &= ~fgkSaturatedMask;
404 : }
405 708 : }
406 :
407 : //_____________________________________________________________________________
408 : void
409 : AliMUONDigit::Converted(Bool_t value)
410 : {
411 : /// Set the convertion status of this digit.
412 :
413 0 : if ( value )
414 : {
415 0 : fFlags |= fgkConverted;
416 0 : }
417 : else
418 : {
419 0 : fFlags &= ~fgkConverted;
420 : }
421 0 : }
422 :
423 : //_____________________________________________________________________________
424 : void
425 : AliMUONDigit::ChargeInFC(Bool_t value)
426 : {
427 : /// Set the convertion status of this digit.
428 :
429 3364 : if ( value )
430 : {
431 3364 : fFlags |= fgkChargeInFC;
432 1682 : }
433 : else
434 : {
435 0 : fFlags &= ~fgkChargeInFC;
436 : }
437 1682 : }
438 :
439 : //_____________________________________________________________________________
440 : Int_t
441 : AliMUONDigit::Track(Int_t i) const
442 : {
443 : /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
444 :
445 528 : if ( i >= 0 && i < fNtracks )
446 : {
447 176 : return fTracks[i];
448 : }
449 :
450 0 : return -1;
451 176 : }
452 :
453 : //_____________________________________________________________________________
454 : Float_t
455 : AliMUONDigit::TrackCharge(Int_t i) const
456 : {
457 : /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
458 :
459 513 : if ( i >= 0 && i < fNtracks )
460 : {
461 171 : return fTcharges[i];
462 : }
463 :
464 0 : return -1;
465 171 : }
466 :
467 : //_____________________________________________________________________________
468 : UInt_t
469 : AliMUONDigit::GetUniqueID() const
470 : {
471 : /// Return a single integer with id information
472 :
473 1324 : return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode());
474 : }
|