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