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()
58 /// Default constructor
61 //_____________________________________________________________________________
62 AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
81 (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
84 //_____________________________________________________________________________
85 AliMUONDigit::~AliMUONDigit()
93 //_____________________________________________________________________________
95 AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge)
97 /// Add 1 track information to the track list we keep.
98 /// The implementation below is dumb, you've been warned !
100 // First check if track is already there, in which
101 // case we simply increment its charge.
102 for ( Int_t i = 0; i < Ntracks(); ++i )
104 if ( Track(i) == trackNumber )
106 fTcharges[i] += trackCharge;
111 // Nope. It's a brand new track. Make a new array to get space
112 // for it, copy the old array into new one, and add the track.
113 Int_t* newTracks = new Int_t[fNtracks+1];
114 Float_t* newTcharges = new Float_t[fNtracks+1];
116 for ( Int_t i = 0; i < fNtracks; ++i )
118 newTracks[i] = fTracks[i];
119 newTcharges[i] = fTcharges[i];
122 newTracks[fNtracks] = trackNumber;
123 newTcharges[fNtracks] = trackCharge;
129 fTcharges = newTcharges;
134 //_____________________________________________________________________________
136 AliMUONDigit::Clear(Option_t*)
138 /// Reset this digit, in particular the internal arrays are deleted.
147 //_____________________________________________________________________________
148 Int_t AliMUONDigit::Compare(const TObject *obj) const
150 /// The order defined below is first by DE, then Signal, then
151 /// manuId, and then manuChannel, i.e. it should be a total ordering...
153 const AliMUONDigit* d = static_cast<const AliMUONDigit*>(obj);
155 if ( DetElemId() > d->DetElemId() )
159 else if ( DetElemId() < d->DetElemId() )
165 if ( Signal() > d->Signal() )
169 else if ( Signal() < d->Signal() )
175 if ( ManuId() < d->ManuId() )
179 else if ( ManuId() > d->ManuId() )
185 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
191 //______________________________________________________________________________
193 AliMUONDigit::Copy(TObject& obj) const
195 /// Copy this line to line.
198 AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
200 digit.fDetElemId = fDetElemId;
201 digit.fManuId = fManuId;
202 digit.fManuChannel = fManuChannel;
203 digit.fSignal = fSignal;
207 digit.fCathode = fCathode;
209 digit.fFlags = fFlags;
211 digit.fNtracks = fNtracks;
213 delete[] digit.fTcharges;
214 delete[] digit.fTracks;
218 digit.fTcharges = new Float_t[fNtracks];
219 digit.fTracks = new Int_t[fNtracks];
222 for ( Int_t i=0; i<fNtracks; ++i )
224 digit.fTcharges[i] = fTcharges[i];
225 digit.fTracks[i] = fTracks[i];
228 digit.fPhysics = fPhysics;
232 //_____________________________________________________________________________
234 AliMUONDigit::IsNoiseOnly() const
236 /// Whether this (simulated only) digit is only due to noise.
238 return (fFlags & fgkNoiseOnlyMask );
241 //_____________________________________________________________________________
243 AliMUONDigit::IsSaturated() const
245 /// Whether this digit is saturated or not.
247 return (fFlags & fgkSaturatedMask );
250 //_____________________________________________________________________________
252 AliMUONDigit::NoiseOnly(Bool_t value)
254 /// Set the NoiseOnly status of this digit.
258 fFlags |= fgkNoiseOnlyMask;
262 fFlags ^= fgkNoiseOnlyMask;
266 //_____________________________________________________________________________
268 AliMUONDigit::operator=(const AliMUONDigit& digit)
270 /// Assignement operator.
272 AliMUONDigit a(digit);
277 //_____________________________________________________________________________
279 AliMUONDigit::PatchTracks(Int_t mask)
281 /// Add mask to each track number.
283 for ( Int_t i = 0; i < Ntracks(); ++i )
289 //_____________________________________________________________________________
291 AliMUONDigit::Print(Option_t* opt) const
294 /// If opt=="tracks", info on tracks are printed too.
296 cout << Form("<AliMUONDigit>: DE %4d Cath %d (Ix,Iy)=(%3d,%3d) (Manu,Channel)=(%4d,%2d)"
297 ", Signal=%7.2f Physics=%7.2f",
298 DetElemId(),Cathode(),PadX(),PadY(),ManuId(),ManuChannel(),Signal(),
309 cout << " ADC=" << setw(4) << ADC();
310 cout << " Flags=0x" << setw(4) << hex << setfill('0') << fFlags << dec
312 TString options(opt);
314 if ( options.Contains("tracks") )
316 cout << " Hit " << setw(3) << Hit();
317 Int_t ntracks = Ntracks();
320 cout << " Tracks : " << setw(2) << ntracks;
321 for ( Int_t i = 0; i < ntracks; ++i )
323 cout << " Track(" << i << ")=" << setw(3) << Track(i)
324 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
329 cout << " no track info.";
335 //_____________________________________________________________________________
337 AliMUONDigit::Saturated(Bool_t value)
339 /// Set the saturation status of this digit.
343 fFlags |= fgkSaturatedMask;
347 fFlags ^= fgkSaturatedMask;
351 //_____________________________________________________________________________
353 AliMUONDigit::SetElectronics(Int_t manuId, Int_t manuChannel)
356 //FIXME: should we check that the values are ok here ??
359 fManuChannel=manuChannel;
362 //_____________________________________________________________________________
364 AliMUONDigit::Track(Int_t i) const
366 /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
368 if ( i >= 0 && i < fNtracks )
376 //_____________________________________________________________________________
378 AliMUONDigit::TrackCharge(Int_t i) const
380 /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
382 if ( i >= 0 && i < fNtracks )