]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDigit.cxx
Adding comment
[u/mrichter/AliRoot.git] / MUON / AliMUONDigit.cxx
CommitLineData
a9e2aefa 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
88cb7938 16/* $Id$ */
a9e2aefa 17
18#include "AliMUONDigit.h"
19
81b31073 20#include "Riostream.h"
21#include "TString.h"
8c343c7c 22
5398f946 23/// \class AliMUONDigit
b1d79ad7 24/// A class representing a digit in the MUON spectrometer
25/// either in tracking or trigger chambers.
26///
27/// A digit holds the signal (proportional to a charge) on a pad
28/// (or strip).
29///
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).
81b31073 34
5398f946 35/// \cond CLASSIMP
b1d79ad7 36ClassImp(AliMUONDigit)
5398f946 37/// \endcond
5350e3a6 38
61adb9bd 39//_____________________________________________________________________________
81b31073 40AliMUONDigit::AliMUONDigit()
5350e3a6 41:
42TObject(),
43fDetElemId(-1),
81b31073 44fManuId(-1),
45fManuChannel(-1),
8a92eee6 46fSignal(0.0),
5350e3a6 47fPadX(-1),
48fPadY(-1),
49fCathode(-1),
81b31073 50fADC(0),
5350e3a6 51fFlags(0),
52fNtracks(0),
53fTcharges(0x0),
54fTracks(0x0),
8a92eee6 55fPhysics(0.0),
aaf7adc0 56fHit(0),
57fStatusMap(0)
61adb9bd 58{
5398f946 59 /// Default constructor
81b31073 60}
61adb9bd 61
81b31073 62//_____________________________________________________________________________
63AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit)
5350e3a6 64: TObject(digit),
65fDetElemId(-1),
66fManuId(-1),
67fManuChannel(-1),
8a92eee6 68fSignal(0.0),
5350e3a6 69fPadX(-1),
70fPadY(-1),
71fCathode(-1),
72fADC(0),
73fFlags(0),
74fNtracks(0),
75fTcharges(0x0),
76fTracks(0x0),
8a92eee6 77fPhysics(0.0),
aaf7adc0 78fHit(0),
79fStatusMap(0)
81b31073 80{
5398f946 81 /// Copy constructor
82
81b31073 83 (static_cast<const AliMUONDigit&>(digit)).Copy(*this);
61adb9bd 84}
85
5350e3a6 86//_____________________________________________________________________________
87AliMUONDigit::~AliMUONDigit()
88{
5398f946 89 /// Destructor
90
5350e3a6 91 delete[] fTcharges;
92 delete[] fTracks;
93}
94
95//_____________________________________________________________________________
96void
8a92eee6 97AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge)
5350e3a6 98{
5398f946 99 /// Add 1 track information to the track list we keep.
100 /// The implementation below is dumb, you've been warned !
5350e3a6 101
102 // First check if track is already there, in which
103 // case we simply increment its charge.
104 for ( Int_t i = 0; i < Ntracks(); ++i )
105 {
106 if ( Track(i) == trackNumber )
107 {
108 fTcharges[i] += trackCharge;
109 return;
110 }
111 }
112
113 // Nope. It's a brand new track. Make a new array to get space
114 // for it, copy the old array into new one, and add the track.
115 Int_t* newTracks = new Int_t[fNtracks+1];
8a92eee6 116 Float_t* newTcharges = new Float_t[fNtracks+1];
5350e3a6 117
118 for ( Int_t i = 0; i < fNtracks; ++i )
119 {
120 newTracks[i] = fTracks[i];
121 newTcharges[i] = fTcharges[i];
122 }
123
124 newTracks[fNtracks] = trackNumber;
125 newTcharges[fNtracks] = trackCharge;
126
127 delete[] fTracks;
128 delete[] fTcharges;
129
130 fTracks = newTracks;
131 fTcharges = newTcharges;
132
133 ++fNtracks;
134}
135
136//_____________________________________________________________________________
137void
138AliMUONDigit::Clear(Option_t*)
139{
5398f946 140 /// Reset this digit, in particular the internal arrays are deleted.
141
5350e3a6 142 delete[] fTracks;
143 delete[] fTcharges;
144 fTracks=0x0;
145 fTcharges=0x0;
146 fNtracks=0;
a9e2aefa 147}
148
81b31073 149//_____________________________________________________________________________
150Int_t AliMUONDigit::Compare(const TObject *obj) const
a9e2aefa 151{
5398f946 152 /// The order defined below is first by DE, then Signal, then
153 /// manuId, and then manuChannel, i.e. it should be a total ordering...
81b31073 154
5350e3a6 155 const AliMUONDigit* d = static_cast<const AliMUONDigit*>(obj);
156
157 if ( DetElemId() > d->DetElemId() )
158 {
159 return 1;
160 }
161 else if ( DetElemId() < d->DetElemId() )
162 {
163 return -1;
164 }
165 else
166 {
167 if ( Signal() > d->Signal() )
168 {
169 return 1;
170 }
171 else if ( Signal() < d->Signal() )
172 {
173 return -1;
174 }
175 else
176 {
177 if ( ManuId() < d->ManuId() )
178 {
179 return 1;
180 }
181 else if ( ManuId() > d->ManuId() )
182 {
183 return -1;
184 }
185 else
186 {
187 return ( ManuChannel() < d->ManuChannel() ) ? 1 : -1;
188 }
189 }
190 }
191}
192
193//______________________________________________________________________________
194void
195AliMUONDigit::Copy(TObject& obj) const
196{
5398f946 197 /// Copy this line to line.
198
5350e3a6 199 TObject::Copy(obj);
200 AliMUONDigit& digit = static_cast<AliMUONDigit&>(obj);
201
202 digit.fDetElemId = fDetElemId;
203 digit.fManuId = fManuId;
204 digit.fManuChannel = fManuChannel;
205 digit.fSignal = fSignal;
206
207 digit.fPadX = fPadX;
208 digit.fPadY = fPadY;
209 digit.fCathode = fCathode;
210 digit.fADC = fADC;
211 digit.fFlags = fFlags;
212
213 digit.fNtracks = fNtracks;
214
215 delete[] digit.fTcharges;
216 delete[] digit.fTracks;
217
218 if ( fNtracks )
219 {
8a92eee6 220 digit.fTcharges = new Float_t[fNtracks];
5350e3a6 221 digit.fTracks = new Int_t[fNtracks];
222 }
223
224 for ( Int_t i=0; i<fNtracks; ++i )
225 {
226 digit.fTcharges[i] = fTcharges[i];
227 digit.fTracks[i] = fTracks[i];
228 }
229
230 digit.fPhysics = fPhysics;
231 digit.fHit = fHit;
aaf7adc0 232 digit.fStatusMap = fStatusMap;
5350e3a6 233}
81b31073 234
b1d79ad7 235//_____________________________________________________________________________
236Bool_t
237AliMUONDigit::IsNoiseOnly() const
238{
5398f946 239 /// Whether this (simulated only) digit is only due to noise.
240
b1d79ad7 241 return (fFlags & fgkNoiseOnlyMask );
242}
243
5350e3a6 244//_____________________________________________________________________________
245Bool_t
246AliMUONDigit::IsSaturated() const
247{
5398f946 248 /// Whether this digit is saturated or not.
249
b1d79ad7 250 return (fFlags & fgkSaturatedMask );
251}
252
253//_____________________________________________________________________________
1d4e6965 254Bool_t
255AliMUONDigit::IsEfficiencyApplied() const
256{
257 /// Whether this digit had efficiency applied or not
258
259 return (fFlags & fgkEfficiencyMask );
260}
261
262//_____________________________________________________________________________
263void
264AliMUONDigit::EfficiencyApplied(Bool_t value)
265{
266 /// Set the EfficiencyApplied status of this digit.
267
268 if ( value )
269 {
270 fFlags |= fgkEfficiencyMask;
271 }
272 else
273 {
274 fFlags ^= fgkEfficiencyMask;
275 }
276}
277
278//_____________________________________________________________________________
b1d79ad7 279void
280AliMUONDigit::NoiseOnly(Bool_t value)
281{
5398f946 282 /// Set the NoiseOnly status of this digit.
283
b1d79ad7 284 if ( value )
285 {
286 fFlags |= fgkNoiseOnlyMask;
287 }
288 else
289 {
290 fFlags ^= fgkNoiseOnlyMask;
291 }
5350e3a6 292}
81b31073 293
5350e3a6 294//_____________________________________________________________________________
295AliMUONDigit&
296AliMUONDigit::operator=(const AliMUONDigit& digit)
297{
5398f946 298 /// Assignement operator.
299
5350e3a6 300 AliMUONDigit a(digit);
301 a.Copy(*this);
302 return *this;
303}
304
305//_____________________________________________________________________________
306void
307AliMUONDigit::PatchTracks(Int_t mask)
308{
5398f946 309 /// Add mask to each track number.
310
5350e3a6 311 for ( Int_t i = 0; i < Ntracks(); ++i )
312 {
313 fTracks[i] += mask;
314 }
a9e2aefa 315}
61adb9bd 316
317//_____________________________________________________________________________
81b31073 318void
319AliMUONDigit::Print(Option_t* opt) const
61adb9bd 320{
5398f946 321 /// Dump to screen.
322 /// If opt=="tracks", info on tracks are printed too.
323
8a92eee6 324 cout << Form("<AliMUONDigit>: DE %4d Cath %d (Ix,Iy)=(%3d,%3d) (Manu,Channel)=(%4d,%2d)"
325 ", Signal=%7.2f Physics=%7.2f",
326 DetElemId(),Cathode(),PadX(),PadY(),ManuId(),ManuChannel(),Signal(),
327 Physics());
328
5350e3a6 329 if ( IsSaturated() )
81b31073 330 {
331 cout << "(S)";
332 }
333 else
334 {
335 cout << " ";
336 }
337 cout << " ADC=" << setw(4) << ADC();
b1d79ad7 338 cout << " Flags=0x" << setw(4) << hex << setfill('0') << fFlags << dec
339 << setfill(' ');
aaf7adc0 340 cout << " StatusMap=0x" << setw(4) << hex << setfill('0') << StatusMap() << dec
341 << setfill(' ');
342
81b31073 343 TString options(opt);
344 options.ToLower();
345 if ( options.Contains("tracks") )
346 {
5350e3a6 347 cout << " Hit " << setw(3) << Hit();
348 Int_t ntracks = Ntracks();
349 if (ntracks)
350 {
351 cout << " Tracks : " << setw(2) << ntracks;
352 for ( Int_t i = 0; i < ntracks; ++i )
353 {
354 cout << " Track(" << i << ")=" << setw(3) << Track(i)
355 << " Charge(" << i << ")=" << setw(5) << TrackCharge(i);
356 }
357 }
358 else
359 {
360 cout << " no track info.";
361 }
81b31073 362 }
363 cout << endl;
364}
61adb9bd 365
81b31073 366//_____________________________________________________________________________
367void
5350e3a6 368AliMUONDigit::Saturated(Bool_t value)
81b31073 369{
5398f946 370 /// Set the saturation status of this digit.
371
5350e3a6 372 if ( value )
373 {
b1d79ad7 374 fFlags |= fgkSaturatedMask;
5350e3a6 375 }
376 else
377 {
b1d79ad7 378 fFlags ^= fgkSaturatedMask;
5350e3a6 379 }
81b31073 380}
a713db22 381
81b31073 382//_____________________________________________________________________________
383void
384AliMUONDigit::SetElectronics(Int_t manuId, Int_t manuChannel)
385{
386 //
387 //FIXME: should we check that the values are ok here ??
388 //
389 fManuId=manuId;
390 fManuChannel=manuChannel;
a713db22 391}
81b31073 392
393//_____________________________________________________________________________
5350e3a6 394Int_t
395AliMUONDigit::Track(Int_t i) const
81b31073 396{
5398f946 397 /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1.
398
5350e3a6 399 if ( i >= 0 && i < fNtracks )
400 {
401 return fTracks[i];
402 }
403
404 return -1;
81b31073 405}
406
5350e3a6 407//_____________________________________________________________________________
8a92eee6 408Float_t
5350e3a6 409AliMUONDigit::TrackCharge(Int_t i) const
410{
5398f946 411 /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1.
412
5350e3a6 413 if ( i >= 0 && i < fNtracks )
414 {
415 return fTcharges[i];
416 }
81b31073 417
5350e3a6 418 return -1;
419}