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);
85 //_____________________________________________________________________________
86 AliMUONDigit::AliMUONDigit(Int_t *digits)
104 /// Creates a MUON digit object to be updated
109 fCathode = digits[2];
111 fPhysics = digits[4];
113 fDetElemId = digits[6];
120 //_____________________________________________________________________________
121 AliMUONDigit::AliMUONDigit(Int_t *tracks, Int_t *charges, Int_t *digits)
138 /// Creates a MUON digit object
143 fCathode = digits[2];
145 fPhysics = digits[4];
147 fDetElemId = digits[6];
152 // For backward compatibility, which assumed 10 tracks.
154 fTcharges = new Int_t[fNtracks];
155 fTracks = new Int_t[fNtracks];
157 for ( Int_t i=0; i<fNtracks; ++i )
159 fTcharges[i] = charges[i];
160 fTracks[i] = tracks[i];
165 //_____________________________________________________________________________
166 AliMUONDigit::~AliMUONDigit()
174 //_____________________________________________________________________________
176 AliMUONDigit::AddTrack(Int_t trackNumber, Int_t trackCharge)
178 /// Add 1 track information to the track list we keep.
179 /// The implementation below is dumb, you've been warned !
181 // First check if track is already there, in which
182 // case we simply increment its charge.
183 for ( Int_t i = 0; i < Ntracks(); ++i )
185 if ( Track(i) == trackNumber )
187 fTcharges[i] += trackCharge;
192 // Nope. It's a brand new track. Make a new array to get space
193 // for it, copy the old array into new one, and add the track.
194 Int_t* newTracks = new Int_t[fNtracks+1];
195 Int_t* newTcharges = new Int_t[fNtracks+1];
197 for ( Int_t i = 0; i < fNtracks; ++i )
199 newTracks[i] = fTracks[i];
200 newTcharges[i] = fTcharges[i];
203 newTracks[fNtracks] = trackNumber;
204 newTcharges[fNtracks] = trackCharge;
210 fTcharges = newTcharges;
215 //_____________________________________________________________________________
217 AliMUONDigit::Clear(Option_t*)
219 /// Reset this digit, in particular the internal arrays are deleted.
228 //_____________________________________________________________________________
229 Int_t AliMUONDigit::Compare(const TObject *obj) const
231 /// The order defined below is first by DE, then Signal, then
232 /// manuId, and then manuChannel, i.e. it should be a total ordering...
234 const AliMUONDigit* d = static_cast<const AliMUONDigit*>(obj);
236 if ( DetElemId() > d->DetElemId() )
240 else if ( DetElemId() < d->DetElemId() )
246 if ( Signal() > d->Signal() )
250 else if ( Signal() < d->Signal() )
256 if ( ManuId() < d->ManuId() )
260 else if ( ManuId() > d->ManuId() )
266 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
272 //______________________________________________________________________________
274 AliMUONDigit::Copy(TObject& obj) const
276 /// Copy this line to line.
279 AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
281 digit.fDetElemId = fDetElemId;
282 digit.fManuId = fManuId;
283 digit.fManuChannel = fManuChannel;
284 digit.fSignal = fSignal;
288 digit.fCathode = fCathode;
290 digit.fFlags = fFlags;
292 digit.fNtracks = fNtracks;
294 delete[] digit.fTcharges;
295 delete[] digit.fTracks;
299 digit.fTcharges = new Int_t[fNtracks];
300 digit.fTracks = new Int_t[fNtracks];
303 for ( Int_t i=0; i<fNtracks; ++i )
305 digit.fTcharges[i] = fTcharges[i];
306 digit.fTracks[i] = fTracks[i];
309 digit.fPhysics = fPhysics;
313 //_____________________________________________________________________________
315 AliMUONDigit::IsNoiseOnly() const
317 /// Whether this (simulated only) digit is only due to noise.
319 return (fFlags & fgkNoiseOnlyMask );
322 //_____________________________________________________________________________
324 AliMUONDigit::IsSaturated() const
326 /// Whether this digit is saturated or not.
328 return (fFlags & fgkSaturatedMask );
331 //_____________________________________________________________________________
333 AliMUONDigit::NoiseOnly(Bool_t value)
335 /// Set the NoiseOnly status of this digit.
339 fFlags |= fgkNoiseOnlyMask;
343 fFlags ^= fgkNoiseOnlyMask;
347 //_____________________________________________________________________________
349 AliMUONDigit::operator=(const AliMUONDigit& digit)
351 /// Assignement operator.
353 AliMUONDigit a(digit);
358 //_____________________________________________________________________________
360 AliMUONDigit::PatchTracks(Int_t mask)
362 /// Add mask to each track number.
364 for ( Int_t i = 0; i < Ntracks(); ++i )
370 //_____________________________________________________________________________
372 AliMUONDigit::Print(Option_t* opt) const
375 /// If opt=="tracks", info on tracks are printed too.
377 cout << "<AliMUONDigit>: DetEle " << setw(5) << DetElemId()
378 << " Cath " << setw(2) << Cathode()
379 << " (Ix,Iy)=(" << setw(3) << PadX() << "," << setw(3) << PadY()
381 << " (Manu,Channel)=(" << setw(4) << ManuId()
382 << "," << setw(3) << ManuChannel() << ")"
383 << " Signal=" << setw(6) << Signal()
384 << " Physics=" << setw(4) << Physics();
393 cout << " ADC=" << setw(4) << ADC();
394 cout << " Flags=0x" << setw(4) << hex << setfill('0') << fFlags << dec
396 TString options(opt);
398 if ( options.Contains("tracks") )
400 cout << " Hit " << setw(3) << Hit();
401 Int_t ntracks = Ntracks();
404 cout << " Tracks : " << setw(2) << ntracks;
405 for ( Int_t i = 0; i < ntracks; ++i )
407 cout << " Track(" << i << ")=" << setw(3) << Track(i)
408 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
413 cout << " no track info.";
419 //_____________________________________________________________________________
421 AliMUONDigit::Saturated(Bool_t value)
423 /// Set the saturation status of this digit.
427 fFlags |= fgkSaturatedMask;
431 fFlags ^= fgkSaturatedMask;
435 //_____________________________________________________________________________
437 AliMUONDigit::SetElectronics(Int_t manuId, Int_t manuChannel)
440 //FIXME: should we check that the values are ok here ??
443 fManuChannel=manuChannel;
446 //_____________________________________________________________________________
448 AliMUONDigit::Track(Int_t i) const
450 /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
452 if ( i >= 0 && i < fNtracks )
460 //_____________________________________________________________________________
462 AliMUONDigit::TrackCharge(Int_t i) const
464 /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
466 if ( i >= 0 && i < fNtracks )