1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONDigit.h"
20 #include "Riostream.h"
23 /// \class AliMUONDigit
24 /// A class representing a digit in the MUON spectrometer
25 /// either in tracking or trigger chambers.
27 /// A digit holds the signal (proportional to a charge) on a pad
30 /// This class is used to represent either sdigits (purely simulated digit,
31 /// with no electronic noise whatsoever) or digits (either real digits or
32 /// simulated ones but including electronic noise and de-calibration, to
33 /// closely ressemble real ones).
36 ClassImp(AliMUONDigit)
39 //_____________________________________________________________________________
40 AliMUONDigit::AliMUONDigit()
59 /// Default constructor
62 //_____________________________________________________________________________
63 AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
83 (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
86 //_____________________________________________________________________________
87 AliMUONDigit::~AliMUONDigit()
95 //_____________________________________________________________________________
97 AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge)
99 /// Add 1 track information to the track list we keep.
100 /// The implementation below is dumb, you've been warned !
102 // First check if track is already there, in which
103 // case we simply increment its charge.
104 for ( Int_t i = 0; i < Ntracks(); ++i )
106 if ( Track(i) == trackNumber )
108 fTcharges[i] += trackCharge;
113 // Nope. It's a brand new track. Make a new array to get space
114 // for it, copy the old array into new one, and add the track.
115 Int_t* newTracks = new Int_t[fNtracks+1];
116 Float_t* newTcharges = new Float_t[fNtracks+1];
118 for ( Int_t i = 0; i < fNtracks; ++i )
120 newTracks[i] = fTracks[i];
121 newTcharges[i] = fTcharges[i];
124 newTracks[fNtracks] = trackNumber;
125 newTcharges[fNtracks] = trackCharge;
131 fTcharges = newTcharges;
136 //_____________________________________________________________________________
138 AliMUONDigit::Clear(Option_t*)
140 /// Reset this digit, in particular the internal arrays are deleted.
149 //_____________________________________________________________________________
150 Int_t AliMUONDigit::Compare(const TObject *obj) const
152 /// The order defined below is first by DE, then Signal, then
153 /// manuId, and then manuChannel, i.e. it should be a total ordering...
155 const AliMUONDigit* d = static_cast<const AliMUONDigit*>(obj);
157 if ( DetElemId() > d->DetElemId() )
161 else if ( DetElemId() < d->DetElemId() )
167 if ( Signal() > d->Signal() )
171 else if ( Signal() < d->Signal() )
177 if ( ManuId() < d->ManuId() )
181 else if ( ManuId() > d->ManuId() )
187 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
193 //______________________________________________________________________________
195 AliMUONDigit::Copy(TObject& obj) const
197 /// Copy this line to line.
200 AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
202 digit.fDetElemId = fDetElemId;
203 digit.fManuId = fManuId;
204 digit.fManuChannel = fManuChannel;
205 digit.fSignal = fSignal;
209 digit.fCathode = fCathode;
211 digit.fFlags = fFlags;
213 digit.fNtracks = fNtracks;
215 delete[] digit.fTcharges;
216 delete[] digit.fTracks;
220 digit.fTcharges = new Float_t[fNtracks];
221 digit.fTracks = new Int_t[fNtracks];
224 for ( Int_t i=0; i<fNtracks; ++i )
226 digit.fTcharges[i] = fTcharges[i];
227 digit.fTracks[i] = fTracks[i];
230 digit.fPhysics = fPhysics;
232 digit.fStatusMap = fStatusMap;
235 //_____________________________________________________________________________
237 AliMUONDigit::IsNoiseOnly() const
239 /// Whether this (simulated only) digit is only due to noise.
241 return (fFlags & fgkNoiseOnlyMask );
244 //_____________________________________________________________________________
246 AliMUONDigit::IsSaturated() const
248 /// Whether this digit is saturated or not.
250 return (fFlags & fgkSaturatedMask );
253 //_____________________________________________________________________________
255 AliMUONDigit::IsEfficiencyApplied() const
257 /// Whether this digit had efficiency applied or not
259 return (fFlags & fgkEfficiencyMask );
262 //_____________________________________________________________________________
264 AliMUONDigit::EfficiencyApplied(Bool_t value)
266 /// Set the EfficiencyApplied status of this digit.
270 fFlags |= fgkEfficiencyMask;
274 fFlags ^= fgkEfficiencyMask;
278 //_____________________________________________________________________________
280 AliMUONDigit::NoiseOnly(Bool_t value)
282 /// Set the NoiseOnly status of this digit.
286 fFlags |= fgkNoiseOnlyMask;
290 fFlags ^= fgkNoiseOnlyMask;
294 //_____________________________________________________________________________
296 AliMUONDigit::operator=(const AliMUONDigit& digit)
298 /// Assignement operator.
300 AliMUONDigit a(digit);
305 //_____________________________________________________________________________
307 AliMUONDigit::PatchTracks(Int_t mask)
309 /// Add mask to each track number.
311 for ( Int_t i = 0; i < Ntracks(); ++i )
317 //_____________________________________________________________________________
319 AliMUONDigit::Print(Option_t* opt) const
322 /// If opt=="tracks", info on tracks are printed too.
324 cout << Form("<AliMUONDigit>: DE %4d Cath %d (Ix,Iy)=(%3d,%3d) (Manu,Channel)=(%4d,%2d)"
325 ", Signal=%7.2f Physics=%7.2f",
326 DetElemId(),Cathode(),PadX(),PadY(),ManuId(),ManuChannel(),Signal(),
337 cout << " ADC=" << setw(4) << ADC();
338 cout << " Flags=0x" << setw(4) << hex << setfill('0') << fFlags << dec
340 cout << " StatusMap=0x" << setw(4) << hex << setfill('0') << StatusMap() << dec
343 TString options(opt);
345 if ( options.Contains("tracks") )
347 cout << " Hit " << setw(3) << Hit();
348 Int_t ntracks = Ntracks();
351 cout << " Tracks : " << setw(2) << ntracks;
352 for ( Int_t i = 0; i < ntracks; ++i )
354 cout << " Track(" << i << ")=" << setw(3) << Track(i)
355 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
360 cout << " no track info.";
366 //_____________________________________________________________________________
368 AliMUONDigit::Saturated(Bool_t value)
370 /// Set the saturation status of this digit.
374 fFlags |= fgkSaturatedMask;
378 fFlags ^= fgkSaturatedMask;
382 //_____________________________________________________________________________
384 AliMUONDigit::SetElectronics(Int_t manuId, Int_t manuChannel)
387 //FIXME: should we check that the values are ok here ??
390 fManuChannel=manuChannel;
393 //_____________________________________________________________________________
395 AliMUONDigit::Track(Int_t i) const
397 /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
399 if ( i >= 0 && i < fNtracks )
407 //_____________________________________________________________________________
409 AliMUONDigit::TrackCharge(Int_t i) const
411 /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
413 if ( i >= 0 && i < fNtracks )