1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
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
25 //*-- Author: Sahal Yacoob (LBL)
26 // based on : AliPHOSDigit
27 //__________________________________________________________________________
29 // --- ROOT system ---
31 // --- Standard library ---
35 // --- AliRoot header files ---
37 #include "AliEMCALDigit.h"
38 #include "AliEMCALGeometry.h"
39 #include "AliEMCALGetter.h"
42 ClassImp(AliEMCALDigit)
44 //____________________________________________________________________________
45 AliEMCALDigit::AliEMCALDigit()
53 fNMaxiparent = fNMaxPrimary*10;
54 fPrimary = new Int_t[fNMaxPrimary] ;
55 fIparent = new Int_t[fNMaxiparent] ;
58 //____________________________________________________________________________
59 AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index)
64 fNMaxiparent = fNMaxPrimary*10;
65 fPrimary = new Int_t[fNMaxPrimary] ;
66 fIparent = new Int_t[fNMaxiparent] ;
70 fIndexInList = index ;
73 fPrimary[0] = primary ;
75 fIparent[0] = iparent ;
78 else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
86 for ( i = 1; i < fNMaxPrimary ; i++)
89 for ( Int_t j =1; j< fNMaxiparent ; j++)
93 //____________________________________________________________________________
94 AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit)
99 fNMaxPrimary = digit.fNMaxPrimary ;
100 fNMaxiparent = digit.fNMaxiparent ;
101 fPrimary = new Int_t[fNMaxPrimary] ;
102 fIparent = new Int_t[fNMaxiparent] ;
104 for ( i = 0; i < fNMaxPrimary ; i++)
105 fPrimary[i] = digit.fPrimary[i] ;
107 for (j = 0; j< fNMaxiparent ; j++)
108 fIparent[j] = digit.fIparent[j] ;
110 fTime = digit.fTime ;
112 fIndexInList = digit.fIndexInList ;
113 fNprimary = digit.fNprimary ;
114 fNiparent = digit.fNiparent ;
117 //____________________________________________________________________________
118 AliEMCALDigit::~AliEMCALDigit()
120 // Delete array of primiries if any
125 //____________________________________________________________________________
126 Int_t AliEMCALDigit::Compare(const TObject * obj) const
128 // Compares two digits with respect to its Id
129 // to sort according increasing Id
133 AliEMCALDigit * digit = (AliEMCALDigit *)obj ;
135 Int_t iddiff = fId - digit->GetId() ;
139 else if ( iddiff < 0 )
148 //____________________________________________________________________________
149 const Float_t AliEMCALDigit::GetEta() const
151 Float_t eta=-10., phi=-10.;
152 AliEMCALGeometry::GetInstance()->EtaPhiFromIndex(fId,eta,phi);
156 //____________________________________________________________________________
157 const Float_t AliEMCALDigit::GetPhi() const
159 Float_t eta=-10., phi=-10.;
160 AliEMCALGeometry::GetInstance()->EtaPhiFromIndex(fId,eta,phi);
164 //____________________________________________________________________________
165 Int_t AliEMCALDigit::GetPrimary(Int_t index) const
167 // retrieves the primary particle number given its index in the list
169 if ( index <= fNprimary && index > 0){
170 rv = fPrimary[index-1] ;
177 //____________________________________________________________________________
178 Int_t AliEMCALDigit::GetIparent(Int_t index) const
180 // retrieves the primary particle number given its index in the list
182 if ( index <= fNiparent ){
183 rv = fIparent[index-1] ;
190 //______________________________________________________________________
191 const Bool_t AliEMCALDigit::IsInPreShower() const
194 const AliEMCALGeometry * geom = AliEMCALGetter::GetInstance()->EMCALGeometry() ;
195 if( GetId() > (geom->GetNZ() * geom->GetNPhi() ))
200 //____________________________________________________________________________
201 void AliEMCALDigit::ShiftPrimary(Int_t shift){
202 //shifts primary nimber to BIG offset, to separate primary in different TreeK
204 for(index = 0; index <fNprimary; index++ ){
205 fPrimary[index] = fPrimary[index]+ shift * 10000000 ;}
206 for(index =0; index <fNiparent; index++){
207 fIparent[index] = fIparent[index] + shift * 10000000 ;}
209 //____________________________________________________________________________
210 Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const
212 // Two digits are equal if they have the same Id
214 if ( fId == digit.fId )
220 //____________________________________________________________________________
221 AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit)
223 // Adds the amplitude of digits and completes the list of primary particles
224 // if amplitude is larger than
227 if(fTime > digit.fTime)
228 fTime = digit.fTime ;
230 Int_t max1 = fNprimary ;
231 Int_t max2 = fNiparent ;
233 for (index = 0 ; index < digit.fNprimary ; index++){
234 Bool_t deja = kTRUE ;
236 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
237 if(fPrimary[old] == (digit.fPrimary)[index])
241 fPrimary[fNprimary] = (digit.fPrimary)[index] ;
243 if(fNprimary>fNMaxPrimary) {
244 cout << "AliEMCALDigit >> Increase NMaxPrimary "<< endl ;
250 for (index = 0 ; index < digit.fNiparent ; index++){
251 Bool_t dejavu = kTRUE ;
253 for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary?
254 if(fIparent[old] == (digit.fIparent)[index])
258 fIparent[fNiparent] = (digit.fIparent)[index] ;
260 if(fNiparent>fNMaxiparent) {
261 cout << "AliEMCALDigit >> Increase NMaxiparent "<< endl ;
270 //____________________________________________________________________________
271 ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
273 // Prints the data of the digit
275 out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
277 for(i=0;i<digit.fNprimary;i++)
278 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
280 for(j=0;j<digit.fNiparent;j++)
281 out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ;
282 out << "Position in list = " << digit.fIndexInList << endl ;