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 //-----------------------------------------------------------------------------
21 /// \class AliMUONDigit
22 /// A class representing a digit (with MC information if possible)
23 /// in the MUON spectrometer either in tracking or trigger chambers.
25 /// A digit holds the signal (proportional to a charge) on a pad
28 /// This class is used to represent either sdigits (purely simulated digit,
29 /// with no electronic noise whatsoever) or digits (simulated ones but
30 /// including electronic noise and de-calibration, to closely ressemble real ones).
31 //-----------------------------------------------------------------------------
34 ClassImp(AliMUONDigit)
37 //_____________________________________________________________________________
38 AliMUONDigit::AliMUONDigit()
56 /// Default constructor
59 //_____________________________________________________________________________
60 AliMUONDigit::AliMUONDigit(Int_t detElemId, Int_t manuId,
61 Int_t manuChannel, Int_t cathode)
63 AliMUONVDigit(detElemId,manuId,manuChannel,cathode),
64 fDetElemId(detElemId),
66 fManuChannel(manuChannel),
79 /// Normal constructor
83 //_____________________________________________________________________________
84 AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
103 (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
106 //_____________________________________________________________________________
107 AliMUONDigit::~AliMUONDigit()
115 //_____________________________________________________________________________
117 AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge)
119 /// Add 1 track information to the track list we keep.
120 /// The implementation below is dumb, you've been warned !
122 // First check if track is already there, in which
123 // case we simply increment its charge.
124 for ( Int_t i = 0; i < Ntracks(); ++i )
126 if ( Track(i) == trackNumber )
128 fTcharges[i] += trackCharge;
133 // Nope. It's a brand new track. Make a new array to get space
134 // for it, copy the old array into new one, and add the track.
135 Int_t* newTracks = new Int_t[fNtracks+1];
136 Float_t* newTcharges = new Float_t[fNtracks+1];
138 for ( Int_t i = 0; i < fNtracks; ++i )
140 newTracks[i] = fTracks[i];
141 newTcharges[i] = fTcharges[i];
144 newTracks[fNtracks] = trackNumber;
145 newTcharges[fNtracks] = trackCharge;
151 fTcharges = newTcharges;
156 //_____________________________________________________________________________
158 AliMUONDigit::Clear(Option_t*)
160 /// Reset this digit, in particular the internal arrays are deleted.
169 //_____________________________________________________________________________
170 Int_t AliMUONDigit::Compare(const TObject *obj) const
172 /// The order defined below is first by DE, then Signal, then
173 /// manuId, and then manuChannel, i.e. it should be a total ordering...
175 const AliMUONDigit* d = static_cast<const AliMUONDigit*>(obj);
177 if ( DetElemId() > d->DetElemId() )
181 else if ( DetElemId() < d->DetElemId() )
187 if ( Charge() > d->Charge() )
191 else if ( Charge() < d->Charge() )
197 if ( ManuId() < d->ManuId() )
201 else if ( ManuId() > d->ManuId() )
207 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
213 //______________________________________________________________________________
215 AliMUONDigit::Copy(TObject& obj) const
217 /// Copy this line to line.
220 AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
222 digit.fDetElemId = fDetElemId;
223 digit.fManuId = fManuId;
224 digit.fManuChannel = fManuChannel;
225 digit.fSignal = fSignal;
229 digit.fCathode = fCathode;
231 digit.fFlags = fFlags;
233 digit.fNtracks = fNtracks;
235 delete[] digit.fTcharges;
236 delete[] digit.fTracks;
240 digit.fTcharges = new Float_t[fNtracks];
241 digit.fTracks = new Int_t[fNtracks];
244 for ( Int_t i=0; i<fNtracks; ++i )
246 digit.fTcharges[i] = fTcharges[i];
247 digit.fTracks[i] = fTracks[i];
251 digit.fStatusMap = fStatusMap;
255 //_____________________________________________________________________________
257 AliMUONDigit::IsNoiseOnly() const
259 /// Whether this (simulated only) digit is only due to noise.
261 return (fFlags & fgkNoiseOnlyMask );
264 //_____________________________________________________________________________
266 AliMUONDigit::IsSaturated() const
268 /// Whether this digit is saturated or not.
270 return (fFlags & fgkSaturatedMask );
273 //_____________________________________________________________________________
275 AliMUONDigit::IsCalibrated() const
277 /// Whether this digit is calibrated or not
279 return (fFlags & fgkCalibratedMask );
283 //_____________________________________________________________________________
285 AliMUONDigit::IsUsed() const
287 /// Whether this digit is used or not (in a cluster, for instance)
289 return (fFlags & fgkUsedMask );
292 //_____________________________________________________________________________
294 AliMUONDigit::IsEfficiencyApplied() const
296 /// Whether this digit had efficiency applied or not
298 return (fFlags & fgkEfficiencyMask );
301 //_____________________________________________________________________________
303 AliMUONDigit::Used(Bool_t value)
305 /// Set the Used status of this digit.
309 fFlags |= fgkUsedMask;
313 fFlags ^= fgkUsedMask;
317 //_____________________________________________________________________________
319 AliMUONDigit::Calibrated(Bool_t value)
321 /// Set the Calibrated status of this digit.
325 fFlags |= fgkCalibratedMask;
329 fFlags ^= fgkCalibratedMask;
333 //_____________________________________________________________________________
335 AliMUONDigit::EfficiencyApplied(Bool_t value)
337 /// Set the EfficiencyApplied status of this digit.
341 fFlags |= fgkEfficiencyMask;
345 fFlags ^= fgkEfficiencyMask;
349 //_____________________________________________________________________________
351 AliMUONDigit::MergeWith(const AliMUONVDigit& src)
355 Bool_t check = ( src.DetElemId() == DetElemId() &&
356 src.PadX() == PadX() &&
357 src.PadY() == PadY() &&
358 src.Cathode() == Cathode() );
364 AddCharge(src.Charge());
365 for ( Int_t i = 0; i < src.Ntracks(); ++i )
367 AddTrack(src.Track(i),src.TrackCharge(i));
372 //_____________________________________________________________________________
374 AliMUONDigit::NoiseOnly(Bool_t value)
376 /// Set the NoiseOnly status of this digit.
380 fFlags |= fgkNoiseOnlyMask;
384 fFlags ^= fgkNoiseOnlyMask;
388 //_____________________________________________________________________________
390 AliMUONDigit::operator=(const AliMUONDigit& digit)
392 /// Assignement operator.
394 AliMUONDigit a(digit);
399 //_____________________________________________________________________________
401 AliMUONDigit::PatchTracks(Int_t mask)
403 /// Add mask to each track number.
405 for ( Int_t i = 0; i < Ntracks(); ++i )
411 //_____________________________________________________________________________
413 AliMUONDigit::Saturated(Bool_t value)
415 /// Set the saturation status of this digit.
419 fFlags |= fgkSaturatedMask;
423 fFlags ^= fgkSaturatedMask;
427 //_____________________________________________________________________________
429 AliMUONDigit::Track(Int_t i) const
431 /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
433 if ( i >= 0 && i < fNtracks )
441 //_____________________________________________________________________________
443 AliMUONDigit::TrackCharge(Int_t i) const
445 /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
447 if ( i >= 0 && i < fNtracks )
455 //_____________________________________________________________________________
457 AliMUONDigit::GetUniqueID() const
459 /// Return a single integer with id information
461 return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode());