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 /// \class AliMUONDigit
21 /// A class representing a digit (with MC information if possible)
22 /// in the MUON spectrometer either in tracking or trigger chambers.
24 /// A digit holds the signal (proportional to a charge) on a pad
27 /// This class is used to represent either sdigits (purely simulated digit,
28 /// with no electronic noise whatsoever) or digits (simulated ones but
29 /// including electronic noise and de-calibration, to closely ressemble real ones).
32 ClassImp(AliMUONDigit)
35 //_____________________________________________________________________________
36 AliMUONDigit::AliMUONDigit()
54 /// Default constructor
57 //_____________________________________________________________________________
58 AliMUONDigit::AliMUONDigit(Int_t detElemId, Int_t manuId,
59 Int_t manuChannel, Int_t cathode)
61 AliMUONVDigit(detElemId,manuId,manuChannel,cathode),
62 fDetElemId(detElemId),
64 fManuChannel(manuChannel),
77 /// Normal constructor
81 //_____________________________________________________________________________
82 AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
101 (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
104 //_____________________________________________________________________________
105 AliMUONDigit::~AliMUONDigit()
113 //_____________________________________________________________________________
115 AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge)
117 /// Add 1 track information to the track list we keep.
118 /// The implementation below is dumb, you've been warned !
120 // First check if track is already there, in which
121 // case we simply increment its charge.
122 for ( Int_t i = 0; i < Ntracks(); ++i )
124 if ( Track(i) == trackNumber )
126 fTcharges[i] += trackCharge;
131 // Nope. It's a brand new track. Make a new array to get space
132 // for it, copy the old array into new one, and add the track.
133 Int_t* newTracks = new Int_t[fNtracks+1];
134 Float_t* newTcharges = new Float_t[fNtracks+1];
136 for ( Int_t i = 0; i < fNtracks; ++i )
138 newTracks[i] = fTracks[i];
139 newTcharges[i] = fTcharges[i];
142 newTracks[fNtracks] = trackNumber;
143 newTcharges[fNtracks] = trackCharge;
149 fTcharges = newTcharges;
154 //_____________________________________________________________________________
156 AliMUONDigit::Clear(Option_t*)
158 /// Reset this digit, in particular the internal arrays are deleted.
167 //_____________________________________________________________________________
168 Int_t AliMUONDigit::Compare(const TObject *obj) const
170 /// The order defined below is first by DE, then Signal, then
171 /// manuId, and then manuChannel, i.e. it should be a total ordering...
173 const AliMUONDigit* d = static_cast<const AliMUONDigit*>(obj);
175 if ( DetElemId() > d->DetElemId() )
179 else if ( DetElemId() < d->DetElemId() )
185 if ( Charge() > d->Charge() )
189 else if ( Charge() < d->Charge() )
195 if ( ManuId() < d->ManuId() )
199 else if ( ManuId() > d->ManuId() )
205 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
211 //______________________________________________________________________________
213 AliMUONDigit::Copy(TObject& obj) const
215 /// Copy this line to line.
218 AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
220 digit.fDetElemId = fDetElemId;
221 digit.fManuId = fManuId;
222 digit.fManuChannel = fManuChannel;
223 digit.fSignal = fSignal;
227 digit.fCathode = fCathode;
229 digit.fFlags = fFlags;
231 digit.fNtracks = fNtracks;
233 delete[] digit.fTcharges;
234 delete[] digit.fTracks;
238 digit.fTcharges = new Float_t[fNtracks];
239 digit.fTracks = new Int_t[fNtracks];
242 for ( Int_t i=0; i<fNtracks; ++i )
244 digit.fTcharges[i] = fTcharges[i];
245 digit.fTracks[i] = fTracks[i];
249 digit.fStatusMap = fStatusMap;
253 //_____________________________________________________________________________
255 AliMUONDigit::IsNoiseOnly() const
257 /// Whether this (simulated only) digit is only due to noise.
259 return (fFlags & fgkNoiseOnlyMask );
262 //_____________________________________________________________________________
264 AliMUONDigit::IsSaturated() const
266 /// Whether this digit is saturated or not.
268 return (fFlags & fgkSaturatedMask );
271 //_____________________________________________________________________________
273 AliMUONDigit::IsCalibrated() const
275 /// Whether this digit is calibrated or not
277 return (fFlags & fgkCalibratedMask );
281 //_____________________________________________________________________________
283 AliMUONDigit::IsUsed() const
285 /// Whether this digit is used or not (in a cluster, for instance)
287 return (fFlags & fgkUsedMask );
290 //_____________________________________________________________________________
292 AliMUONDigit::IsEfficiencyApplied() const
294 /// Whether this digit had efficiency applied or not
296 return (fFlags & fgkEfficiencyMask );
299 //_____________________________________________________________________________
301 AliMUONDigit::Used(Bool_t value)
303 /// Set the Used status of this digit.
307 fFlags |= fgkUsedMask;
311 fFlags ^= fgkUsedMask;
315 //_____________________________________________________________________________
317 AliMUONDigit::Calibrated(Bool_t value)
319 /// Set the Calibrated status of this digit.
323 fFlags |= fgkCalibratedMask;
327 fFlags ^= fgkCalibratedMask;
331 //_____________________________________________________________________________
333 AliMUONDigit::EfficiencyApplied(Bool_t value)
335 /// Set the EfficiencyApplied status of this digit.
339 fFlags |= fgkEfficiencyMask;
343 fFlags ^= fgkEfficiencyMask;
347 //_____________________________________________________________________________
349 AliMUONDigit::MergeWith(const AliMUONVDigit& src)
353 Bool_t check = ( src.DetElemId() == DetElemId() &&
354 src.PadX() == PadX() &&
355 src.PadY() == PadY() &&
356 src.Cathode() == Cathode() );
362 AddCharge(src.Charge());
363 for ( Int_t i = 0; i < src.Ntracks(); ++i )
365 AddTrack(src.Track(i),src.TrackCharge(i));
370 //_____________________________________________________________________________
372 AliMUONDigit::NoiseOnly(Bool_t value)
374 /// Set the NoiseOnly status of this digit.
378 fFlags |= fgkNoiseOnlyMask;
382 fFlags ^= fgkNoiseOnlyMask;
386 //_____________________________________________________________________________
388 AliMUONDigit::operator=(const AliMUONDigit& digit)
390 /// Assignement operator.
392 AliMUONDigit a(digit);
397 //_____________________________________________________________________________
399 AliMUONDigit::PatchTracks(Int_t mask)
401 /// Add mask to each track number.
403 for ( Int_t i = 0; i < Ntracks(); ++i )
409 //_____________________________________________________________________________
411 AliMUONDigit::Saturated(Bool_t value)
413 /// Set the saturation status of this digit.
417 fFlags |= fgkSaturatedMask;
421 fFlags ^= fgkSaturatedMask;
425 //_____________________________________________________________________________
427 AliMUONDigit::Track(Int_t i) const
429 /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
431 if ( i >= 0 && i < fNtracks )
439 //_____________________________________________________________________________
441 AliMUONDigit::TrackCharge(Int_t i) const
443 /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
445 if ( i >= 0 && i < fNtracks )
453 //_____________________________________________________________________________
455 AliMUONDigit::GetUniqueID() const
457 /// Return a single integer with id information
459 return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode());