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()
60 //____________________________________________________________________________
61 AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index)
67 fPrimary = new Int_t[fNMaxPrimary] ;
68 fIparent = new Int_t[fNMaxiparent] ;
72 fIndexInList = index ;
76 fPrimary[0] = primary ;
78 fIparent[0] = iparent ;
80 else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
88 for ( i = 1; i < fNMaxPrimary ; i++)
91 for ( i =1; i< fNMaxiparent ; i++)
95 //____________________________________________________________________________
96 AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit)
101 fNMaxPrimary = digit.fNMaxPrimary ;
102 fNMaxiparent = digit.fNMaxiparent ;
103 fPrimary = new Int_t[fNMaxPrimary] ;
104 fIparent = new Int_t[fNMaxiparent] ;
106 for ( i = 0; i < fNMaxPrimary ; i++)
107 fPrimary[i] = digit.fPrimary[i] ;
109 for (j = 0; j< fNMaxiparent ; j++)
110 fIparent[j] = digit.fIparent[j] ;
112 fTime = digit.fTime ;
114 fMaxIter = digit.fMaxIter;
115 fIndexInList = digit.fIndexInList ;
116 fNprimary = digit.fNprimary ;
117 fNiparent = digit.fNiparent ;
120 //____________________________________________________________________________
121 AliEMCALDigit::~AliEMCALDigit()
123 // Delete array of primiries if any
128 //____________________________________________________________________________
129 Int_t AliEMCALDigit::Compare(const TObject * obj) const
131 // Compares two digits with respect to its Id
132 // to sort according increasing Id
136 AliEMCALDigit * digit = (AliEMCALDigit *)obj ;
138 Int_t iddiff = fId - digit->GetId() ;
142 else if ( iddiff < 0 )
151 //____________________________________________________________________________
152 const Float_t AliEMCALDigit::GetEta() const
154 Float_t eta=-10., phi=-10.;
156 const AliEMCALGeometry *g = AliEMCALGetter::GetInstance()->EMCALGeometry();
157 g->EtaPhiFromIndex(id,eta,phi);
161 //____________________________________________________________________________
162 const Float_t AliEMCALDigit::GetPhi() const
164 Float_t eta=-10., phi=-10.;
166 const AliEMCALGeometry *g = AliEMCALGetter::GetInstance()->EMCALGeometry();
167 g->EtaPhiFromIndex(id,eta,phi);
171 //____________________________________________________________________________
172 Int_t AliEMCALDigit::GetPrimary(Int_t index) const
174 // retrieves the primary particle number given its index in the list
176 if ( index <= fNprimary && index > 0){
177 rv = fPrimary[index-1] ;
184 //____________________________________________________________________________
185 Int_t AliEMCALDigit::GetIparent(Int_t index) const
187 // retrieves the primary particle number given its index in the list
189 if ( index <= fNiparent ){
190 rv = fIparent[index-1] ;
197 //____________________________________________________________________________
198 void AliEMCALDigit::ShiftPrimary(Int_t shift){
199 //shifts primary nimber to BIG offset, to separate primary in different TreeK
201 for(index = 0; index <fNprimary; index++ ){
202 fPrimary[index] = fPrimary[index]+ shift * 10000000 ;}
203 for(index =0; index <fNiparent; index++){
204 fIparent[index] = fIparent[index] + shift * 10000000 ;}
206 //____________________________________________________________________________
207 Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const
209 // Two digits are equal if they have the same Id
211 if ( fId == digit.fId )
217 //____________________________________________________________________________
218 AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit)
220 // Adds the amplitude of digits and completes the list of primary particles
221 // if amplitude is larger than
224 if(fTime > digit.fTime)
225 fTime = digit.fTime ;
227 Int_t max1 = fNprimary ;
228 Int_t max2 = fNiparent ;
230 for (index = 0 ; index < digit.fNprimary ; index++){
231 Bool_t deja = kTRUE ;
233 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
234 if(fPrimary[old] == digit.fPrimary[index])
238 if(max1<fNMaxPrimary){ fPrimary[max1] = digit.fPrimary[index] ;
241 if(fNprimary==fNMaxPrimary) {
243 TString mess = " NMaxPrimary = " ;
244 mess += fNMaxPrimary ;
245 mess += " is too small" ;
246 Fatal("AliEMCALDigit::Operator+ -->" , mess.Data()) ;
252 for (index = 0 ; index < digit.fNiparent ; index++){
253 Bool_t dejavu = kTRUE ;
255 for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary?
256 if(fIparent[old] == digit.fIparent[index])
260 if(max2<fNMaxiparent){ fIparent[max2] = digit.fIparent[index] ;
263 if(fNiparent==fNMaxiparent) {
265 TString mess = " NMaxiparent = " ;
266 mess += fNMaxiparent ;
267 mess += " is too small" ;
268 Fatal("AliEMCALDigit::Operator+ -->", mess.Data()) ;
277 //____________________________________________________________________________
278 AliEMCALDigit& AliEMCALDigit::operator*(Float_t factor)
280 // Multiplies the amplitude by a factor
282 Float_t tempo = static_cast<Float_t>(fAmp) ;
284 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
288 //____________________________________________________________________________
289 ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
291 // Prints the data of the digit
293 out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
295 for(i=0;i<digit.fNprimary;i++)
296 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
298 for(j=0;j<digit.fNiparent;j++)
299 out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ;
300 out << "Position in list = " << digit.fIndexInList << endl ;