1 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * Author: The ALICE Off-line Project. *
9 * Contributors are mentioned in the code where appropriate. *
13 * Permission to use, copy, modify and distribute this software and its *
15 * documentation strictly for non-commercial purposes is hereby granted *
17 * without fee, provided that the above copyright notice appears in all *
19 * copies and that both the copyright notice and this permission notice *
21 * appear in the supporting documentation. The authors make no claims *
23 * about the suitability of this software for any purpose. It is *
25 * provided "as is" without express or implied warranty. *
27 **************************************************************************/
35 //_________________________________________________________________________
39 // A Digit is the sum of the energy lost in an EMCAL Tower
41 // It also stores information on Primary, and enterring particle
43 // tracknumbers Digits are created using AliEMCALSDigitizer, followed
45 // by AliEMCALDigitizer
49 //*-- Author: Sahal Yacoob (LBL)
51 // based on : AliPHOSDigit
53 //__________________________________________________________________________
57 // --- ROOT system ---
61 // --- Standard library ---
69 // --- AliRoot header files ---
73 #include "AliEMCALDigit.h"
75 #include "AliEMCALGeometry.h"
77 #include "AliEMCALGetter.h"
83 ClassImp(AliEMCALDigit)
87 //____________________________________________________________________________
89 AliEMCALDigit::AliEMCALDigit()
117 //____________________________________________________________________________
119 AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index)
123 // ctor with all data
131 fPrimary = new Int_t[fNMaxPrimary] ;
133 fIparent = new Int_t[fNMaxiparent] ;
141 fIndexInList = index ;
148 fPrimary[0] = primary ;
152 fIparent[0] = iparent ;
156 else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
172 for ( i = 1; i < fNMaxPrimary ; i++)
178 for ( i =1; i< fNMaxiparent ; i++)
186 //____________________________________________________________________________
188 AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit)
198 fNMaxPrimary = digit.fNMaxPrimary ;
200 fNMaxiparent = digit.fNMaxiparent ;
202 fPrimary = new Int_t[fNMaxPrimary] ;
204 fIparent = new Int_t[fNMaxiparent] ;
208 for ( i = 0; i < fNMaxPrimary ; i++)
210 fPrimary[i] = digit.fPrimary[i] ;
214 for (j = 0; j< fNMaxiparent ; j++)
216 fIparent[j] = digit.fIparent[j] ;
220 fTime = digit.fTime ;
224 fMaxIter = digit.fMaxIter;
225 fIndexInList = digit.fIndexInList ;
227 fNprimary = digit.fNprimary ;
229 fNiparent = digit.fNiparent ;
235 //____________________________________________________________________________
237 AliEMCALDigit::~AliEMCALDigit()
241 // Delete array of primiries if any
251 //____________________________________________________________________________
253 Int_t AliEMCALDigit::Compare(const TObject * obj) const
257 // Compares two digits with respect to its Id
259 // to sort according increasing Id
267 AliEMCALDigit * digit = (AliEMCALDigit *)obj ;
271 Int_t iddiff = fId - digit->GetId() ;
279 else if ( iddiff < 0 )
297 //____________________________________________________________________________
299 const Float_t AliEMCALDigit::GetEta() const
303 Float_t eta=-10., phi=-10.;
307 const AliEMCALGeometry *g = AliEMCALGetter::GetInstance()->EMCALGeometry();
309 g->EtaPhiFromIndex(id,eta,phi);
317 //____________________________________________________________________________
319 const Float_t AliEMCALDigit::GetPhi() const
323 Float_t eta=-10., phi=-10.;
327 const AliEMCALGeometry *g = AliEMCALGetter::GetInstance()->EMCALGeometry();
329 g->EtaPhiFromIndex(id,eta,phi);
337 //____________________________________________________________________________
339 Int_t AliEMCALDigit::GetPrimary(Int_t index) const
343 // retrieves the primary particle number given its index in the list
347 if ( index <= fNprimary && index > 0){
349 rv = fPrimary[index-1] ;
363 //____________________________________________________________________________
365 Int_t AliEMCALDigit::GetIparent(Int_t index) const
369 // retrieves the primary particle number given its index in the list
373 if ( index <= fNiparent ){
375 rv = fIparent[index-1] ;
389 //______________________________________________________________________
391 const Bool_t AliEMCALDigit::IsInPreShower() const
397 const AliEMCALGeometry * geom = AliEMCALGetter::GetInstance()->EMCALGeometry() ;
399 if( GetId() > (geom->GetNZ() * geom->GetNPhi() ))
409 //____________________________________________________________________________
411 void AliEMCALDigit::ShiftPrimary(Int_t shift){
413 //shifts primary nimber to BIG offset, to separate primary in different TreeK
417 for(index = 0; index <fNprimary; index++ ){
419 fPrimary[index] = fPrimary[index]+ shift * 10000000 ;}
421 for(index =0; index <fNiparent; index++){
423 fIparent[index] = fIparent[index] + shift * 10000000 ;}
427 //____________________________________________________________________________
429 Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const
433 // Two digits are equal if they have the same Id
437 if ( fId == digit.fId )
449 //____________________________________________________________________________
451 AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit)
455 // Adds the amplitude of digits and completes the list of primary particles
457 // if amplitude is larger than
463 if(fTime > digit.fTime)
465 fTime = digit.fTime ;
469 Int_t max1 = fNprimary ;
471 Int_t max2 = fNiparent ;
475 for (index = 0 ; index < digit.fNprimary ; index++){
477 Bool_t deja = kTRUE ;
481 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
483 if(fPrimary[old] == digit.fPrimary[index])
491 if(max1<fNMaxPrimary){ fPrimary[max1] = digit.fPrimary[index] ;
497 if(fNprimary==fNMaxPrimary) {
499 fNMaxPrimary += fMaxIter ;
500 Int_t tempo[fNprimary] ;
502 for (i=0; i < fNprimary; i++)
503 tempo[i] = fPrimary[i] ;
505 fPrimary = new Int_t[fNMaxPrimary];
506 for (i=0; i < fNprimary; i++)
507 fPrimary[i] = tempo[i] ;
509 for (i=fNprimary; i < fNMaxPrimary; i++)
511 cout << "AliEMCALDigit >> NMaxPrimary has been increased to "<< fNMaxPrimary << endl ;
523 for (index = 0 ; index < digit.fNiparent ; index++){
525 Bool_t dejavu = kTRUE ;
529 for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary?
531 if(fIparent[old] == digit.fIparent[index])
539 if(max2<fNMaxiparent){ fIparent[max2] = digit.fIparent[index] ;
545 if(fNiparent==fNMaxiparent) {
547 fNMaxiparent += fMaxIter ;
548 Int_t tempo[fNiparent] ;
550 for (i=0; i < fNiparent; i++)
551 tempo[i] = fIparent[i] ;
553 fIparent = new Int_t[fNMaxiparent];
554 for (i=0; i < fNiparent; i++)
555 fIparent[i] = tempo[i] ;
557 for (i=fNiparent; i < fNMaxiparent; i++)
559 cout << "AliEMCALDigit >> Increasing fNMaxiparent to " << fNMaxiparent << endl ;
577 //____________________________________________________________________________
579 AliEMCALDigit& AliEMCALDigit::operator*(Float_t factor)
583 // Multiplies the amplitude by a factor
587 Float_t tempo = static_cast<Float_t>(fAmp) ;
591 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
599 //____________________________________________________________________________
601 ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
605 // Prints the data of the digit
609 out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
613 for(i=0;i<digit.fNprimary;i++)
615 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
619 for(j=0;j<digit.fNiparent;j++)
621 out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ;
623 out << "Position in list = " << digit.fIndexInList << endl ;