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