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"
40 ClassImp(AliEMCALDigit)
42 //____________________________________________________________________________
43 AliEMCALDigit::AliEMCALDigit() :
60 //____________________________________________________________________________
61 AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index)
65 // data memebrs of the base class (AliNewDigit)
68 fIndexInList = index ;
73 fPrimary = new Int_t[fNMaxPrimary] ;
74 fIparent = new Int_t[fNMaxiparent] ;
80 fPrimary[0] = primary ;
82 fIparent[0] = iparent ;
84 else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
92 for ( i = 1; i < fNMaxPrimary ; i++)
95 for ( i =1; i< fNMaxiparent ; i++)
99 //____________________________________________________________________________
100 AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) : AliDigitNew(digit)
104 // data memebrs of the base class (AliNewDigit)
107 fIndexInList = digit.fIndexInList ;
110 fNMaxPrimary = digit.fNMaxPrimary ;
111 fNMaxiparent = digit.fNMaxiparent ;
112 fPrimary = new Int_t[fNMaxPrimary] ;
113 fIparent = new Int_t[fNMaxiparent] ;
115 for ( i = 0; i < fNMaxPrimary ; i++)
116 fPrimary[i] = digit.fPrimary[i] ;
118 for (j = 0; j< fNMaxiparent ; j++)
119 fIparent[j] = digit.fIparent[j] ;
120 fTime = digit.fTime ;
121 fTimeR = digit.fTimeR ;
122 fMaxIter = digit.fMaxIter;
123 fNprimary = digit.fNprimary ;
124 fNiparent = digit.fNiparent ;
127 //____________________________________________________________________________
128 AliEMCALDigit::~AliEMCALDigit()
130 // Delete array of primiries if any
135 //____________________________________________________________________________
136 Int_t AliEMCALDigit::Compare(const TObject * obj) const
138 // Compares two digits with respect to its Id
139 // to sort according increasing Id
143 AliEMCALDigit * digit = (AliEMCALDigit *)obj ;
145 Int_t iddiff = fId - digit->GetId() ;
149 else if ( iddiff < 0 )
158 //____________________________________________________________________________
159 Float_t AliEMCALDigit::GetEta() const
161 //return pseudorapidity for this digit
162 // should be change in EMCALGeometry - 19-nov-04
163 Float_t eta=-10., phi=-10.;
165 const AliEMCALGeometry *g = AliEMCALGeometry::GetInstance();
166 g->EtaPhiFromIndex(id,eta,phi);
170 //____________________________________________________________________________
171 Float_t AliEMCALDigit::GetPhi() const
173 //return phi coordinate of digit
174 // should be change in EMCALGeometry - 19-nov-04
175 Float_t eta=-10., phi=-10.;
177 const AliEMCALGeometry *g = AliEMCALGeometry::GetInstance();
178 g->EtaPhiFromIndex(id,eta,phi);
182 //____________________________________________________________________________
183 Int_t AliEMCALDigit::GetPrimary(Int_t index) const
185 // retrieves the primary particle number given its index in the list
187 if ( (index <= fNprimary) && (index > 0)){
188 rv = fPrimary[index-1] ;
195 //____________________________________________________________________________
196 Int_t AliEMCALDigit::GetIparent(Int_t index) const
198 // retrieves the primary particle number given its index in the list
200 if ( index <= fNiparent ){
201 rv = fIparent[index-1] ;
208 //____________________________________________________________________________
209 void AliEMCALDigit::ShiftPrimary(Int_t shift){
210 //shifts primary number to BIG offset, to separate primary in different TreeK
212 for(index = 0; index <fNprimary; index++ ){
213 fPrimary[index] = fPrimary[index]+ shift * 10000000 ;}
214 for(index =0; index <fNiparent; index++){
215 fIparent[index] = fIparent[index] + shift * 10000000 ;}
217 //____________________________________________________________________________
218 Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const
220 // Two digits are equal if they have the same Id
222 if ( fId == digit.fId )
228 //____________________________________________________________________________
229 AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit)
231 // Adds the amplitude of digits and completes the list of primary particles
232 // if amplitude is larger than
235 if(fTime > digit.fTime)
236 fTime = digit.fTime ;
239 Int_t max1 = fNprimary ;
240 Int_t max2 = fNiparent ;
242 for (index = 0 ; index < digit.fNprimary ; index++){
243 Bool_t deja = kTRUE ;
245 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
246 if(fPrimary[old] == digit.fPrimary[index])
250 if(max1<fNMaxPrimary){ fPrimary[max1] = digit.fPrimary[index] ;
253 if(fNprimary==fNMaxPrimary) {
255 TString mess = " NMaxPrimary = " ;
256 mess += fNMaxPrimary ;
257 mess += " is too small" ;
258 Fatal("AliEMCALDigit::Operator+ -->" , mess.Data()) ;
264 for (index = 0 ; index < digit.fNiparent ; index++){
265 Bool_t dejavu = kTRUE ;
267 for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary?
268 if(fIparent[old] == digit.fIparent[index])
272 if(max2<fNMaxiparent){ fIparent[max2] = digit.fIparent[index] ;
275 if(fNiparent==fNMaxiparent) {
277 TString mess = " NMaxiparent = " ;
278 mess += fNMaxiparent ;
279 mess += " is too small" ;
280 Fatal("AliEMCALDigit::Operator+ -->", mess.Data()) ;
289 //____________________________________________________________________________
290 AliEMCALDigit& AliEMCALDigit::operator*(Float_t factor)
292 // Multiplies the amplitude by a factor
294 Float_t tempo = static_cast<Float_t>(fAmp) ;
296 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
300 //____________________________________________________________________________
301 ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
303 // Prints the data of the digit
305 out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
307 for(i=0;i<digit.fNprimary;i++)
308 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
310 for(j=0;j<digit.fNiparent;j++)
311 out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ;
312 out << "Position in list = " << digit.fIndexInList << endl ;