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()
59 //____________________________________________________________________________
60 AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index)
66 fPrimary = new Int_t[fNMaxPrimary] ;
67 fIparent = new Int_t[fNMaxiparent] ;
71 fIndexInList = index ;
75 fPrimary[0] = primary ;
77 fIparent[0] = iparent ;
79 else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
87 for ( i = 1; i < fNMaxPrimary ; i++)
90 for ( i =1; i< fNMaxiparent ; i++)
94 //____________________________________________________________________________
95 AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) : AliDigitNew(digit)
100 fNMaxPrimary = digit.fNMaxPrimary ;
101 fNMaxiparent = digit.fNMaxiparent ;
102 fPrimary = new Int_t[fNMaxPrimary] ;
103 fIparent = new Int_t[fNMaxiparent] ;
105 for ( i = 0; i < fNMaxPrimary ; i++)
106 fPrimary[i] = digit.fPrimary[i] ;
108 for (j = 0; j< fNMaxiparent ; j++)
109 fIparent[j] = digit.fIparent[j] ;
111 fTime = digit.fTime ;
113 fMaxIter = digit.fMaxIter;
114 fIndexInList = digit.fIndexInList ;
115 fNprimary = digit.fNprimary ;
116 fNiparent = digit.fNiparent ;
119 //____________________________________________________________________________
120 AliEMCALDigit::~AliEMCALDigit()
122 // Delete array of primiries if any
127 //____________________________________________________________________________
128 Int_t AliEMCALDigit::Compare(const TObject * obj) const
130 // Compares two digits with respect to its Id
131 // to sort according increasing Id
135 AliEMCALDigit * digit = (AliEMCALDigit *)obj ;
137 Int_t iddiff = fId - digit->GetId() ;
141 else if ( iddiff < 0 )
150 //____________________________________________________________________________
151 Float_t AliEMCALDigit::GetEta() const
153 Float_t eta=-10., phi=-10.;
155 const AliEMCALGeometry *g = AliEMCALGetter::Instance()->EMCALGeometry();
156 g->EtaPhiFromIndex(id,eta,phi);
160 //____________________________________________________________________________
161 Float_t AliEMCALDigit::GetPhi() const
163 Float_t eta=-10., phi=-10.;
165 const AliEMCALGeometry *g = AliEMCALGetter::Instance()->EMCALGeometry();
166 g->EtaPhiFromIndex(id,eta,phi);
170 //____________________________________________________________________________
171 Int_t AliEMCALDigit::GetPrimary(Int_t index) const
173 // retrieves the primary particle number given its index in the list
175 if ( (index <= fNprimary) && (index > 0)){
176 rv = fPrimary[index-1] ;
183 //____________________________________________________________________________
184 Int_t AliEMCALDigit::GetIparent(Int_t index) const
186 // retrieves the primary particle number given its index in the list
188 if ( index <= fNiparent ){
189 rv = fIparent[index-1] ;
196 //____________________________________________________________________________
197 void AliEMCALDigit::ShiftPrimary(Int_t shift){
198 //shifts primary number to BIG offset, to separate primary in different TreeK
200 for(index = 0; index <fNprimary; index++ ){
201 fPrimary[index] = fPrimary[index]+ shift * 10000000 ;}
202 for(index =0; index <fNiparent; index++){
203 fIparent[index] = fIparent[index] + shift * 10000000 ;}
205 //____________________________________________________________________________
206 Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const
208 // Two digits are equal if they have the same Id
210 if ( fId == digit.fId )
216 //____________________________________________________________________________
217 AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit)
219 // Adds the amplitude of digits and completes the list of primary particles
220 // if amplitude is larger than
223 if(fTime > digit.fTime)
224 fTime = digit.fTime ;
226 Int_t max1 = fNprimary ;
227 Int_t max2 = fNiparent ;
229 for (index = 0 ; index < digit.fNprimary ; index++){
230 Bool_t deja = kTRUE ;
232 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
233 if(fPrimary[old] == digit.fPrimary[index])
237 if(max1<fNMaxPrimary){ fPrimary[max1] = digit.fPrimary[index] ;
240 if(fNprimary==fNMaxPrimary) {
242 TString mess = " NMaxPrimary = " ;
243 mess += fNMaxPrimary ;
244 mess += " is too small" ;
245 Fatal("AliEMCALDigit::Operator+ -->" , mess.Data()) ;
251 for (index = 0 ; index < digit.fNiparent ; index++){
252 Bool_t dejavu = kTRUE ;
254 for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary?
255 if(fIparent[old] == digit.fIparent[index])
259 if(max2<fNMaxiparent){ fIparent[max2] = digit.fIparent[index] ;
262 if(fNiparent==fNMaxiparent) {
264 TString mess = " NMaxiparent = " ;
265 mess += fNMaxiparent ;
266 mess += " is too small" ;
267 Fatal("AliEMCALDigit::Operator+ -->", mess.Data()) ;
276 //____________________________________________________________________________
277 AliEMCALDigit& AliEMCALDigit::operator*(Float_t factor)
279 // Multiplies the amplitude by a factor
281 Float_t tempo = static_cast<Float_t>(fAmp) ;
283 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
287 //____________________________________________________________________________
288 ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
290 // Prints the data of the digit
292 out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
294 for(i=0;i<digit.fNprimary;i++)
295 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
297 for(j=0;j<digit.fNiparent;j++)
298 out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ;
299 out << "Position in list = " << digit.fIndexInList << endl ;