]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDigit.cxx
Removing class AliMUONTrackK
[u/mrichter/AliRoot.git] / MUON / AliMUONDigit.cxx
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 /// \class AliMUONDigit
21 /// A class representing a digit (with MC information if possible)
22 /// in the MUON spectrometer either in tracking or trigger chambers.
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, 
28 /// with no electronic noise whatsoever) or digits (simulated ones but 
29 /// including electronic noise and de-calibration, to closely ressemble real ones).
30
31 /// \cond CLASSIMP
32 ClassImp(AliMUONDigit)
33 /// \endcond
34
35 //_____________________________________________________________________________
36 AliMUONDigit::AliMUONDigit()
37
38 AliMUONVDigit(),
39 fDetElemId(0),
40 fManuId(0),
41 fManuChannel(0),
42 fSignal(0.0),
43 fPadX(-1),
44 fPadY(-1),
45 fCathode(0),
46 fADC(0),
47 fFlags(0),
48 fNtracks(0),
49 fTcharges(0x0),
50 fTracks(0x0),
51 fHit(0),
52 fStatusMap(0)
53 {
54   /// Default constructor
55 }
56
57 //_____________________________________________________________________________
58 AliMUONDigit::AliMUONDigit(Int_t detElemId, Int_t manuId,
59                            Int_t manuChannel, Int_t cathode)
60
61 AliMUONVDigit(detElemId,manuId,manuChannel,cathode),
62 fDetElemId(detElemId),
63 fManuId(manuId),
64 fManuChannel(manuChannel),
65 fSignal(0.0),
66 fPadX(-1),
67 fPadY(-1),
68 fCathode(cathode),
69 fADC(0),
70 fFlags(0),
71 fNtracks(0),
72 fTcharges(0x0),
73 fTracks(0x0),
74 fHit(0),
75 fStatusMap(0)
76 {
77   /// Normal constructor
78 }
79
80
81 //_____________________________________________________________________________
82 AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
83 : AliMUONVDigit(),
84 fDetElemId(0),
85 fManuId(0),
86 fManuChannel(0),
87 fSignal(0.0),
88 fPadX(-1),
89 fPadY(-1),
90 fCathode(0),
91 fADC(0),
92 fFlags(0),
93 fNtracks(0),
94 fTcharges(0x0),
95 fTracks(0x0),
96 fHit(0),
97 fStatusMap(0)
98 {
99   /// Copy constructor
100
101    (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
102 }
103
104 //_____________________________________________________________________________
105 AliMUONDigit::~AliMUONDigit()
106 {
107   /// Destructor 
108
109   delete[] fTcharges;
110   delete[] fTracks;
111 }
112
113 //_____________________________________________________________________________
114 void
115 AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge)
116 {
117   /// Add 1 track information to the track list we keep.
118   /// The implementation below is dumb, you've been warned !
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];
134   Float_t* newTcharges = new Float_t[fNtracks+1];
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 //_____________________________________________________________________________
155 void 
156 AliMUONDigit::Clear(Option_t*)
157 {
158   /// Reset this digit, in particular the internal arrays are deleted.
159
160   delete[] fTracks;
161   delete[] fTcharges;
162   fTracks=0x0;
163   fTcharges=0x0;
164   fNtracks=0;
165 }
166
167 //_____________________________________________________________________________
168 Int_t AliMUONDigit::Compare(const TObject *obj) const
169 {
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...
172
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   {
185     if ( Charge() > d->Charge() )
186     {
187       return 1;
188     }
189     else if ( Charge() < d->Charge() )
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 //______________________________________________________________________________
212 void 
213 AliMUONDigit::Copy(TObject& obj) const
214 {
215   /// Copy this line to line.
216
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   {
238     digit.fTcharges = new Float_t[fNtracks];
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   
248   digit.fHit = fHit;
249   digit.fStatusMap = fStatusMap;
250 }
251
252
253 //_____________________________________________________________________________
254 Bool_t
255 AliMUONDigit::IsNoiseOnly() const
256 {
257   /// Whether this (simulated only) digit is only due to noise.
258
259   return (fFlags & fgkNoiseOnlyMask );
260 }
261
262 //_____________________________________________________________________________
263 Bool_t
264 AliMUONDigit::IsSaturated() const
265 {
266   /// Whether this digit is saturated or not.
267
268   return (fFlags & fgkSaturatedMask );
269 }
270
271 //_____________________________________________________________________________
272 Bool_t
273 AliMUONDigit::IsCalibrated() const
274 {
275   /// Whether this digit is calibrated or not
276   
277   return (fFlags & fgkCalibratedMask );
278 }
279
280
281 //_____________________________________________________________________________
282 Bool_t
283 AliMUONDigit::IsUsed() const
284 {
285   /// Whether this digit is used or not (in a cluster, for instance)
286   
287   return (fFlags & fgkUsedMask );
288 }
289
290 //_____________________________________________________________________________
291 Bool_t
292 AliMUONDigit::IsEfficiencyApplied() const
293 {
294   /// Whether this digit had efficiency applied or not
295   
296   return (fFlags & fgkEfficiencyMask );
297 }
298
299 //_____________________________________________________________________________
300 void
301 AliMUONDigit::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 //_____________________________________________________________________________
316 void
317 AliMUONDigit::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
331 //_____________________________________________________________________________
332 void
333 AliMUONDigit::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
347 //_____________________________________________________________________________
348 Bool_t
349 AliMUONDigit::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
370 //_____________________________________________________________________________
371 void
372 AliMUONDigit::NoiseOnly(Bool_t value)
373 {
374   /// Set the NoiseOnly status of this digit.
375
376   if ( value )
377   {
378     fFlags |= fgkNoiseOnlyMask;
379   }
380   else
381   {
382     fFlags ^= fgkNoiseOnlyMask;
383   }
384 }
385
386 //_____________________________________________________________________________
387 AliMUONDigit& 
388 AliMUONDigit::operator=(const AliMUONDigit& digit)
389 {
390   /// Assignement operator.
391
392   AliMUONDigit a(digit);
393   a.Copy(*this);
394   return *this;
395 }
396
397 //_____________________________________________________________________________
398 void
399 AliMUONDigit::PatchTracks(Int_t mask)
400 {
401   /// Add mask to each track number.
402
403   for ( Int_t i = 0; i < Ntracks(); ++i )
404   {
405     fTracks[i] += mask;
406   }
407 }
408
409 //_____________________________________________________________________________
410 void
411 AliMUONDigit::Saturated(Bool_t value)
412 {
413   /// Set the saturation status of this digit.
414
415   if ( value )
416   {
417     fFlags |= fgkSaturatedMask;
418   }
419   else
420   {
421     fFlags ^= fgkSaturatedMask;
422   }
423 }
424
425 //_____________________________________________________________________________
426 Int_t
427 AliMUONDigit::Track(Int_t i) const
428 {
429   /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
430
431   if ( i >= 0 && i < fNtracks ) 
432   {
433     return fTracks[i];
434   }
435
436   return -1;
437 }
438
439 //_____________________________________________________________________________
440 Float_t
441 AliMUONDigit::TrackCharge(Int_t i) const
442 {
443   /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
444
445   if ( i >= 0 && i < fNtracks ) 
446   {
447     return fTcharges[i];
448   }
449
450   return -1;
451 }
452
453 //_____________________________________________________________________________
454 UInt_t
455 AliMUONDigit::GetUniqueID() const
456 {
457   /// Return a single integer with id information
458
459   return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode());
460 }