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"
41 ClassImp(AliEMCALDigit)
43 //____________________________________________________________________________
44 AliEMCALDigit::AliEMCALDigit()
52 fNMaxiparent = fNMaxPrimary*10;
55 //____________________________________________________________________________
56 AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index)
61 fNMaxiparent = fNMaxPrimary*10;
65 fIndexInList = index ;
68 fPrimary[0] = primary ;
70 fIparent[0] = iparent ;
73 else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
81 for ( i = 1; i < fNMaxPrimary ; i++)
84 for ( Int_t j =1; j< fNMaxiparent ; j++)
88 //____________________________________________________________________________
89 AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit)
94 fNMaxPrimary = digit.fNMaxPrimary ;
95 fNMaxiparent = digit.fNMaxiparent ;
97 for ( i = 0; i < fNMaxPrimary ; i++)
98 fPrimary[i] = digit.fPrimary[i] ;
100 for (j = 0; j< fNMaxiparent ; j++)
101 fIparent[j] = digit.fIparent[j] ;
103 fTime = digit.fTime ;
105 fIndexInList = digit.fIndexInList ;
106 fNprimary = digit.fNprimary ;
107 fNiparent = digit.fNiparent ;
110 //____________________________________________________________________________
111 AliEMCALDigit::~AliEMCALDigit()
113 // Delete array of primiries if any
117 //____________________________________________________________________________
118 Int_t AliEMCALDigit::Compare(const TObject * obj) const
120 // Compares two digits with respect to its Id
121 // to sort according increasing Id
125 AliEMCALDigit * digit = (AliEMCALDigit *)obj ;
127 Int_t iddiff = fId - digit->GetId() ;
131 else if ( iddiff < 0 )
140 //____________________________________________________________________________
141 const Float_t AliEMCALDigit::GetEta() const
143 Float_t eta=-10., phi=-10.;
144 AliEMCALGeometry::GetInstance()->EtaPhiFromIndex(fId,eta,phi);
148 //____________________________________________________________________________
149 const Float_t AliEMCALDigit::GetPhi() const
151 Float_t eta=-10., phi=-10.;
152 AliEMCALGeometry::GetInstance()->EtaPhiFromIndex(fId,eta,phi);
156 //____________________________________________________________________________
157 Int_t AliEMCALDigit::GetPrimary(Int_t index) const
159 // retrieves the primary particle number given its index in the list
161 if ( index <= fNprimary && index > 0){
162 rv = fPrimary[index-1] ;
169 //____________________________________________________________________________
170 Int_t AliEMCALDigit::GetIparent(Int_t index) const
172 // retrieves the primary particle number given its index in the list
174 if ( index <= fNiparent ){
175 rv = fIparent[index-1] ;
183 //____________________________________________________________________________
184 void AliEMCALDigit::ShiftPrimary(Int_t shift){
185 //shifts primary nimber to BIG offset, to separate primary in different TreeK
187 for(index = 0; index <fNprimary; index++ ){
188 fPrimary[index] = fPrimary[index]+ shift * 10000000 ;}
189 for(index =0; index <fNiparent; index++){
190 fIparent[index] = fIparent[index] + shift * 10000000 ;}
192 //____________________________________________________________________________
193 Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const
195 // Two digits are equal if they have the same Id
197 if ( fId == digit.fId )
203 //____________________________________________________________________________
204 AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit)
206 // Adds the amplitude of digits and completes the list of primary particles
207 // if amplitude is larger than
210 if(fTime > digit.fTime)
211 fTime = digit.fTime ;
213 Int_t max1 = fNprimary ;
214 Int_t max2 = fNiparent ;
216 for (index = 0 ; index < digit.fNprimary ; index++){
217 Bool_t deja = kTRUE ;
219 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
220 if(fPrimary[old] == (digit.fPrimary)[index])
224 fPrimary[fNprimary] = (digit.fPrimary)[index] ;
226 if(fNprimary>fNMaxPrimary) {
227 cout << "AliEMCALDigit >> Increase NMaxPrimary "<< endl ;
233 for (index = 0 ; index < digit.fNiparent ; index++){
234 Bool_t dejavu = kTRUE ;
236 for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary?
237 if(fIparent[old] == (digit.fIparent)[index])
241 fIparent[fNiparent] = (digit.fIparent)[index] ;
243 if(fNiparent>fNMaxiparent) {
244 cout << "AliEMCALDigit >> Increase NMaxiparent "<< endl ;
253 //____________________________________________________________________________
254 ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
256 // Prints the data of the digit
258 out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
260 for(i=0;i<digit.fNprimary;i++)
261 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
263 for(j=0;j<digit.fNiparent;j++)
264 out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ;
265 out << "Position in list = " << digit.fIndexInList << endl ;