]>
Commit | Line | Data |
---|---|---|
61e0abb5 | 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 | ||
090026bf | 16 | /* $Id$ */ |
61e0abb5 | 17 | |
18 | //_________________________________________________________________________ | |
ffa6d63b | 19 | // EMCAL digit: |
20 | // A Digit is the sum of the energy lost in an EMCAL Tower | |
21 | // It also stores information on Primary, and enterring particle | |
22 | // tracknumbers Digits are created using AliEMCALSDigitizer, followed | |
23 | // by AliEMCALDigitizer | |
61e0abb5 | 24 | // |
ffa6d63b | 25 | //*-- Author: Sahal Yacoob (LBL) |
26 | // based on : AliPHOSDigit | |
814ad4bf | 27 | //__________________________________________________________________________ |
61e0abb5 | 28 | |
29 | // --- ROOT system --- | |
090026bf | 30 | #include <Riostream.h> |
31 | #include <TMath.h> | |
61e0abb5 | 32 | |
33 | // --- Standard library --- | |
34 | ||
61e0abb5 | 35 | // --- AliRoot header files --- |
36 | ||
37 | #include "AliEMCALDigit.h" | |
814ad4bf | 38 | #include "AliEMCALGeometry.h" |
a520bcd0 | 39 | #include "AliLog.h" |
61e0abb5 | 40 | |
0267cfa6 | 41 | using std::cout; |
42 | using std::endl; | |
61e0abb5 | 43 | ClassImp(AliEMCALDigit) |
44 | ||
45 | //____________________________________________________________________________ | |
514da33c | 46 | AliEMCALDigit::AliEMCALDigit() : |
829ba234 | 47 | AliDigitNew(), |
48 | fAmpFloat(0.), | |
49 | fNSamples(0), | |
50 | fSamples(0x0), | |
51 | fNSamplesHG(0), | |
52 | fSamplesHG(0x0), | |
514da33c | 53 | fNprimary(0), |
54 | fNMaxPrimary(5), | |
55 | fPrimary(0x0), | |
af5bdd85 | 56 | fDEPrimary(0x0), |
514da33c | 57 | fNiparent(0), |
58 | fNMaxiparent(5), | |
59 | fIparent(0x0), | |
af5bdd85 | 60 | fDEParent(0x0), |
514da33c | 61 | fMaxIter(0), |
62 | fTime(0.), | |
829ba234 | 63 | fTimeR(0.), |
64 | fChi2(0.), | |
65 | fNDF(0), | |
8a84b948 | 66 | fDigitType(kUnknown), |
67 | fAmpCalib(-1) | |
61e0abb5 | 68 | { |
69 | // default ctor | |
70 | ||
af5bdd85 | 71 | // Need to initialise for reading old files |
f4a4dc82 | 72 | fPrimary = new Int_t[fNMaxPrimary] ; |
af5bdd85 | 73 | fDEPrimary = new Float_t[fNMaxPrimary] ; |
f4a4dc82 | 74 | fIparent = new Int_t[fNMaxiparent] ; |
75 | fDEParent = new Float_t[fNMaxiparent] ; | |
af5bdd85 | 76 | for ( Int_t i = 0; i < fNMaxPrimary ; i++) { |
f4a4dc82 | 77 | fPrimary[i] = -1 ; |
af5bdd85 | 78 | fDEPrimary[i] = 0 ; |
79 | } | |
80 | ||
0ae8ae77 | 81 | for ( Int_t i = 0; i < fNMaxiparent ; i++) { |
f4a4dc82 | 82 | fIparent[i] = -1 ; |
af5bdd85 | 83 | fDEParent[i] = 0 ; |
84 | } | |
61e0abb5 | 85 | } |
86 | ||
87 | //____________________________________________________________________________ | |
2cd0ffda | 88 | AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Float_t digEnergy, Float_t time, Int_t type, Int_t index, Float_t chi2, Int_t ndf, Float_t dE) |
18a21c7c | 89 | : AliDigitNew(), |
829ba234 | 90 | fAmpFloat(digEnergy), |
91 | fNSamples(0), | |
f4a4dc82 | 92 | fSamples(0x0), |
829ba234 | 93 | fNSamplesHG(0), |
94 | fSamplesHG(0x0), | |
18a21c7c | 95 | fNprimary(0), |
96 | fNMaxPrimary(25), | |
97 | fPrimary(0x0), | |
af5bdd85 | 98 | fDEPrimary(0x0), |
18a21c7c | 99 | fNiparent(0), |
100 | fNMaxiparent(150), | |
101 | fIparent(0x0), | |
af5bdd85 | 102 | fDEParent(0x0), |
18a21c7c | 103 | fMaxIter(5), |
104 | fTime(time), | |
829ba234 | 105 | fTimeR(time), |
2cd0ffda | 106 | fChi2(chi2), |
107 | fNDF(ndf), | |
8a84b948 | 108 | fDigitType(type), |
109 | fAmpCalib(-1) | |
61e0abb5 | 110 | { |
111 | // ctor with all data | |
112 | ||
514da33c | 113 | // data memebrs of the base class (AliNewDigit) |
829ba234 | 114 | fAmp = 0; |
514da33c | 115 | fId = id ; |
116 | fIndexInList = index ; | |
117 | ||
829ba234 | 118 | // data member |
f4a4dc82 | 119 | fPrimary = new Int_t[fNMaxPrimary] ; |
af5bdd85 | 120 | fDEPrimary = new Float_t[fNMaxPrimary] ; |
f4a4dc82 | 121 | fIparent = new Int_t[fNMaxiparent] ; |
122 | fDEParent = new Float_t[fNMaxiparent] ; | |
61e0abb5 | 123 | if( primary != -1){ |
124 | fNprimary = 1 ; | |
7b62cd84 | 125 | fPrimary[0] = primary ; |
af5bdd85 | 126 | fDEPrimary[0] = dE ; |
61e0abb5 | 127 | fNiparent = 1 ; |
128 | fIparent[0] = iparent ; | |
af5bdd85 | 129 | fDEParent[0] = dE ; |
130 | } | |
61e0abb5 | 131 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1) |
132 | fNprimary = 0 ; | |
133 | fPrimary[0] = -1 ; | |
af5bdd85 | 134 | fDEPrimary[0] = 0 ; |
61e0abb5 | 135 | fNiparent = 0 ; |
af5bdd85 | 136 | fIparent[0] = -1 ; |
137 | fDEParent[0] = 0 ; | |
61e0abb5 | 138 | } |
139 | Int_t i ; | |
af5bdd85 | 140 | for ( i = 1; i < fNMaxPrimary ; i++) { |
61e0abb5 | 141 | fPrimary[i] = -1 ; |
af5bdd85 | 142 | fDEPrimary[i] = 0 ; |
143 | } | |
61e0abb5 | 144 | |
af5bdd85 | 145 | for ( i = 1; i< fNMaxiparent ; i++) { |
f807c3bd | 146 | fIparent[i] = -1 ; |
af5bdd85 | 147 | fDEParent[i] = 0 ; |
148 | } | |
61e0abb5 | 149 | } |
150 | ||
151 | //____________________________________________________________________________ | |
18a21c7c | 152 | AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) |
153 | : AliDigitNew(digit), | |
f4a4dc82 | 154 | fAmpFloat(digit.fAmpFloat), |
155 | fNSamples(digit.fNSamples), | |
e0dc3f7d | 156 | fSamples(), |
829ba234 | 157 | fNSamplesHG(digit.fNSamplesHG), |
e0dc3f7d | 158 | fSamplesHG(), |
18a21c7c | 159 | fNprimary(digit.fNprimary), |
160 | fNMaxPrimary(digit.fNMaxPrimary), | |
e0dc3f7d | 161 | fPrimary(), |
162 | fDEPrimary(), | |
18a21c7c | 163 | fNiparent(digit.fNiparent), |
164 | fNMaxiparent(digit.fNMaxiparent), | |
e0dc3f7d | 165 | fIparent(), |
166 | fDEParent(), | |
18a21c7c | 167 | fMaxIter(digit.fMaxIter), |
168 | fTime(digit.fTime), | |
829ba234 | 169 | fTimeR(digit.fTimeR), |
170 | fChi2(digit.fChi2), | |
171 | fNDF(digit.fNDF), | |
8a84b948 | 172 | fDigitType(digit.fDigitType), |
173 | fAmpCalib(digit.fAmpCalib) | |
61e0abb5 | 174 | { |
175 | // copy ctor | |
514da33c | 176 | // data memebrs of the base class (AliNewDigit) |
177 | fAmp = digit.fAmp ; | |
178 | fId = digit.fId; | |
179 | fIndexInList = digit.fIndexInList ; | |
61e0abb5 | 180 | |
829ba234 | 181 | // data members |
e0dc3f7d | 182 | if (fSamples ) delete [] fSamples ; fSamples = NULL ; |
183 | if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ; | |
184 | if (fPrimary ) delete [] fPrimary ; fPrimary = NULL ; | |
185 | if (fDEPrimary) delete [] fDEPrimary ; fDEPrimary = NULL ; | |
186 | if (fIparent ) delete [] fIparent ; fIparent = NULL ; | |
187 | if (fDEParent) delete [] fDEParent ; fDEParent = NULL ; | |
188 | ||
189 | if (fNSamples){ | |
84f6f119 | 190 | fSamples = new Int_t[fNSamples]; |
191 | for (Int_t i=0; i < digit.fNSamples; i++) fSamples[i] = digit.fSamples[i]; | |
192 | } | |
e0dc3f7d | 193 | |
194 | if (fNSamplesHG){ | |
84f6f119 | 195 | fSamplesHG = new Int_t[fNSamplesHG]; |
196 | for (Int_t i=0; i < digit.fNSamplesHG; i++) fSamplesHG[i] = digit.fSamplesHG[i]; | |
af5bdd85 | 197 | } |
e0dc3f7d | 198 | |
199 | ||
200 | if (fNMaxPrimary){ | |
84f6f119 | 201 | fPrimary = new Int_t [fNMaxPrimary] ; |
202 | fDEPrimary = new Float_t[fNMaxPrimary] ; | |
203 | for ( Int_t i = 0; i < fNMaxPrimary ; i++) { | |
204 | fPrimary[i] = digit.fPrimary[i] ; | |
205 | fDEPrimary[i] = digit.fDEPrimary[i] ; | |
206 | } | |
207 | } | |
e0dc3f7d | 208 | |
209 | if (fNMaxiparent){ | |
84f6f119 | 210 | fIparent = new Int_t [fNMaxiparent] ; |
211 | fDEParent = new Float_t[fNMaxiparent] ; | |
212 | for (Int_t j = 0; j< fNMaxiparent ; j++) { | |
af5bdd85 | 213 | fIparent[j] = digit.fIparent[j] ; |
84f6f119 | 214 | fDEParent[j] = digit.fDEParent[j] ; |
215 | } | |
e0dc3f7d | 216 | } |
217 | ||
61e0abb5 | 218 | } |
219 | ||
220 | //____________________________________________________________________________ | |
221 | AliEMCALDigit::~AliEMCALDigit() | |
222 | { | |
e0dc3f7d | 223 | // Delete array of primaries if any |
224 | ||
225 | if (fSamples ) delete [] fSamples ; fSamples = NULL ; | |
226 | if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ; | |
227 | if (fPrimary ) delete [] fPrimary ; fPrimary = NULL ; | |
228 | if (fDEPrimary) delete [] fDEPrimary ; fDEPrimary = NULL ; | |
229 | if (fIparent ) delete [] fIparent ; fIparent = NULL ; | |
230 | if (fDEParent) delete [] fDEParent ; fDEParent = NULL ; | |
231 | ||
232 | } | |
233 | ||
234 | ||
235 | //____________________________________________________________________________ | |
236 | void AliEMCALDigit::Clear(const Option_t*) | |
237 | { | |
238 | // Delete array of primaries if any | |
239 | if (fSamples ) delete [] fSamples ; fSamples = NULL ; | |
240 | if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ; | |
241 | if (fPrimary ) delete [] fPrimary ; fPrimary = NULL ; | |
242 | if (fDEPrimary) delete [] fDEPrimary ; fDEPrimary = NULL ; | |
243 | if (fIparent ) delete [] fIparent ; fIparent = NULL ; | |
244 | if (fDEParent) delete [] fDEParent ; fDEParent = NULL ; | |
829ba234 | 245 | |
61e0abb5 | 246 | } |
247 | ||
248 | //____________________________________________________________________________ | |
249 | Int_t AliEMCALDigit::Compare(const TObject * obj) const | |
250 | { | |
251 | // Compares two digits with respect to its Id | |
252 | // to sort according increasing Id | |
253 | ||
53e430a3 | 254 | Int_t rv = 2 ; |
61e0abb5 | 255 | |
256 | AliEMCALDigit * digit = (AliEMCALDigit *)obj ; | |
257 | ||
258 | Int_t iddiff = fId - digit->GetId() ; | |
259 | ||
260 | if ( iddiff > 0 ) | |
261 | rv = 1 ; | |
262 | else if ( iddiff < 0 ) | |
263 | rv = -1 ; | |
264 | else | |
265 | rv = 0 ; | |
266 | ||
267 | return rv ; | |
268 | ||
269 | } | |
270 | ||
814ad4bf | 271 | //____________________________________________________________________________ |
88cb7938 | 272 | Float_t AliEMCALDigit::GetEta() const |
14ce0a6e | 273 | { |
274 | //return pseudorapidity for this digit | |
275 | // should be change in EMCALGeometry - 19-nov-04 | |
814ad4bf | 276 | Float_t eta=-10., phi=-10.; |
563aa66c | 277 | Int_t id = GetId(); |
5dee926e | 278 | const AliEMCALGeometry *g = AliEMCALGeometry::GetInstance(); |
563aa66c | 279 | g->EtaPhiFromIndex(id,eta,phi); |
814ad4bf | 280 | return eta ; |
281 | } | |
282 | ||
283 | //____________________________________________________________________________ | |
88cb7938 | 284 | Float_t AliEMCALDigit::GetPhi() const |
14ce0a6e | 285 | { |
286 | //return phi coordinate of digit | |
287 | // should be change in EMCALGeometry - 19-nov-04 | |
814ad4bf | 288 | Float_t eta=-10., phi=-10.; |
563aa66c | 289 | Int_t id = GetId(); |
5dee926e | 290 | const AliEMCALGeometry *g = AliEMCALGeometry::GetInstance(); |
563aa66c | 291 | g->EtaPhiFromIndex(id,eta,phi); |
814ad4bf | 292 | return phi ; |
293 | } | |
294 | ||
829ba234 | 295 | //____________________________________________________________________________ |
296 | Bool_t AliEMCALDigit::GetFALTROSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const | |
297 | { | |
298 | //Get FALTRO sample in time bin iSample | |
f4a4dc82 | 299 | if (iSample >= fNSamples || iSample < 0 || fDigitType==kTrigger) return kFALSE; |
829ba234 | 300 | |
301 | amp = fSamples[iSample] & 0xFFF; | |
302 | timeBin = (fSamples[iSample] >> 12) & 0xFF; | |
303 | ||
304 | return kTRUE; | |
305 | } | |
306 | //____________________________________________________________________________ | |
307 | Bool_t AliEMCALDigit::GetALTROSampleLG(const Int_t iSample, Int_t& timeBin, Int_t& amp) const | |
308 | { | |
309 | //Get Low Gain ALTRO sample in time bin iSample | |
f4a4dc82 | 310 | if (iSample >= fNSamples || iSample < 0 || fDigitType==kLG) return kFALSE; |
829ba234 | 311 | |
312 | amp = fSamples[iSample] & 0xFFF; | |
313 | timeBin = (fSamples[iSample] >> 12) & 0xFF; | |
314 | ||
315 | return kTRUE; | |
316 | } | |
317 | ||
318 | //____________________________________________________________________________ | |
319 | void AliEMCALDigit::SetALTROSamplesLG(const Int_t nSamples, Int_t *samples) | |
320 | { | |
321 | //Set array of ALTRO samples, Low Gain or FALTRO | |
322 | fNSamples = nSamples; | |
323 | fSamples = new Int_t[fNSamples]; | |
324 | for (Int_t i=0; i < fNSamples; i++) fSamples[i] = samples[i]; | |
325 | } | |
326 | ||
327 | //____________________________________________________________________________ | |
328 | void AliEMCALDigit::SetALTROSamplesHG(const Int_t nSamples, Int_t *samples) | |
329 | { | |
330 | //Set array of ALTRO samples, High Gain. | |
331 | fNSamplesHG = nSamples; | |
332 | fSamplesHG = new Int_t[fNSamplesHG]; | |
333 | for (Int_t i=0; i < fNSamplesHG; i++) fSamplesHG[i] = samples[i]; | |
334 | } | |
335 | ||
336 | ||
337 | //____________________________________________________________________________ | |
338 | Bool_t AliEMCALDigit::GetALTROSampleHG(const Int_t iSample, Int_t& timeBin, Int_t& amp) const | |
339 | { | |
340 | //Get High Gain ALTRO sample in time bin iSample | |
f4a4dc82 | 341 | if (iSample >= fNSamplesHG || iSample < 0 || fDigitType==kHG) return kFALSE; |
829ba234 | 342 | |
343 | amp = fSamplesHG[iSample] & 0xFFF; | |
344 | timeBin = (fSamplesHG[iSample] >> 12) & 0xFF; | |
345 | ||
346 | return kTRUE; | |
347 | } | |
348 | ||
349 | ||
61e0abb5 | 350 | //____________________________________________________________________________ |
351 | Int_t AliEMCALDigit::GetPrimary(Int_t index) const | |
352 | { | |
353 | // retrieves the primary particle number given its index in the list | |
fdebddeb | 354 | if ( (index <= fNprimary) && (index > 0)){ |
af5bdd85 | 355 | return fPrimary[index-1] ; |
61e0abb5 | 356 | } |
357 | ||
af5bdd85 | 358 | return -1 ; |
359 | } | |
360 | ||
361 | //____________________________________________________________________________ | |
362 | Float_t AliEMCALDigit::GetDEPrimary(Int_t index) const | |
363 | { | |
364 | // retrieves the primary particle energy contribution | |
365 | // given its index in the list | |
366 | if ( (index <= fNprimary) && (index > 0)){ | |
367 | return fDEPrimary[index-1] ; | |
368 | } | |
369 | ||
370 | return 0 ; | |
61e0abb5 | 371 | |
372 | } | |
373 | ||
374 | //____________________________________________________________________________ | |
375 | Int_t AliEMCALDigit::GetIparent(Int_t index) const | |
376 | { | |
377 | // retrieves the primary particle number given its index in the list | |
af5bdd85 | 378 | if ( index <= fNiparent && index > 0){ |
379 | return fIparent[index-1] ; | |
61e0abb5 | 380 | } |
381 | ||
af5bdd85 | 382 | return -1 ; |
61e0abb5 | 383 | |
384 | } | |
385 | ||
af5bdd85 | 386 | //____________________________________________________________________________ |
387 | Float_t AliEMCALDigit::GetDEParent(Int_t index) const | |
388 | { | |
389 | // retrieves the parent particle energy contribution | |
390 | // given its index in the list | |
391 | if ( (index <= fNiparent) && (index > 0)){ | |
392 | return fDEParent[index-1] ; | |
393 | } | |
394 | ||
395 | return 0; | |
396 | } | |
397 | ||
61e0abb5 | 398 | //____________________________________________________________________________ |
399 | void AliEMCALDigit::ShiftPrimary(Int_t shift){ | |
fdebddeb | 400 | //shifts primary number to BIG offset, to separate primary in different TreeK |
61e0abb5 | 401 | Int_t index ; |
402 | for(index = 0; index <fNprimary; index++ ){ | |
403 | fPrimary[index] = fPrimary[index]+ shift * 10000000 ;} | |
404 | for(index =0; index <fNiparent; index++){ | |
405 | fIparent[index] = fIparent[index] + shift * 10000000 ;} | |
406 | } | |
0bd264d5 | 407 | |
408 | ||
409 | //____________________________________________________________________________ | |
410 | AliEMCALDigit& AliEMCALDigit::operator= (const AliEMCALDigit &digit) | |
411 | { | |
412 | // assignment operator | |
413 | ||
414 | if(&digit == this) return *this; | |
415 | ||
416 | fAmpFloat = digit.fAmpFloat; | |
417 | fNSamples = digit.fNSamples; | |
418 | fNSamplesHG = digit.fNSamplesHG; | |
419 | fNprimary = digit.fNprimary; | |
420 | fNMaxPrimary = digit.fNMaxPrimary; | |
421 | fNiparent = digit.fNiparent; | |
422 | fNMaxiparent = digit.fNMaxiparent; | |
423 | fMaxIter = digit.fMaxIter; | |
424 | fTime = digit.fTime; | |
425 | fTimeR = digit.fTimeR; | |
426 | fChi2 = digit.fChi2; | |
427 | fNDF = digit.fNDF; | |
428 | fDigitType = digit.fDigitType; | |
429 | fAmpCalib = digit.fAmpCalib; | |
430 | fAmp = digit.fAmp ; | |
431 | fId = digit.fId; | |
432 | fIndexInList = digit.fIndexInList ; | |
433 | ||
434 | // data members | |
435 | if (fSamples ) delete [] fSamples ; fSamples = NULL ; | |
436 | if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ; | |
437 | if (fPrimary ) delete [] fPrimary ; fPrimary = NULL ; | |
438 | if (fDEPrimary) delete [] fDEPrimary ; fDEPrimary = NULL ; | |
439 | if (fIparent ) delete [] fIparent ; fIparent = NULL ; | |
440 | if (fDEParent) delete [] fDEParent ; fDEParent = NULL ; | |
441 | ||
442 | if (fNSamples){ | |
443 | fSamples = new Int_t[fNSamples]; | |
444 | for (Int_t i=0; i < digit.fNSamples; i++) fSamples[i] = digit.fSamples[i]; | |
445 | } | |
446 | ||
447 | if (fNSamplesHG){ | |
448 | fSamplesHG = new Int_t[fNSamplesHG]; | |
449 | for (Int_t i=0; i < digit.fNSamplesHG; i++) fSamplesHG[i] = digit.fSamplesHG[i]; | |
450 | } | |
451 | ||
452 | ||
453 | if (fNMaxPrimary){ | |
454 | fPrimary = new Int_t [fNMaxPrimary] ; | |
455 | fDEPrimary = new Float_t[fNMaxPrimary] ; | |
456 | for ( Int_t i = 0; i < fNMaxPrimary ; i++) { | |
457 | fPrimary[i] = digit.fPrimary[i] ; | |
458 | fDEPrimary[i] = digit.fDEPrimary[i] ; | |
459 | } | |
460 | } | |
461 | ||
462 | if (fNMaxiparent){ | |
463 | fIparent = new Int_t [fNMaxiparent] ; | |
464 | fDEParent = new Float_t[fNMaxiparent] ; | |
465 | for (Int_t j = 0; j< fNMaxiparent ; j++) { | |
466 | fIparent[j] = digit.fIparent[j] ; | |
467 | fDEParent[j] = digit.fDEParent[j] ; | |
468 | } | |
469 | } | |
470 | ||
471 | return *this; | |
472 | ||
473 | } | |
474 | ||
61e0abb5 | 475 | //____________________________________________________________________________ |
476 | Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const | |
477 | { | |
478 | // Two digits are equal if they have the same Id | |
479 | ||
480 | if ( fId == digit.fId ) | |
481 | return kTRUE ; | |
482 | else | |
483 | return kFALSE ; | |
484 | } | |
485 | ||
486 | //____________________________________________________________________________ | |
0a4cb131 | 487 | AliEMCALDigit AliEMCALDigit::operator+(const AliEMCALDigit &digit) |
61e0abb5 | 488 | { |
489 | // Adds the amplitude of digits and completes the list of primary particles | |
490 | // if amplitude is larger than | |
491 | ||
829ba234 | 492 | fAmpFloat += digit.fAmpFloat ; |
493 | for (Int_t i=0; i < fNSamples ; i++) fSamples[i] += digit.fSamples[i]; | |
494 | for (Int_t i=0; i < fNSamplesHG; i++) fSamplesHG[i] += digit.fSamplesHG[i]; | |
d8c2bd69 | 495 | |
829ba234 | 496 | fAmp += digit.fAmp ; |
814ad4bf | 497 | if(fTime > digit.fTime) |
498 | fTime = digit.fTime ; | |
3c80fef6 | 499 | if (digit.fTimeR < fTimeR) |
500 | fTimeR = digit.fTimeR ; | |
d8c2bd69 | 501 | |
61e0abb5 | 502 | Int_t max1 = fNprimary ; |
503 | Int_t max2 = fNiparent ; | |
504 | Int_t index ; | |
7b62cd84 | 505 | for (index = 0 ; index < digit.fNprimary ; index++){ |
af5bdd85 | 506 | Bool_t newPrim = kTRUE ; |
61e0abb5 | 507 | Int_t old ; |
af5bdd85 | 508 | for ( old = 0 ; (old < max1) && newPrim; old++) { //already have this primary? |
509 | if(fPrimary[old] == digit.fPrimary[index]) { | |
d8c2bd69 | 510 | newPrim = kFALSE; |
511 | fDEPrimary[old] += digit.fDEPrimary[index]; | |
af5bdd85 | 512 | } |
61e0abb5 | 513 | } |
af5bdd85 | 514 | if (newPrim) { |
515 | if(max1<fNMaxPrimary){ | |
d8c2bd69 | 516 | fPrimary[max1] = digit.fPrimary[index] ; |
517 | fDEPrimary[max1] = digit.fDEPrimary[index] ; | |
518 | fNprimary++ ; | |
519 | max1++; | |
af5bdd85 | 520 | } |
7b62cd84 | 521 | if(fNprimary==fNMaxPrimary) { |
d8c2bd69 | 522 | |
523 | TString mess = " NMaxPrimary = " ; | |
524 | mess += fNMaxPrimary ; | |
525 | mess += " is too small" ; | |
526 | AliFatal(mess.Data()) ; | |
527 | ||
61e0abb5 | 528 | } |
529 | } | |
530 | } | |
531 | ||
532 | for (index = 0 ; index < digit.fNiparent ; index++){ | |
af5bdd85 | 533 | Bool_t newParent = kTRUE ; |
61e0abb5 | 534 | Int_t old ; |
af5bdd85 | 535 | for ( old = 0 ; (old < max2) && newParent; old++) { //already have this primary? |
536 | if(fIparent[old] == digit.fIparent[index]) { | |
d8c2bd69 | 537 | newParent = kFALSE; |
538 | fDEParent[old] += digit.fDEParent[index]; | |
af5bdd85 | 539 | } |
61e0abb5 | 540 | } |
af5bdd85 | 541 | if(newParent){ |
542 | if(max2<fNMaxiparent) { | |
d8c2bd69 | 543 | fIparent[max2] = digit.fIparent[index] ; |
544 | fDEParent[max2] = digit.fDEParent[index] ; | |
545 | fNiparent++ ; | |
546 | max2++; | |
af5bdd85 | 547 | } |
7b62cd84 | 548 | if(fNiparent==fNMaxiparent) { |
d8c2bd69 | 549 | |
550 | TString mess = " NMaxiparent = " ; | |
551 | mess += fNMaxiparent ; | |
552 | mess += " is too small" ; | |
553 | AliFatal(mess.Data()) ; | |
554 | ||
61e0abb5 | 555 | } |
556 | } | |
557 | } | |
558 | ||
559 | return *this ; | |
560 | } | |
561 | ||
563aa66c | 562 | //____________________________________________________________________________ |
0a4cb131 | 563 | AliEMCALDigit AliEMCALDigit::operator*(Float_t factor) |
563aa66c | 564 | { |
565 | // Multiplies the amplitude by a factor | |
566 | ||
829ba234 | 567 | //Float_t tempo = static_cast<Float_t>(fAmp) ; |
568 | //tempo *= factor ; | |
569 | //fAmp = static_cast<Int_t>(TMath::Floor(tempo)) ; | |
570 | ||
571 | fAmpFloat *= factor; | |
572 | for (Int_t i=0; i < fNSamples ; i++) fSamples[i] = Int_t(factor*fSamples[i]); | |
573 | for (Int_t i=0; i < fNSamplesHG; i++) fSamplesHG[i] = Int_t(factor*fSamplesHG[i]); | |
574 | ||
af5bdd85 | 575 | for(Int_t i=0; i < fNprimary; i++) |
576 | fDEPrimary[i] *= factor; | |
577 | for(Int_t i=0; i < fNiparent; i++) | |
578 | fDEParent[i] *= factor; | |
579 | ||
563aa66c | 580 | return *this ; |
581 | } | |
582 | ||
61e0abb5 | 583 | //____________________________________________________________________________ |
584 | ostream& operator << ( ostream& out , const AliEMCALDigit & digit) | |
585 | { | |
586 | // Prints the data of the digit | |
587 | ||
814ad4bf | 588 | out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ; |
53e430a3 | 589 | for(Int_t i=0;i<digit.fNprimary;i++) |
af5bdd85 | 590 | out << "Primary " << i+1 << " = " << digit.fPrimary[i] |
591 | << " : DE " << digit.fDEPrimary[i] << endl ; | |
61e0abb5 | 592 | |
53e430a3 | 593 | for(Int_t j=0;j<digit.fNiparent;j++) |
af5bdd85 | 594 | out << "Iparent " << j+1 << " = " << digit.fIparent[j] |
595 | << " : DE " << digit.fDEParent[j] << endl ; | |
596 | out << "Position in list = " << digit.fIndexInList << endl ; | |
61e0abb5 | 597 | return out ; |
598 | } | |
599 | ||
829ba234 | 600 | //____________________________________________________________________________ |
601 | void AliEMCALDigit::Print(const Option_t* /*opt*/) const | |
602 | { | |
603 | ||
f4a4dc82 | 604 | printf("===\nDigit id: %4d / Energy %2.3f ; Time %e ; Time samples %d ; Chi2 %2.3f, NDF %d, Type? %d \n", |
605 | fId, fAmpFloat,fTime, fNSamples, fChi2, fNDF, fDigitType); | |
606 | if(fDigitType==kTrigger){ | |
829ba234 | 607 | printf("FALTRO: "); |
608 | for (Int_t i=0; i < GetNFALTROSamples(); i++) | |
609 | { | |
610 | Int_t timeBin, amp; | |
611 | GetFALTROSample(i, timeBin, amp); | |
612 | printf(" (%d,%d) ",timeBin,amp); | |
613 | } | |
614 | printf("\n"); | |
615 | }//trigger | |
616 | else{ | |
617 | printf("ALTRO, Low Gain: "); | |
618 | for (Int_t i=0; i < GetNALTROSamplesLG(); i++) | |
619 | { | |
620 | Int_t timeBin, amp; | |
621 | GetALTROSampleLG(i, timeBin, amp); | |
622 | printf(" (%d,%d) ",timeBin,amp); | |
623 | } | |
624 | printf("\n"); | |
625 | printf("ALTRO, High Gain: "); | |
626 | for (Int_t i=0; i < GetNALTROSamplesHG(); i++) | |
627 | { | |
628 | Int_t timeBin, amp; | |
629 | GetALTROSampleHG(i, timeBin, amp); | |
630 | printf(" (%d,%d) ",timeBin,amp); | |
631 | } | |
632 | printf("\n"); | |
633 | }//trigger | |
634 | ||
635 | } | |
636 | ||
637 | ||
61e0abb5 | 638 |