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