]>
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() : |
44 | AliDigitNew(), | |
45 | fNprimary(0), | |
46 | fNMaxPrimary(5), | |
47 | fPrimary(0x0), | |
af5bdd85 | 48 | fDEPrimary(0x0), |
514da33c | 49 | fNiparent(0), |
50 | fNMaxiparent(5), | |
51 | fIparent(0x0), | |
af5bdd85 | 52 | fDEParent(0x0), |
514da33c | 53 | fMaxIter(0), |
54 | fTime(0.), | |
55 | fTimeR(0.) | |
56 | ||
61e0abb5 | 57 | { |
58 | // default ctor | |
59 | ||
af5bdd85 | 60 | // Need to initialise for reading old files |
0ae8ae77 | 61 | fPrimary = new Int_t[fNMaxPrimary] ; |
af5bdd85 | 62 | fDEPrimary = new Float_t[fNMaxPrimary] ; |
0ae8ae77 | 63 | fIparent = new Int_t[fNMaxiparent] ; |
af5bdd85 | 64 | fDEParent = new Float_t[fNMaxiparent] ; |
65 | for ( Int_t i = 0; i < fNMaxPrimary ; i++) { | |
0ae8ae77 | 66 | fPrimary[i] = -1 ; |
af5bdd85 | 67 | fDEPrimary[i] = 0 ; |
68 | } | |
69 | ||
0ae8ae77 | 70 | for ( Int_t i = 0; i < fNMaxiparent ; i++) { |
71 | fIparent[i] = -1 ; | |
af5bdd85 | 72 | fDEParent[i] = 0 ; |
73 | } | |
61e0abb5 | 74 | } |
75 | ||
76 | //____________________________________________________________________________ | |
af5bdd85 | 77 | AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index, Float_t dE) |
18a21c7c | 78 | : AliDigitNew(), |
79 | fNprimary(0), | |
80 | fNMaxPrimary(25), | |
81 | fPrimary(0x0), | |
af5bdd85 | 82 | fDEPrimary(0x0), |
18a21c7c | 83 | fNiparent(0), |
84 | fNMaxiparent(150), | |
85 | fIparent(0x0), | |
af5bdd85 | 86 | fDEParent(0x0), |
18a21c7c | 87 | fMaxIter(5), |
88 | fTime(time), | |
89 | fTimeR(time) | |
61e0abb5 | 90 | { |
91 | // ctor with all data | |
92 | ||
514da33c | 93 | // data memebrs of the base class (AliNewDigit) |
94 | fAmp = DigEnergy ; | |
95 | fId = id ; | |
96 | fIndexInList = index ; | |
97 | ||
98 | // data members | |
88d764f0 | 99 | fPrimary = new Int_t[fNMaxPrimary] ; |
af5bdd85 | 100 | fDEPrimary = new Float_t[fNMaxPrimary] ; |
88d764f0 | 101 | fIparent = new Int_t[fNMaxiparent] ; |
af5bdd85 | 102 | fDEParent = new Float_t[fNMaxiparent] ; |
61e0abb5 | 103 | if( primary != -1){ |
104 | fNprimary = 1 ; | |
7b62cd84 | 105 | fPrimary[0] = primary ; |
af5bdd85 | 106 | fDEPrimary[0] = dE ; |
61e0abb5 | 107 | fNiparent = 1 ; |
108 | fIparent[0] = iparent ; | |
af5bdd85 | 109 | fDEParent[0] = dE ; |
110 | } | |
61e0abb5 | 111 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1) |
112 | fNprimary = 0 ; | |
113 | fPrimary[0] = -1 ; | |
af5bdd85 | 114 | fDEPrimary[0] = 0 ; |
61e0abb5 | 115 | fNiparent = 0 ; |
af5bdd85 | 116 | fIparent[0] = -1 ; |
117 | fDEParent[0] = 0 ; | |
61e0abb5 | 118 | } |
119 | Int_t i ; | |
af5bdd85 | 120 | for ( i = 1; i < fNMaxPrimary ; i++) { |
61e0abb5 | 121 | fPrimary[i] = -1 ; |
af5bdd85 | 122 | fDEPrimary[i] = 0 ; |
123 | } | |
61e0abb5 | 124 | |
af5bdd85 | 125 | for ( i = 1; i< fNMaxiparent ; i++) { |
f807c3bd | 126 | fIparent[i] = -1 ; |
af5bdd85 | 127 | fDEParent[i] = 0 ; |
128 | } | |
61e0abb5 | 129 | } |
130 | ||
131 | //____________________________________________________________________________ | |
18a21c7c | 132 | AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) |
133 | : AliDigitNew(digit), | |
134 | fNprimary(digit.fNprimary), | |
135 | fNMaxPrimary(digit.fNMaxPrimary), | |
136 | fPrimary(0x0), | |
af5bdd85 | 137 | fDEPrimary(0x0), |
18a21c7c | 138 | fNiparent(digit.fNiparent), |
139 | fNMaxiparent(digit.fNMaxiparent), | |
140 | fIparent(0x0), | |
af5bdd85 | 141 | fDEParent(0x0), |
18a21c7c | 142 | fMaxIter(digit.fMaxIter), |
143 | fTime(digit.fTime), | |
144 | fTimeR(digit.fTimeR) | |
61e0abb5 | 145 | { |
146 | // copy ctor | |
147 | ||
514da33c | 148 | // data memebrs of the base class (AliNewDigit) |
149 | fAmp = digit.fAmp ; | |
150 | fId = digit.fId; | |
151 | fIndexInList = digit.fIndexInList ; | |
61e0abb5 | 152 | |
514da33c | 153 | // data members |
af5bdd85 | 154 | fPrimary = new Int_t[fNMaxPrimary] ; |
155 | fDEPrimary = new Float_t[fNMaxPrimary] ; | |
156 | fIparent = new Int_t[fNMaxiparent] ; | |
157 | fDEParent = new Float_t[fNMaxiparent] ; | |
61e0abb5 | 158 | Int_t i ; |
8c6a53b9 | 159 | for ( i = 0; i < fNMaxPrimary ; i++) { |
af5bdd85 | 160 | fPrimary[i] = digit.fPrimary[i] ; |
161 | fDEPrimary[i] = digit.fDEPrimary[i] ; | |
162 | } | |
61e0abb5 | 163 | Int_t j ; |
8c6a53b9 | 164 | for (j = 0; j< fNMaxiparent ; j++) { |
af5bdd85 | 165 | fIparent[j] = digit.fIparent[j] ; |
166 | fDEParent[j] = digit.fDEParent[j] ; | |
167 | } | |
61e0abb5 | 168 | } |
169 | ||
170 | //____________________________________________________________________________ | |
171 | AliEMCALDigit::~AliEMCALDigit() | |
172 | { | |
173 | // Delete array of primiries if any | |
88d764f0 | 174 | delete [] fPrimary ; |
af5bdd85 | 175 | delete [] fDEPrimary ; |
88d764f0 | 176 | delete [] fIparent ; |
af5bdd85 | 177 | delete [] fDEParent ; |
61e0abb5 | 178 | } |
179 | ||
180 | //____________________________________________________________________________ | |
181 | Int_t AliEMCALDigit::Compare(const TObject * obj) const | |
182 | { | |
183 | // Compares two digits with respect to its Id | |
184 | // to sort according increasing Id | |
185 | ||
186 | Int_t rv ; | |
187 | ||
188 | AliEMCALDigit * digit = (AliEMCALDigit *)obj ; | |
189 | ||
190 | Int_t iddiff = fId - digit->GetId() ; | |
191 | ||
192 | if ( iddiff > 0 ) | |
193 | rv = 1 ; | |
194 | else if ( iddiff < 0 ) | |
195 | rv = -1 ; | |
196 | else | |
197 | rv = 0 ; | |
198 | ||
199 | return rv ; | |
200 | ||
201 | } | |
202 | ||
814ad4bf | 203 | //____________________________________________________________________________ |
88cb7938 | 204 | Float_t AliEMCALDigit::GetEta() const |
14ce0a6e | 205 | { |
206 | //return pseudorapidity for this digit | |
207 | // should be change in EMCALGeometry - 19-nov-04 | |
814ad4bf | 208 | Float_t eta=-10., phi=-10.; |
563aa66c | 209 | Int_t id = GetId(); |
5dee926e | 210 | const AliEMCALGeometry *g = AliEMCALGeometry::GetInstance(); |
563aa66c | 211 | g->EtaPhiFromIndex(id,eta,phi); |
814ad4bf | 212 | return eta ; |
213 | } | |
214 | ||
215 | //____________________________________________________________________________ | |
88cb7938 | 216 | Float_t AliEMCALDigit::GetPhi() const |
14ce0a6e | 217 | { |
218 | //return phi coordinate of digit | |
219 | // should be change in EMCALGeometry - 19-nov-04 | |
814ad4bf | 220 | Float_t eta=-10., phi=-10.; |
563aa66c | 221 | Int_t id = GetId(); |
5dee926e | 222 | const AliEMCALGeometry *g = AliEMCALGeometry::GetInstance(); |
563aa66c | 223 | g->EtaPhiFromIndex(id,eta,phi); |
814ad4bf | 224 | return phi ; |
225 | } | |
226 | ||
61e0abb5 | 227 | //____________________________________________________________________________ |
228 | Int_t AliEMCALDigit::GetPrimary(Int_t index) const | |
229 | { | |
230 | // retrieves the primary particle number given its index in the list | |
fdebddeb | 231 | if ( (index <= fNprimary) && (index > 0)){ |
af5bdd85 | 232 | return fPrimary[index-1] ; |
61e0abb5 | 233 | } |
234 | ||
af5bdd85 | 235 | return -1 ; |
236 | } | |
237 | ||
238 | //____________________________________________________________________________ | |
239 | Float_t AliEMCALDigit::GetDEPrimary(Int_t index) const | |
240 | { | |
241 | // retrieves the primary particle energy contribution | |
242 | // given its index in the list | |
243 | if ( (index <= fNprimary) && (index > 0)){ | |
244 | return fDEPrimary[index-1] ; | |
245 | } | |
246 | ||
247 | return 0 ; | |
61e0abb5 | 248 | |
249 | } | |
250 | ||
251 | //____________________________________________________________________________ | |
252 | Int_t AliEMCALDigit::GetIparent(Int_t index) const | |
253 | { | |
254 | // retrieves the primary particle number given its index in the list | |
af5bdd85 | 255 | if ( index <= fNiparent && index > 0){ |
256 | return fIparent[index-1] ; | |
61e0abb5 | 257 | } |
258 | ||
af5bdd85 | 259 | return -1 ; |
61e0abb5 | 260 | |
261 | } | |
262 | ||
af5bdd85 | 263 | //____________________________________________________________________________ |
264 | Float_t AliEMCALDigit::GetDEParent(Int_t index) const | |
265 | { | |
266 | // retrieves the parent particle energy contribution | |
267 | // given its index in the list | |
268 | if ( (index <= fNiparent) && (index > 0)){ | |
269 | return fDEParent[index-1] ; | |
270 | } | |
271 | ||
272 | return 0; | |
273 | } | |
274 | ||
61e0abb5 | 275 | //____________________________________________________________________________ |
276 | void AliEMCALDigit::ShiftPrimary(Int_t shift){ | |
fdebddeb | 277 | //shifts primary number to BIG offset, to separate primary in different TreeK |
61e0abb5 | 278 | Int_t index ; |
279 | for(index = 0; index <fNprimary; index++ ){ | |
280 | fPrimary[index] = fPrimary[index]+ shift * 10000000 ;} | |
281 | for(index =0; index <fNiparent; index++){ | |
282 | fIparent[index] = fIparent[index] + shift * 10000000 ;} | |
283 | } | |
284 | //____________________________________________________________________________ | |
285 | Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const | |
286 | { | |
287 | // Two digits are equal if they have the same Id | |
288 | ||
289 | if ( fId == digit.fId ) | |
290 | return kTRUE ; | |
291 | else | |
292 | return kFALSE ; | |
293 | } | |
294 | ||
295 | //____________________________________________________________________________ | |
0a4cb131 | 296 | AliEMCALDigit AliEMCALDigit::operator+(const AliEMCALDigit &digit) |
61e0abb5 | 297 | { |
298 | // Adds the amplitude of digits and completes the list of primary particles | |
299 | // if amplitude is larger than | |
300 | ||
301 | fAmp += digit.fAmp ; | |
814ad4bf | 302 | if(fTime > digit.fTime) |
303 | fTime = digit.fTime ; | |
3c80fef6 | 304 | if (digit.fTimeR < fTimeR) |
305 | fTimeR = digit.fTimeR ; | |
7b62cd84 | 306 | |
61e0abb5 | 307 | Int_t max1 = fNprimary ; |
308 | Int_t max2 = fNiparent ; | |
309 | Int_t index ; | |
7b62cd84 | 310 | for (index = 0 ; index < digit.fNprimary ; index++){ |
af5bdd85 | 311 | Bool_t newPrim = kTRUE ; |
61e0abb5 | 312 | Int_t old ; |
af5bdd85 | 313 | for ( old = 0 ; (old < max1) && newPrim; old++) { //already have this primary? |
314 | if(fPrimary[old] == digit.fPrimary[index]) { | |
315 | newPrim = kFALSE; | |
316 | fDEPrimary[old] += digit.fDEPrimary[index]; | |
317 | } | |
61e0abb5 | 318 | } |
af5bdd85 | 319 | if (newPrim) { |
320 | if(max1<fNMaxPrimary){ | |
321 | fPrimary[max1] = digit.fPrimary[index] ; | |
322 | fDEPrimary[max1] = digit.fDEPrimary[index] ; | |
323 | fNprimary++ ; | |
324 | max1++; | |
325 | } | |
7b62cd84 | 326 | if(fNprimary==fNMaxPrimary) { |
af5bdd85 | 327 | |
451bc3c5 | 328 | TString mess = " NMaxPrimary = " ; |
329 | mess += fNMaxPrimary ; | |
330 | mess += " is too small" ; | |
331 | Fatal("AliEMCALDigit::Operator+ -->" , mess.Data()) ; | |
8704424d | 332 | |
61e0abb5 | 333 | } |
334 | } | |
335 | } | |
336 | ||
337 | for (index = 0 ; index < digit.fNiparent ; index++){ | |
af5bdd85 | 338 | Bool_t newParent = kTRUE ; |
61e0abb5 | 339 | Int_t old ; |
af5bdd85 | 340 | for ( old = 0 ; (old < max2) && newParent; old++) { //already have this primary? |
341 | if(fIparent[old] == digit.fIparent[index]) { | |
342 | newParent = kFALSE; | |
343 | fDEParent[old] += digit.fDEParent[index]; | |
344 | } | |
61e0abb5 | 345 | } |
af5bdd85 | 346 | if(newParent){ |
347 | if(max2<fNMaxiparent) { | |
348 | fIparent[max2] = digit.fIparent[index] ; | |
349 | fDEParent[max2] = digit.fDEParent[index] ; | |
350 | fNiparent++ ; | |
351 | max2++; | |
352 | } | |
7b62cd84 | 353 | if(fNiparent==fNMaxiparent) { |
af5bdd85 | 354 | |
451bc3c5 | 355 | TString mess = " NMaxiparent = " ; |
356 | mess += fNMaxiparent ; | |
357 | mess += " is too small" ; | |
358 | Fatal("AliEMCALDigit::Operator+ -->", mess.Data()) ; | |
8704424d | 359 | |
61e0abb5 | 360 | } |
361 | } | |
362 | } | |
363 | ||
364 | return *this ; | |
365 | } | |
366 | ||
563aa66c | 367 | //____________________________________________________________________________ |
0a4cb131 | 368 | AliEMCALDigit AliEMCALDigit::operator*(Float_t factor) |
563aa66c | 369 | { |
370 | // Multiplies the amplitude by a factor | |
371 | ||
372 | Float_t tempo = static_cast<Float_t>(fAmp) ; | |
373 | tempo *= factor ; | |
374 | fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ; | |
af5bdd85 | 375 | for(Int_t i=0; i < fNprimary; i++) |
376 | fDEPrimary[i] *= factor; | |
377 | for(Int_t i=0; i < fNiparent; i++) | |
378 | fDEParent[i] *= factor; | |
379 | ||
563aa66c | 380 | return *this ; |
381 | } | |
382 | ||
61e0abb5 | 383 | //____________________________________________________________________________ |
384 | ostream& operator << ( ostream& out , const AliEMCALDigit & digit) | |
385 | { | |
386 | // Prints the data of the digit | |
387 | ||
814ad4bf | 388 | out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ; |
61e0abb5 | 389 | Int_t i,j ; |
af5bdd85 | 390 | for(i=0;i<digit.fNprimary;i++) |
391 | out << "Primary " << i+1 << " = " << digit.fPrimary[i] | |
392 | << " : DE " << digit.fDEPrimary[i] << endl ; | |
61e0abb5 | 393 | |
394 | for(j=0;j<digit.fNiparent;j++) | |
af5bdd85 | 395 | out << "Iparent " << j+1 << " = " << digit.fIparent[j] |
396 | << " : DE " << digit.fDEParent[j] << endl ; | |
397 | out << "Position in list = " << digit.fIndexInList << endl ; | |
61e0abb5 | 398 | return out ; |
399 | } | |
400 | ||
401 |