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