]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALDigit.cxx
Avoid compiler warnings.
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALDigit.cxx
CommitLineData
61e0abb5 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
ffa6d63b 16/* $Id: */
61e0abb5 17
18//_________________________________________________________________________
ffa6d63b 19// EMCAL digit:
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
61e0abb5 24//
ffa6d63b 25//*-- Author: Sahal Yacoob (LBL)
26// based on : AliPHOSDigit
814ad4bf 27//__________________________________________________________________________
61e0abb5 28
29// --- ROOT system ---
30
31// --- Standard library ---
32
70479d0e 33#include <Riostream.h>
61e0abb5 34
35// --- AliRoot header files ---
36
37#include "AliEMCALDigit.h"
814ad4bf 38#include "AliEMCALGeometry.h"
88d764f0 39#include "AliEMCALGetter.h"
61e0abb5 40
41
42ClassImp(AliEMCALDigit)
43
44//____________________________________________________________________________
da98933e 45 AliEMCALDigit::AliEMCALDigit()
61e0abb5 46{
47 // default ctor
48
88cb7938 49 fIndexInList = -1 ;
61e0abb5 50 fNprimary = 0 ;
88cb7938 51 fNMaxPrimary = 5 ;
52 fNiparent = 0 ;
53 fNMaxiparent = 5;
ef733077 54 fPrimary = 0 ;
55 fIparent = 0 ;
0c22a365 56 fMaxIter = 0;
04f0bda3 57 fTime = 0. ;
58 fTimeR = 0. ;
61e0abb5 59}
60
61//____________________________________________________________________________
814ad4bf 62AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Int_t DigEnergy, Float_t time, Int_t index)
61e0abb5 63{
64 // ctor with all data
65
451bc3c5 66 fNMaxPrimary = 25 ;
fb8b329a 67 fNMaxiparent = 150 ;
88d764f0 68 fPrimary = new Int_t[fNMaxPrimary] ;
69 fIparent = new Int_t[fNMaxiparent] ;
61e0abb5 70 fAmp = DigEnergy ;
814ad4bf 71 fTime = time ;
04f0bda3 72 fTimeR = fTime ;
61e0abb5 73 fId = id ;
74 fIndexInList = index ;
0c22a365 75 fMaxIter = 5;
61e0abb5 76 if( primary != -1){
77 fNprimary = 1 ;
7b62cd84 78 fPrimary[0] = primary ;
61e0abb5 79 fNiparent = 1 ;
80 fIparent[0] = iparent ;
7b62cd84 81}
61e0abb5 82 else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1)
83 fNprimary = 0 ;
84 fPrimary[0] = -1 ;
85 fNiparent = 0 ;
86 fIparent[0] = -1 ;
87
88 }
89 Int_t i ;
90 for ( i = 1; i < fNMaxPrimary ; i++)
91 fPrimary[i] = -1 ;
92
f807c3bd 93 for ( i =1; i< fNMaxiparent ; i++)
94 fIparent[i] = -1 ;
61e0abb5 95}
96
97//____________________________________________________________________________
9e5d2067 98AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) : AliDigitNew(digit)
61e0abb5 99{
100 // copy ctor
101
102
103 fNMaxPrimary = digit.fNMaxPrimary ;
104 fNMaxiparent = digit.fNMaxiparent ;
88d764f0 105 fPrimary = new Int_t[fNMaxPrimary] ;
106 fIparent = new Int_t[fNMaxiparent] ;
61e0abb5 107 Int_t i ;
108 for ( i = 0; i < fNMaxPrimary ; i++)
109 fPrimary[i] = digit.fPrimary[i] ;
110 Int_t j ;
111 for (j = 0; j< fNMaxiparent ; j++)
112 fIparent[j] = digit.fIparent[j] ;
113 fAmp = digit.fAmp ;
814ad4bf 114 fTime = digit.fTime ;
04f0bda3 115 fTimeR = digit.fTimeR ;
61e0abb5 116 fId = digit.fId;
0c22a365 117 fMaxIter = digit.fMaxIter;
61e0abb5 118 fIndexInList = digit.fIndexInList ;
119 fNprimary = digit.fNprimary ;
120 fNiparent = digit.fNiparent ;
121}
122
123//____________________________________________________________________________
124AliEMCALDigit::~AliEMCALDigit()
125{
126 // Delete array of primiries if any
88d764f0 127 delete [] fPrimary ;
128 delete [] fIparent ;
61e0abb5 129}
130
131//____________________________________________________________________________
132Int_t AliEMCALDigit::Compare(const TObject * obj) const
133{
134 // Compares two digits with respect to its Id
135 // to sort according increasing Id
136
137 Int_t rv ;
138
139 AliEMCALDigit * digit = (AliEMCALDigit *)obj ;
140
141 Int_t iddiff = fId - digit->GetId() ;
142
143 if ( iddiff > 0 )
144 rv = 1 ;
145 else if ( iddiff < 0 )
146 rv = -1 ;
147 else
148 rv = 0 ;
149
150 return rv ;
151
152}
153
814ad4bf 154//____________________________________________________________________________
88cb7938 155Float_t AliEMCALDigit::GetEta() const
1963b290 156{ // should be change in EMCALGeometry - 19-nov-04
814ad4bf 157 Float_t eta=-10., phi=-10.;
563aa66c 158 Int_t id = GetId();
88cb7938 159 const AliEMCALGeometry *g = AliEMCALGetter::Instance()->EMCALGeometry();
563aa66c 160 g->EtaPhiFromIndex(id,eta,phi);
814ad4bf 161 return eta ;
162}
163
164//____________________________________________________________________________
88cb7938 165Float_t AliEMCALDigit::GetPhi() const
1963b290 166{ // should be change in EMCALGeometry - 19-nov-04
814ad4bf 167 Float_t eta=-10., phi=-10.;
563aa66c 168 Int_t id = GetId();
88cb7938 169 const AliEMCALGeometry *g = AliEMCALGetter::Instance()->EMCALGeometry();
563aa66c 170 g->EtaPhiFromIndex(id,eta,phi);
814ad4bf 171 return phi ;
172}
173
61e0abb5 174//____________________________________________________________________________
175Int_t AliEMCALDigit::GetPrimary(Int_t index) const
176{
177 // retrieves the primary particle number given its index in the list
178 Int_t rv = -1 ;
fdebddeb 179 if ( (index <= fNprimary) && (index > 0)){
61e0abb5 180 rv = fPrimary[index-1] ;
181 }
182
183 return rv ;
184
185}
186
187//____________________________________________________________________________
188Int_t AliEMCALDigit::GetIparent(Int_t index) const
189{
190 // retrieves the primary particle number given its index in the list
191 Int_t rv = -1 ;
192 if ( index <= fNiparent ){
193 rv = fIparent[index-1] ;
194 }
195
196 return rv ;
197
198}
199
61e0abb5 200//____________________________________________________________________________
201void AliEMCALDigit::ShiftPrimary(Int_t shift){
fdebddeb 202 //shifts primary number to BIG offset, to separate primary in different TreeK
61e0abb5 203 Int_t index ;
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 ;}
208}
209//____________________________________________________________________________
210Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const
211{
212 // Two digits are equal if they have the same Id
213
214 if ( fId == digit.fId )
215 return kTRUE ;
216 else
217 return kFALSE ;
218}
219
220//____________________________________________________________________________
221AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit)
222{
223 // Adds the amplitude of digits and completes the list of primary particles
224 // if amplitude is larger than
225
226 fAmp += digit.fAmp ;
814ad4bf 227 if(fTime > digit.fTime)
228 fTime = digit.fTime ;
04f0bda3 229 fTimeR = fTime ;
7b62cd84 230
61e0abb5 231 Int_t max1 = fNprimary ;
232 Int_t max2 = fNiparent ;
233 Int_t index ;
7b62cd84 234 for (index = 0 ; index < digit.fNprimary ; index++){
61e0abb5 235 Bool_t deja = kTRUE ;
236 Int_t old ;
237 for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary?
7b62cd84 238 if(fPrimary[old] == digit.fPrimary[index])
61e0abb5 239 deja = kFALSE;
240 }
241 if(deja){
7b62cd84 242 if(max1<fNMaxPrimary){ fPrimary[max1] = digit.fPrimary[index] ;
61e0abb5 243 fNprimary++ ;
7b62cd84 244 max1++;}
245 if(fNprimary==fNMaxPrimary) {
8704424d 246
451bc3c5 247 TString mess = " NMaxPrimary = " ;
248 mess += fNMaxPrimary ;
249 mess += " is too small" ;
250 Fatal("AliEMCALDigit::Operator+ -->" , mess.Data()) ;
8704424d 251
61e0abb5 252 }
253 }
254 }
255
256 for (index = 0 ; index < digit.fNiparent ; index++){
257 Bool_t dejavu = kTRUE ;
258 Int_t old ;
259 for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary?
7b62cd84 260 if(fIparent[old] == digit.fIparent[index])
61e0abb5 261 dejavu = kFALSE;
262 }
263 if(dejavu){
7b62cd84 264 if(max2<fNMaxiparent){ fIparent[max2] = digit.fIparent[index] ;
61e0abb5 265 fNiparent++ ;
7b62cd84 266 max2++;}
267 if(fNiparent==fNMaxiparent) {
8704424d 268
451bc3c5 269 TString mess = " NMaxiparent = " ;
270 mess += fNMaxiparent ;
271 mess += " is too small" ;
272 Fatal("AliEMCALDigit::Operator+ -->", mess.Data()) ;
8704424d 273
61e0abb5 274 }
275 }
276 }
277
278 return *this ;
279}
280
563aa66c 281//____________________________________________________________________________
282AliEMCALDigit& AliEMCALDigit::operator*(Float_t factor)
283{
284 // Multiplies the amplitude by a factor
285
286 Float_t tempo = static_cast<Float_t>(fAmp) ;
287 tempo *= factor ;
288 fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ;
289 return *this ;
290}
291
61e0abb5 292//____________________________________________________________________________
293ostream& operator << ( ostream& out , const AliEMCALDigit & digit)
294{
295 // Prints the data of the digit
296
814ad4bf 297 out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ;
61e0abb5 298 Int_t i,j ;
299 for(i=0;i<digit.fNprimary;i++)
300 out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ;
301
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 ;
305 return out ;
306}
307
308