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"
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)
38 //_____________________________________________________________________________
39 AliMUONDigit::AliMUONDigit()
58 // Default constructor
62 //_____________________________________________________________________________
63 AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
83 (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
87 //_____________________________________________________________________________
88 AliMUONDigit::AliMUONDigit(Int_t *digits)
107 // Creates a MUON digit object to be updated
112 fCathode = digits[2];
114 fPhysics = digits[4];
116 fDetElemId = digits[6];
123 //_____________________________________________________________________________
124 AliMUONDigit::AliMUONDigit(Int_t *tracks, Int_t *charges, Int_t *digits)
142 // Creates a MUON digit object
147 fCathode = digits[2];
149 fPhysics = digits[4];
151 fDetElemId = digits[6];
156 // For backward compatibility, which assumed 10 tracks.
158 fTcharges = new Int_t[fNtracks];
159 fTracks = new Int_t[fNtracks];
161 for ( Int_t i=0; i<fNtracks; ++i )
163 fTcharges[i] = charges[i];
164 fTracks[i] = tracks[i];
169 //_____________________________________________________________________________
170 AliMUONDigit::~AliMUONDigit()
179 //_____________________________________________________________________________
181 AliMUONDigit::AddTrack(Int_t trackNumber, Int_t trackCharge)
184 // Add 1 track information to the track list we keep.
185 // The implementation below is dumb, you've been warned !
188 // First check if track is already there, in which
189 // case we simply increment its charge.
190 for ( Int_t i = 0; i < Ntracks(); ++i )
192 if ( Track(i) == trackNumber )
194 fTcharges[i] += trackCharge;
199 // Nope. It's a brand new track. Make a new array to get space
200 // for it, copy the old array into new one, and add the track.
201 Int_t* newTracks = new Int_t[fNtracks+1];
202 Int_t* newTcharges = new Int_t[fNtracks+1];
204 for ( Int_t i = 0; i < fNtracks; ++i )
206 newTracks[i] = fTracks[i];
207 newTcharges[i] = fTcharges[i];
210 newTracks[fNtracks] = trackNumber;
211 newTcharges[fNtracks] = trackCharge;
217 fTcharges = newTcharges;
222 //_____________________________________________________________________________
224 AliMUONDigit::Clear(Option_t*)
227 // Reset this digit, in particular the internal arrays are deleted.
236 //_____________________________________________________________________________
237 Int_t AliMUONDigit::Compare(const TObject *obj) const
240 // The order defined below is first by DE, then Signal, then
241 // manuId, and then manuChannel, i.e. it should be a total ordering...
244 const AliMUONDigit* d = static_cast<const AliMUONDigit*>(obj);
246 if ( DetElemId() > d->DetElemId() )
250 else if ( DetElemId() < d->DetElemId() )
256 if ( Signal() > d->Signal() )
260 else if ( Signal() < d->Signal() )
266 if ( ManuId() < d->ManuId() )
270 else if ( ManuId() > d->ManuId() )
276 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
282 //______________________________________________________________________________
284 AliMUONDigit::Copy(TObject& obj) const
287 // Copy this line to line.
290 AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
292 digit.fDetElemId = fDetElemId;
293 digit.fManuId = fManuId;
294 digit.fManuChannel = fManuChannel;
295 digit.fSignal = fSignal;
299 digit.fCathode = fCathode;
301 digit.fFlags = fFlags;
303 digit.fNtracks = fNtracks;
305 delete[] digit.fTcharges;
306 delete[] digit.fTracks;
310 digit.fTcharges = new Int_t[fNtracks];
311 digit.fTracks = new Int_t[fNtracks];
314 for ( Int_t i=0; i<fNtracks; ++i )
316 digit.fTcharges[i] = fTcharges[i];
317 digit.fTracks[i] = fTracks[i];
320 digit.fPhysics = fPhysics;
324 //_____________________________________________________________________________
326 AliMUONDigit::IsNoiseOnly() const
328 // Whether this (simulated only) digit is only due to noise.
329 return (fFlags & fgkNoiseOnlyMask );
332 //_____________________________________________________________________________
334 AliMUONDigit::IsSaturated() const
336 // Whether this digit is saturated or not.
337 return (fFlags & fgkSaturatedMask );
340 //_____________________________________________________________________________
342 AliMUONDigit::NoiseOnly(Bool_t value)
345 // Set the NoiseOnly status of this digit.
349 fFlags |= fgkNoiseOnlyMask;
353 fFlags ^= fgkNoiseOnlyMask;
357 //_____________________________________________________________________________
359 AliMUONDigit::operator=(const AliMUONDigit& digit)
362 // Assignement operator.
364 AliMUONDigit a(digit);
369 //_____________________________________________________________________________
371 AliMUONDigit::PatchTracks(Int_t mask)
374 // Add mask to each track number.
376 for ( Int_t i = 0; i < Ntracks(); ++i )
382 //_____________________________________________________________________________
384 AliMUONDigit::Print(Option_t* opt) const
388 // If opt=="tracks", info on tracks are printed too.
390 cout << "<AliMUONDigit>: DetEle " << setw(5) << DetElemId()
391 << " Cath " << setw(2) << Cathode()
392 << " (Ix,Iy)=(" << setw(3) << PadX() << "," << setw(3) << PadY()
394 << " (Manu,Channel)=(" << setw(4) << ManuId()
395 << "," << setw(3) << ManuChannel() << ")"
396 << " Signal=" << setw(6) << Signal()
397 << " Physics=" << setw(4) << Physics();
406 cout << " ADC=" << setw(4) << ADC();
407 cout << " Flags=0x" << setw(4) << hex << setfill('0') << fFlags << dec
409 TString options(opt);
411 if ( options.Contains("tracks") )
413 cout << " Hit " << setw(3) << Hit();
414 Int_t ntracks = Ntracks();
417 cout << " Tracks : " << setw(2) << ntracks;
418 for ( Int_t i = 0; i < ntracks; ++i )
420 cout << " Track(" << i << ")=" << setw(3) << Track(i)
421 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
426 cout << " no track info.";
432 //_____________________________________________________________________________
434 AliMUONDigit::Saturated(Bool_t value)
437 // Set the saturation status of this digit.
441 fFlags |= fgkSaturatedMask;
445 fFlags ^= fgkSaturatedMask;
449 //_____________________________________________________________________________
451 AliMUONDigit::SetElectronics(Int_t manuId, Int_t manuChannel)
454 //FIXME: should we check that the values are ok here ??
457 fManuChannel=manuChannel;
460 //_____________________________________________________________________________
462 AliMUONDigit::Track(Int_t i) const
465 // Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
467 if ( i >= 0 && i < fNtracks )
475 //_____________________________________________________________________________
477 AliMUONDigit::TrackCharge(Int_t i) const
480 // Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
482 if ( i >= 0 && i < fNtracks )