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 ClassImp(AliMUONDigit)
27 const UInt_t SATURATEDFLAG = 0x1;
30 //_____________________________________________________________________________
31 AliMUONDigit::AliMUONDigit()
50 // Default constructor
54 //_____________________________________________________________________________
55 AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
75 (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
79 //_____________________________________________________________________________
80 AliMUONDigit::AliMUONDigit(Int_t *digits)
99 // Creates a MUON digit object to be updated
104 fCathode = digits[2];
106 fPhysics = digits[4];
108 fDetElemId = digits[6];
115 //_____________________________________________________________________________
116 AliMUONDigit::AliMUONDigit(Int_t *tracks, Int_t *charges, Int_t *digits)
134 // Creates a MUON digit object
139 fCathode = digits[2];
141 fPhysics = digits[4];
143 fDetElemId = digits[6];
148 // For backward compatibility, which assumed 10 tracks.
150 fTcharges = new Int_t[fNtracks];
151 fTracks = new Int_t[fNtracks];
153 for ( Int_t i=0; i<fNtracks; ++i )
155 fTcharges[i] = charges[i];
156 fTracks[i] = tracks[i];
161 //_____________________________________________________________________________
162 AliMUONDigit::~AliMUONDigit()
171 //_____________________________________________________________________________
173 AliMUONDigit::AddTrack(Int_t trackNumber, Int_t trackCharge)
176 // Add 1 track information to the track list we keep.
177 // The implementation below is dumb, you've been warned !
180 // First check if track is already there, in which
181 // case we simply increment its charge.
182 for ( Int_t i = 0; i < Ntracks(); ++i )
184 if ( Track(i) == trackNumber )
186 fTcharges[i] += trackCharge;
191 // Nope. It's a brand new track. Make a new array to get space
192 // for it, copy the old array into new one, and add the track.
193 Int_t* newTracks = new Int_t[fNtracks+1];
194 Int_t* newTcharges = new Int_t[fNtracks+1];
196 for ( Int_t i = 0; i < fNtracks; ++i )
198 newTracks[i] = fTracks[i];
199 newTcharges[i] = fTcharges[i];
202 newTracks[fNtracks] = trackNumber;
203 newTcharges[fNtracks] = trackCharge;
209 fTcharges = newTcharges;
214 //_____________________________________________________________________________
216 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
232 // The order defined below is first by DE, then Signal, then
233 // manuId, and then manuChannel, i.e. it should be a total ordering...
236 const AliMUONDigit* d = static_cast<const AliMUONDigit*>(obj);
238 if ( DetElemId() > d->DetElemId() )
242 else if ( DetElemId() < d->DetElemId() )
248 if ( Signal() > d->Signal() )
252 else if ( Signal() < d->Signal() )
258 if ( ManuId() < d->ManuId() )
262 else if ( ManuId() > d->ManuId() )
268 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
274 //______________________________________________________________________________
276 AliMUONDigit::Copy(TObject& obj) const
279 // Copy this line to line.
282 AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
284 digit.fDetElemId = fDetElemId;
285 digit.fManuId = fManuId;
286 digit.fManuChannel = fManuChannel;
287 digit.fSignal = fSignal;
291 digit.fCathode = fCathode;
293 digit.fFlags = fFlags;
295 digit.fNtracks = fNtracks;
297 delete[] digit.fTcharges;
298 delete[] digit.fTracks;
302 digit.fTcharges = new Int_t[fNtracks];
303 digit.fTracks = new Int_t[fNtracks];
306 for ( Int_t i=0; i<fNtracks; ++i )
308 digit.fTcharges[i] = fTcharges[i];
309 digit.fTracks[i] = fTracks[i];
312 digit.fPhysics = fPhysics;
316 //_____________________________________________________________________________
318 AliMUONDigit::IsSaturated() const
320 return (fFlags & SATURATEDFLAG );
323 //_____________________________________________________________________________
325 AliMUONDigit::operator=(const AliMUONDigit& digit)
328 // Assignement operator.
330 AliMUONDigit a(digit);
335 //_____________________________________________________________________________
337 AliMUONDigit::PatchTracks(Int_t mask)
340 // Add mask to each track number.
342 for ( Int_t i = 0; i < Ntracks(); ++i )
348 //_____________________________________________________________________________
350 AliMUONDigit::Print(Option_t* opt) const
354 // If opt=="tracks", info on tracks are printed too.
356 cout << "DetEle " << setw(5) << DetElemId()
357 << " Cath " << setw(2) << Cathode()
358 << " (Ix,Iy)=(" << setw(3) << PadX() << "," << setw(3) << PadY()
360 << " (Manu,Channel)=(" << setw(4) << ManuId()
361 << "," << setw(3) << ManuChannel() << ")"
362 << " Signal=" << setw(6) << Signal()
363 << " Physics=" << setw(4) << Physics();
372 cout << " ADC=" << setw(4) << ADC();
373 TString options(opt);
375 if ( options.Contains("tracks") )
377 cout << " Hit " << setw(3) << Hit();
378 Int_t ntracks = Ntracks();
381 cout << " Tracks : " << setw(2) << ntracks;
382 for ( Int_t i = 0; i < ntracks; ++i )
384 cout << " Track(" << i << ")=" << setw(3) << Track(i)
385 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
390 cout << " no track info.";
396 //_____________________________________________________________________________
398 AliMUONDigit::Saturated(Bool_t value)
402 fFlags |= SATURATEDFLAG;
406 fFlags ^= SATURATEDFLAG;
410 //_____________________________________________________________________________
412 AliMUONDigit::SetElectronics(Int_t manuId, Int_t manuChannel)
415 //FIXME: should we check that the values are ok here ??
418 fManuChannel=manuChannel;
421 //_____________________________________________________________________________
423 AliMUONDigit::Track(Int_t i) const
426 // Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
428 if ( i >= 0 && i < fNtracks )
436 //_____________________________________________________________________________
438 AliMUONDigit::TrackCharge(Int_t i) const
441 // Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
443 if ( i >= 0 && i < fNtracks )