]>
Commit | Line | Data |
---|---|---|
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 | 36 | ClassImp(AliMUONDigit) |
5398f946 | 37 | /// \endcond |
5350e3a6 | 38 | |
61adb9bd | 39 | //_____________________________________________________________________________ |
81b31073 | 40 | AliMUONDigit::AliMUONDigit() |
5350e3a6 | 41 | : |
42 | TObject(), | |
43 | fDetElemId(-1), | |
81b31073 | 44 | fManuId(-1), |
45 | fManuChannel(-1), | |
8a92eee6 | 46 | fSignal(0.0), |
5350e3a6 | 47 | fPadX(-1), |
48 | fPadY(-1), | |
49 | fCathode(-1), | |
81b31073 | 50 | fADC(0), |
5350e3a6 | 51 | fFlags(0), |
52 | fNtracks(0), | |
53 | fTcharges(0x0), | |
54 | fTracks(0x0), | |
8a92eee6 | 55 | fPhysics(0.0), |
aaf7adc0 | 56 | fHit(0), |
57 | fStatusMap(0) | |
61adb9bd | 58 | { |
5398f946 | 59 | /// Default constructor |
81b31073 | 60 | } |
61adb9bd | 61 | |
81b31073 | 62 | //_____________________________________________________________________________ |
63 | AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit) | |
5350e3a6 | 64 | : TObject(digit), |
65 | fDetElemId(-1), | |
66 | fManuId(-1), | |
67 | fManuChannel(-1), | |
8a92eee6 | 68 | fSignal(0.0), |
5350e3a6 | 69 | fPadX(-1), |
70 | fPadY(-1), | |
71 | fCathode(-1), | |
72 | fADC(0), | |
73 | fFlags(0), | |
74 | fNtracks(0), | |
75 | fTcharges(0x0), | |
76 | fTracks(0x0), | |
8a92eee6 | 77 | fPhysics(0.0), |
aaf7adc0 | 78 | fHit(0), |
79 | fStatusMap(0) | |
81b31073 | 80 | { |
5398f946 | 81 | /// Copy constructor |
82 | ||
81b31073 | 83 | (static_cast<const AliMUONDigit&>(digit)).Copy(*this); |
61adb9bd | 84 | } |
85 | ||
5350e3a6 | 86 | //_____________________________________________________________________________ |
87 | AliMUONDigit::~AliMUONDigit() | |
88 | { | |
5398f946 | 89 | /// Destructor |
90 | ||
5350e3a6 | 91 | delete[] fTcharges; |
92 | delete[] fTracks; | |
93 | } | |
94 | ||
95 | //_____________________________________________________________________________ | |
96 | void | |
8a92eee6 | 97 | AliMUONDigit::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 | //_____________________________________________________________________________ | |
137 | void | |
138 | AliMUONDigit::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 | //_____________________________________________________________________________ |
150 | Int_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 | //______________________________________________________________________________ | |
194 | void | |
195 | AliMUONDigit::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 | //_____________________________________________________________________________ |
236 | Bool_t | |
237 | AliMUONDigit::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 | //_____________________________________________________________________________ |
245 | Bool_t | |
246 | AliMUONDigit::IsSaturated() const | |
247 | { | |
5398f946 | 248 | /// Whether this digit is saturated or not. |
249 | ||
b1d79ad7 | 250 | return (fFlags & fgkSaturatedMask ); |
251 | } | |
252 | ||
253 | //_____________________________________________________________________________ | |
254 | void | |
255 | AliMUONDigit::NoiseOnly(Bool_t value) | |
256 | { | |
5398f946 | 257 | /// Set the NoiseOnly status of this digit. |
258 | ||
b1d79ad7 | 259 | if ( value ) |
260 | { | |
261 | fFlags |= fgkNoiseOnlyMask; | |
262 | } | |
263 | else | |
264 | { | |
265 | fFlags ^= fgkNoiseOnlyMask; | |
266 | } | |
5350e3a6 | 267 | } |
81b31073 | 268 | |
5350e3a6 | 269 | //_____________________________________________________________________________ |
270 | AliMUONDigit& | |
271 | AliMUONDigit::operator=(const AliMUONDigit& digit) | |
272 | { | |
5398f946 | 273 | /// Assignement operator. |
274 | ||
5350e3a6 | 275 | AliMUONDigit a(digit); |
276 | a.Copy(*this); | |
277 | return *this; | |
278 | } | |
279 | ||
280 | //_____________________________________________________________________________ | |
281 | void | |
282 | AliMUONDigit::PatchTracks(Int_t mask) | |
283 | { | |
5398f946 | 284 | /// Add mask to each track number. |
285 | ||
5350e3a6 | 286 | for ( Int_t i = 0; i < Ntracks(); ++i ) |
287 | { | |
288 | fTracks[i] += mask; | |
289 | } | |
a9e2aefa | 290 | } |
61adb9bd | 291 | |
292 | //_____________________________________________________________________________ | |
81b31073 | 293 | void |
294 | AliMUONDigit::Print(Option_t* opt) const | |
61adb9bd | 295 | { |
5398f946 | 296 | /// Dump to screen. |
297 | /// If opt=="tracks", info on tracks are printed too. | |
298 | ||
8a92eee6 | 299 | cout << Form("<AliMUONDigit>: DE %4d Cath %d (Ix,Iy)=(%3d,%3d) (Manu,Channel)=(%4d,%2d)" |
300 | ", Signal=%7.2f Physics=%7.2f", | |
301 | DetElemId(),Cathode(),PadX(),PadY(),ManuId(),ManuChannel(),Signal(), | |
302 | Physics()); | |
303 | ||
5350e3a6 | 304 | if ( IsSaturated() ) |
81b31073 | 305 | { |
306 | cout << "(S)"; | |
307 | } | |
308 | else | |
309 | { | |
310 | cout << " "; | |
311 | } | |
312 | cout << " ADC=" << setw(4) << ADC(); | |
b1d79ad7 | 313 | cout << " Flags=0x" << setw(4) << hex << setfill('0') << fFlags << dec |
314 | << setfill(' '); | |
aaf7adc0 | 315 | cout << " StatusMap=0x" << setw(4) << hex << setfill('0') << StatusMap() << dec |
316 | << setfill(' '); | |
317 | ||
81b31073 | 318 | TString options(opt); |
319 | options.ToLower(); | |
320 | if ( options.Contains("tracks") ) | |
321 | { | |
5350e3a6 | 322 | cout << " Hit " << setw(3) << Hit(); |
323 | Int_t ntracks = Ntracks(); | |
324 | if (ntracks) | |
325 | { | |
326 | cout << " Tracks : " << setw(2) << ntracks; | |
327 | for ( Int_t i = 0; i < ntracks; ++i ) | |
328 | { | |
329 | cout << " Track(" << i << ")=" << setw(3) << Track(i) | |
330 | << " Charge(" << i << ")=" << setw(5) << TrackCharge(i); | |
331 | } | |
332 | } | |
333 | else | |
334 | { | |
335 | cout << " no track info."; | |
336 | } | |
81b31073 | 337 | } |
338 | cout << endl; | |
339 | } | |
61adb9bd | 340 | |
81b31073 | 341 | //_____________________________________________________________________________ |
342 | void | |
5350e3a6 | 343 | AliMUONDigit::Saturated(Bool_t value) |
81b31073 | 344 | { |
5398f946 | 345 | /// Set the saturation status of this digit. |
346 | ||
5350e3a6 | 347 | if ( value ) |
348 | { | |
b1d79ad7 | 349 | fFlags |= fgkSaturatedMask; |
5350e3a6 | 350 | } |
351 | else | |
352 | { | |
b1d79ad7 | 353 | fFlags ^= fgkSaturatedMask; |
5350e3a6 | 354 | } |
81b31073 | 355 | } |
a713db22 | 356 | |
81b31073 | 357 | //_____________________________________________________________________________ |
358 | void | |
359 | AliMUONDigit::SetElectronics(Int_t manuId, Int_t manuChannel) | |
360 | { | |
361 | // | |
362 | //FIXME: should we check that the values are ok here ?? | |
363 | // | |
364 | fManuId=manuId; | |
365 | fManuChannel=manuChannel; | |
a713db22 | 366 | } |
81b31073 | 367 | |
368 | //_____________________________________________________________________________ | |
5350e3a6 | 369 | Int_t |
370 | AliMUONDigit::Track(Int_t i) const | |
81b31073 | 371 | { |
5398f946 | 372 | /// Return the i-th track number (if i is >=0 and < Ntracks()) or -1. |
373 | ||
5350e3a6 | 374 | if ( i >= 0 && i < fNtracks ) |
375 | { | |
376 | return fTracks[i]; | |
377 | } | |
378 | ||
379 | return -1; | |
81b31073 | 380 | } |
381 | ||
5350e3a6 | 382 | //_____________________________________________________________________________ |
8a92eee6 | 383 | Float_t |
5350e3a6 | 384 | AliMUONDigit::TrackCharge(Int_t i) const |
385 | { | |
5398f946 | 386 | /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1. |
387 | ||
5350e3a6 | 388 | if ( i >= 0 && i < fNtracks ) |
389 | { | |
390 | return fTcharges[i]; | |
391 | } | |
81b31073 | 392 | |
5350e3a6 | 393 | return -1; |
394 | } |