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 ---
33 #include <Riostream.h>
35 // --- AliRoot header files ---
37 #include "AliEMCALDigit.h"
38 #include "AliEMCALGeometry.h"
39 #include "AliEMCALGetter.h"
42 ClassImp(AliEMCALDigit)
44 //____________________________________________________________________________
45 AliEMCALDigit::AliEMCALDigit()
61 //____________________________________________________________________________
62 AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index)
68 fPrimary = new Int_t[fNMaxPrimary] ;
69 fIparent = new Int_t[fNMaxiparent] ;
74 fIndexInList = index ;
78 fPrimary[0] = primary ;
80 fIparent[0] = iparent ;
82 else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
90 for ( i = 1; i < fNMaxPrimary ; i++)
93 for ( i =1; i< fNMaxiparent ; i++)
97 //____________________________________________________________________________
98 AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) : AliDigitNew(digit)
103 fNMaxPrimary = digit.fNMaxPrimary ;
104 fNMaxiparent = digit.fNMaxiparent ;
105 fPrimary = new Int_t[fNMaxPrimary] ;
106 fIparent = new Int_t[fNMaxiparent] ;
108 for ( i = 0; i < fNMaxPrimary ; i++)
109 fPrimary[i] = digit.fPrimary[i] ;
111 for (j = 0; j< fNMaxiparent ; j++)
112 fIparent[j] = digit.fIparent[j] ;
114 fTime = digit.fTime ;
115 fTimeR = digit.fTimeR ;
117 fMaxIter = digit.fMaxIter;
118 fIndexInList = digit.fIndexInList ;
119 fNprimary = digit.fNprimary ;
120 fNiparent = digit.fNiparent ;
123 //____________________________________________________________________________
124 AliEMCALDigit::~AliEMCALDigit()
126 // Delete array of primiries if any
131 //____________________________________________________________________________
132 Int_t AliEMCALDigit::Compare(const TObject * obj) const
134 // Compares two digits with respect to its Id
135 // to sort according increasing Id
139 AliEMCALDigit * digit = (AliEMCALDigit *)obj ;
141 Int_t iddiff = fId - digit->GetId() ;
145 else if ( iddiff < 0 )
154 //____________________________________________________________________________
155 Float_t AliEMCALDigit::GetEta() const
157 Float_t eta=-10., phi=-10.;
159 const AliEMCALGeometry *g = AliEMCALGetter::Instance()->EMCALGeometry();
160 g->EtaPhiFromIndex(id,eta,phi);
164 //____________________________________________________________________________
165 Float_t AliEMCALDigit::GetPhi() const
167 Float_t eta=-10., phi=-10.;
169 const AliEMCALGeometry *g = AliEMCALGetter::Instance()->EMCALGeometry();
170 g->EtaPhiFromIndex(id,eta,phi);
174 //____________________________________________________________________________
175 Int_t AliEMCALDigit::GetPrimary(Int_t index) const
177 // retrieves the primary particle number given its index in the list
179 if ( (index <= fNprimary) && (index > 0)){
180 rv = fPrimary[index-1] ;
187 //____________________________________________________________________________
188 Int_t AliEMCALDigit::GetIparent(Int_t index) const
190 // retrieves the primary particle number given its index in the list
192 if ( index <= fNiparent ){
193 rv = fIparent[index-1] ;
200 //____________________________________________________________________________
201 void AliEMCALDigit::ShiftPrimary(Int_t shift){
202 //shifts primary number 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 ;
231 Int_t max1 = fNprimary ;
232 Int_t max2 = fNiparent ;
234 for (index = 0 ; index < digit.fNprimary ; index++){
235 Bool_t deja = kTRUE ;
237 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
238 if(fPrimary[old] == digit.fPrimary[index])
242 if(max1<fNMaxPrimary){ fPrimary[max1] = digit.fPrimary[index] ;
245 if(fNprimary==fNMaxPrimary) {
247 TString mess = " NMaxPrimary = " ;
248 mess += fNMaxPrimary ;
249 mess += " is too small" ;
250 Fatal("AliEMCALDigit::Operator+ -->" , mess.Data()) ;
256 for (index = 0 ; index < digit.fNiparent ; index++){
257 Bool_t dejavu = kTRUE ;
259 for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary?
260 if(fIparent[old] == digit.fIparent[index])
264 if(max2<fNMaxiparent){ fIparent[max2] = digit.fIparent[index] ;
267 if(fNiparent==fNMaxiparent) {
269 TString mess = " NMaxiparent = " ;
270 mess += fNMaxiparent ;
271 mess += " is too small" ;
272 Fatal("AliEMCALDigit::Operator+ -->", mess.Data()) ;
281 //____________________________________________________________________________
282 AliEMCALDigit& AliEMCALDigit::operator*(Float_t factor)
284 // Multiplies the amplitude by a factor
286 Float_t tempo = static_cast<Float_t>(fAmp) ;
288 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
292 //____________________________________________________________________________
293 ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
295 // Prints the data of the digit
297 out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
299 for(i=0;i<digit.fNprimary;i++)
300 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
302 for(j=0;j<digit.fNiparent;j++)
303 out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ;
304 out << "Position in list = " << digit.fIndexInList << endl ;