]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | ||
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | ||
5 | * * | |
6 | ||
7 | * Author: The ALICE Off-line Project. * | |
8 | ||
9 | * Contributors are mentioned in the code where appropriate. * | |
10 | ||
11 | * * | |
12 | ||
13 | * Permission to use, copy, modify and distribute this software and its * | |
14 | ||
15 | * documentation strictly for non-commercial purposes is hereby granted * | |
16 | ||
17 | * without fee, provided that the above copyright notice appears in all * | |
18 | ||
19 | * copies and that both the copyright notice and this permission notice * | |
20 | ||
21 | * appear in the supporting documentation. The authors make no claims * | |
22 | ||
23 | * about the suitability of this software for any purpose. It is * | |
24 | ||
25 | * provided "as is" without express or implied warranty. * | |
26 | ||
27 | **************************************************************************/ | |
28 | ||
29 | ||
30 | ||
31 | /* $Id: */ | |
32 | ||
33 | ||
34 | ||
35 | //_________________________________________________________________________ | |
36 | ||
37 | // EMCAL digit: | |
38 | ||
39 | // A Digit is the sum of the energy lost in an EMCAL Tower | |
40 | ||
41 | // It also stores information on Primary, and enterring particle | |
42 | ||
43 | // tracknumbers Digits are created using AliEMCALSDigitizer, followed | |
44 | ||
45 | // by AliEMCALDigitizer | |
46 | ||
47 | // | |
48 | ||
49 | //*-- Author: Sahal Yacoob (LBL) | |
50 | ||
51 | // based on : AliPHOSDigit | |
52 | ||
53 | //__________________________________________________________________________ | |
54 | ||
55 | ||
56 | ||
57 | // --- ROOT system --- | |
58 | ||
59 | ||
60 | ||
61 | // --- Standard library --- | |
62 | ||
63 | ||
64 | ||
65 | #include <iostream.h> | |
66 | ||
67 | ||
68 | ||
69 | // --- AliRoot header files --- | |
70 | ||
71 | ||
72 | ||
73 | #include "AliEMCALDigit.h" | |
74 | ||
75 | #include "AliEMCALGeometry.h" | |
76 | ||
77 | #include "AliEMCALGetter.h" | |
78 | ||
79 | ||
80 | ||
81 | ||
82 | ||
83 | ClassImp(AliEMCALDigit) | |
84 | ||
85 | ||
86 | ||
87 | //____________________________________________________________________________ | |
88 | ||
89 | AliEMCALDigit::AliEMCALDigit() | |
90 | ||
91 | { | |
92 | ||
93 | // default ctor | |
94 | ||
95 | ||
96 | ||
97 | fIndexInList = 0 ; | |
98 | ||
99 | fNprimary = 0 ; | |
100 | ||
101 | fNMaxPrimary = 0 ; | |
102 | ||
103 | fNiparent = 0 ; | |
104 | ||
105 | ||
106 | fNMaxiparent = 0; | |
107 | ||
108 | fPrimary = 0 ; | |
109 | ||
110 | fIparent = 0 ; | |
111 | ||
112 | fMaxIter = 0; | |
113 | } | |
114 | ||
115 | ||
116 | ||
117 | //____________________________________________________________________________ | |
118 | ||
119 | AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index) | |
120 | ||
121 | { | |
122 | ||
123 | // ctor with all data | |
124 | ||
125 | ||
126 | ||
127 | fNMaxPrimary = 5 ; | |
128 | ||
129 | fNMaxiparent = 40 ; | |
130 | ||
131 | fPrimary = new Int_t[fNMaxPrimary] ; | |
132 | ||
133 | fIparent = new Int_t[fNMaxiparent] ; | |
134 | ||
135 | fAmp = DigEnergy ; | |
136 | ||
137 | fTime = time ; | |
138 | ||
139 | fId = id ; | |
140 | ||
141 | fIndexInList = index ; | |
142 | ||
143 | fMaxIter = 5; | |
144 | if( primary != -1){ | |
145 | ||
146 | fNprimary = 1 ; | |
147 | ||
148 | fPrimary[0] = primary ; | |
149 | ||
150 | fNiparent = 1 ; | |
151 | ||
152 | fIparent[0] = iparent ; | |
153 | ||
154 | } | |
155 | ||
156 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1) | |
157 | ||
158 | fNprimary = 0 ; | |
159 | ||
160 | fPrimary[0] = -1 ; | |
161 | ||
162 | fNiparent = 0 ; | |
163 | ||
164 | fIparent[0] = -1 ; | |
165 | ||
166 | ||
167 | ||
168 | } | |
169 | ||
170 | Int_t i ; | |
171 | ||
172 | for ( i = 1; i < fNMaxPrimary ; i++) | |
173 | ||
174 | fPrimary[i] = -1 ; | |
175 | ||
176 | ||
177 | ||
178 | for ( i =1; i< fNMaxiparent ; i++) | |
179 | ||
180 | fIparent[i] = -1 ; | |
181 | ||
182 | } | |
183 | ||
184 | ||
185 | ||
186 | //____________________________________________________________________________ | |
187 | ||
188 | AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) | |
189 | ||
190 | { | |
191 | ||
192 | // copy ctor | |
193 | ||
194 | ||
195 | ||
196 | ||
197 | ||
198 | fNMaxPrimary = digit.fNMaxPrimary ; | |
199 | ||
200 | fNMaxiparent = digit.fNMaxiparent ; | |
201 | ||
202 | fPrimary = new Int_t[fNMaxPrimary] ; | |
203 | ||
204 | fIparent = new Int_t[fNMaxiparent] ; | |
205 | ||
206 | Int_t i ; | |
207 | ||
208 | for ( i = 0; i < fNMaxPrimary ; i++) | |
209 | ||
210 | fPrimary[i] = digit.fPrimary[i] ; | |
211 | ||
212 | Int_t j ; | |
213 | ||
214 | for (j = 0; j< fNMaxiparent ; j++) | |
215 | ||
216 | fIparent[j] = digit.fIparent[j] ; | |
217 | ||
218 | fAmp = digit.fAmp ; | |
219 | ||
220 | fTime = digit.fTime ; | |
221 | ||
222 | fId = digit.fId; | |
223 | ||
224 | fMaxIter = digit.fMaxIter; | |
225 | fIndexInList = digit.fIndexInList ; | |
226 | ||
227 | fNprimary = digit.fNprimary ; | |
228 | ||
229 | fNiparent = digit.fNiparent ; | |
230 | ||
231 | } | |
232 | ||
233 | ||
234 | ||
235 | //____________________________________________________________________________ | |
236 | ||
237 | AliEMCALDigit::~AliEMCALDigit() | |
238 | ||
239 | { | |
240 | ||
241 | // Delete array of primiries if any | |
242 | ||
243 | delete [] fPrimary ; | |
244 | ||
245 | delete [] fIparent ; | |
246 | ||
247 | } | |
248 | ||
249 | ||
250 | ||
251 | //____________________________________________________________________________ | |
252 | ||
253 | Int_t AliEMCALDigit::Compare(const TObject * obj) const | |
254 | ||
255 | { | |
256 | ||
257 | // Compares two digits with respect to its Id | |
258 | ||
259 | // to sort according increasing Id | |
260 | ||
261 | ||
262 | ||
263 | Int_t rv ; | |
264 | ||
265 | ||
266 | ||
267 | AliEMCALDigit * digit = (AliEMCALDigit *)obj ; | |
268 | ||
269 | ||
270 | ||
271 | Int_t iddiff = fId - digit->GetId() ; | |
272 | ||
273 | ||
274 | ||
275 | if ( iddiff > 0 ) | |
276 | ||
277 | rv = 1 ; | |
278 | ||
279 | else if ( iddiff < 0 ) | |
280 | ||
281 | rv = -1 ; | |
282 | ||
283 | else | |
284 | ||
285 | rv = 0 ; | |
286 | ||
287 | ||
288 | ||
289 | return rv ; | |
290 | ||
291 | ||
292 | ||
293 | } | |
294 | ||
295 | ||
296 | ||
297 | //____________________________________________________________________________ | |
298 | ||
299 | const Float_t AliEMCALDigit::GetEta() const | |
300 | ||
301 | { | |
302 | ||
303 | Float_t eta=-10., phi=-10.; | |
304 | ||
305 | Int_t id = GetId(); | |
306 | ||
307 | const AliEMCALGeometry *g = AliEMCALGetter::GetInstance()->EMCALGeometry(); | |
308 | ||
309 | g->EtaPhiFromIndex(id,eta,phi); | |
310 | ||
311 | return eta ; | |
312 | ||
313 | } | |
314 | ||
315 | ||
316 | ||
317 | //____________________________________________________________________________ | |
318 | ||
319 | const Float_t AliEMCALDigit::GetPhi() const | |
320 | ||
321 | { | |
322 | ||
323 | Float_t eta=-10., phi=-10.; | |
324 | ||
325 | Int_t id = GetId(); | |
326 | ||
327 | const AliEMCALGeometry *g = AliEMCALGetter::GetInstance()->EMCALGeometry(); | |
328 | ||
329 | g->EtaPhiFromIndex(id,eta,phi); | |
330 | ||
331 | return phi ; | |
332 | ||
333 | } | |
334 | ||
335 | ||
336 | ||
337 | //____________________________________________________________________________ | |
338 | ||
339 | Int_t AliEMCALDigit::GetPrimary(Int_t index) const | |
340 | ||
341 | { | |
342 | ||
343 | // retrieves the primary particle number given its index in the list | |
344 | ||
345 | Int_t rv = -1 ; | |
346 | ||
347 | if ( index <= fNprimary && index > 0){ | |
348 | ||
349 | rv = fPrimary[index-1] ; | |
350 | ||
351 | } | |
352 | ||
353 | ||
354 | ||
355 | return rv ; | |
356 | ||
357 | ||
358 | ||
359 | } | |
360 | ||
361 | ||
362 | ||
363 | //____________________________________________________________________________ | |
364 | ||
365 | Int_t AliEMCALDigit::GetIparent(Int_t index) const | |
366 | ||
367 | { | |
368 | ||
369 | // retrieves the primary particle number given its index in the list | |
370 | ||
371 | Int_t rv = -1 ; | |
372 | ||
373 | if ( index <= fNiparent ){ | |
374 | ||
375 | rv = fIparent[index-1] ; | |
376 | ||
377 | } | |
378 | ||
379 | ||
380 | ||
381 | return rv ; | |
382 | ||
383 | ||
384 | ||
385 | } | |
386 | ||
387 | ||
388 | ||
389 | //______________________________________________________________________ | |
390 | ||
391 | const Bool_t AliEMCALDigit::IsInPreShower() const | |
392 | ||
393 | { | |
394 | ||
395 | Bool_t rv = kFALSE ; | |
396 | ||
397 | const AliEMCALGeometry * geom = AliEMCALGetter::GetInstance()->EMCALGeometry() ; | |
398 | ||
399 | if( GetId() > (geom->GetNZ() * geom->GetNPhi() )) | |
400 | ||
401 | rv = kTRUE; | |
402 | ||
403 | return rv; | |
404 | ||
405 | } | |
406 | ||
407 | ||
408 | ||
409 | //____________________________________________________________________________ | |
410 | ||
411 | void AliEMCALDigit::ShiftPrimary(Int_t shift){ | |
412 | ||
413 | //shifts primary nimber to BIG offset, to separate primary in different TreeK | |
414 | ||
415 | Int_t index ; | |
416 | ||
417 | for(index = 0; index <fNprimary; index++ ){ | |
418 | ||
419 | fPrimary[index] = fPrimary[index]+ shift * 10000000 ;} | |
420 | ||
421 | for(index =0; index <fNiparent; index++){ | |
422 | ||
423 | fIparent[index] = fIparent[index] + shift * 10000000 ;} | |
424 | ||
425 | } | |
426 | ||
427 | //____________________________________________________________________________ | |
428 | ||
429 | Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const | |
430 | ||
431 | { | |
432 | ||
433 | // Two digits are equal if they have the same Id | |
434 | ||
435 | ||
436 | ||
437 | if ( fId == digit.fId ) | |
438 | ||
439 | return kTRUE ; | |
440 | ||
441 | else | |
442 | ||
443 | return kFALSE ; | |
444 | ||
445 | } | |
446 | ||
447 | ||
448 | ||
449 | //____________________________________________________________________________ | |
450 | ||
451 | AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit) | |
452 | ||
453 | { | |
454 | ||
455 | // Adds the amplitude of digits and completes the list of primary particles | |
456 | ||
457 | // if amplitude is larger than | |
458 | ||
459 | ||
460 | ||
461 | fAmp += digit.fAmp ; | |
462 | ||
463 | if(fTime > digit.fTime) | |
464 | ||
465 | fTime = digit.fTime ; | |
466 | ||
467 | ||
468 | ||
469 | Int_t max1 = fNprimary ; | |
470 | ||
471 | Int_t max2 = fNiparent ; | |
472 | ||
473 | Int_t index ; | |
474 | ||
475 | for (index = 0 ; index < digit.fNprimary ; index++){ | |
476 | ||
477 | Bool_t deja = kTRUE ; | |
478 | ||
479 | Int_t old ; | |
480 | ||
481 | for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary? | |
482 | ||
483 | if(fPrimary[old] == digit.fPrimary[index]) | |
484 | ||
485 | deja = kFALSE; | |
486 | ||
487 | } | |
488 | ||
489 | if(deja){ | |
490 | ||
491 | if(max1<fNMaxPrimary){ fPrimary[max1] = digit.fPrimary[index] ; | |
492 | ||
493 | fNprimary++ ; | |
494 | ||
495 | max1++;} | |
496 | ||
497 | if(fNprimary==fNMaxPrimary) { | |
498 | ||
499 | fNMaxPrimary += fMaxIter ; | |
500 | Int_t tempo[fNprimary] ; | |
501 | Int_t i ; | |
502 | for (i=0; i < fNprimary; i++) | |
503 | tempo[i] = fPrimary[i] ; | |
504 | delete [] fPrimary ; | |
505 | fPrimary = new Int_t[fNMaxPrimary]; | |
506 | for (i=0; i < fNprimary; i++) | |
507 | fPrimary[i] = tempo[i] ; | |
508 | //delete [] tempo ; | |
509 | for (i=fNprimary; i < fNMaxPrimary; i++) | |
510 | fPrimary[i] = -1 ; | |
511 | cout << "AliEMCALDigit >> NMaxPrimary has been increased to "<< fNMaxPrimary << endl ; | |
512 | ||
513 | return *this ; | |
514 | ||
515 | } | |
516 | ||
517 | } | |
518 | ||
519 | } | |
520 | ||
521 | ||
522 | ||
523 | for (index = 0 ; index < digit.fNiparent ; index++){ | |
524 | ||
525 | Bool_t dejavu = kTRUE ; | |
526 | ||
527 | Int_t old ; | |
528 | ||
529 | for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary? | |
530 | ||
531 | if(fIparent[old] == digit.fIparent[index]) | |
532 | ||
533 | dejavu = kFALSE; | |
534 | ||
535 | } | |
536 | ||
537 | if(dejavu){ | |
538 | ||
539 | if(max2<fNMaxiparent){ fIparent[max2] = digit.fIparent[index] ; | |
540 | ||
541 | fNiparent++ ; | |
542 | ||
543 | max2++;} | |
544 | ||
545 | if(fNiparent==fNMaxiparent) { | |
546 | ||
547 | fNMaxiparent += fMaxIter ; | |
548 | Int_t tempo[fNiparent] ; | |
549 | Int_t i ; | |
550 | for (i=0; i < fNiparent; i++) | |
551 | tempo[i] = fIparent[i] ; | |
552 | delete [] fIparent ; | |
553 | fIparent = new Int_t[fNMaxiparent]; | |
554 | for (i=0; i < fNiparent; i++) | |
555 | fIparent[i] = tempo[i] ; | |
556 | // delete [] tempo ; | |
557 | for (i=fNiparent; i < fNMaxiparent; i++) | |
558 | fIparent[i] = -1 ; | |
559 | cout << "AliEMCALDigit >> Increasing fNMaxiparent to " << fNMaxiparent << endl ; | |
560 | ||
561 | return *this ; | |
562 | ||
563 | } | |
564 | ||
565 | } | |
566 | ||
567 | } | |
568 | ||
569 | ||
570 | ||
571 | return *this ; | |
572 | ||
573 | } | |
574 | ||
575 | ||
576 | ||
577 | //____________________________________________________________________________ | |
578 | ||
579 | AliEMCALDigit& AliEMCALDigit::operator*(Float_t factor) | |
580 | ||
581 | { | |
582 | ||
583 | // Multiplies the amplitude by a factor | |
584 | ||
585 | ||
586 | ||
587 | Float_t tempo = static_cast<Float_t>(fAmp) ; | |
588 | ||
589 | tempo *= factor ; | |
590 | ||
591 | fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ; | |
592 | ||
593 | return *this ; | |
594 | ||
595 | } | |
596 | ||
597 | ||
598 | ||
599 | //____________________________________________________________________________ | |
600 | ||
601 | ostream& operator << ( ostream& out , const AliEMCALDigit & digit) | |
602 | ||
603 | { | |
604 | ||
605 | // Prints the data of the digit | |
606 | ||
607 | ||
608 | ||
609 | out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ; | |
610 | ||
611 | Int_t i,j ; | |
612 | ||
613 | for(i=0;i<digit.fNprimary;i++) | |
614 | ||
615 | out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ; | |
616 | ||
617 | ||
618 | ||
619 | for(j=0;j<digit.fNiparent;j++) | |
620 | ||
621 | out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ; | |
622 | ||
623 | out << "Position in list = " << digit.fIndexInList << endl ; | |
624 | ||
625 | return out ; | |
626 | ||
627 | } | |
628 | ||
629 | ||
630 | ||
631 | ||
632 |