]>
Commit | Line | Data |
---|---|---|
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 | ||
33 | #include <iostream.h> | |
34 | ||
35 | // --- AliRoot header files --- | |
36 | ||
37 | #include "AliEMCALDigit.h" | |
814ad4bf | 38 | #include "AliEMCALGeometry.h" |
88d764f0 | 39 | #include "AliEMCALGetter.h" |
61e0abb5 | 40 | |
41 | ||
42 | ClassImp(AliEMCALDigit) | |
43 | ||
44 | //____________________________________________________________________________ | |
da98933e | 45 | AliEMCALDigit::AliEMCALDigit() |
61e0abb5 | 46 | { |
47 | // default ctor | |
48 | ||
0c22a365 | 49 | fIndexInList = 0 ; |
61e0abb5 | 50 | fNprimary = 0 ; |
ef733077 | 51 | fNMaxPrimary = 0 ; |
61e0abb5 | 52 | fNiparent = 0 ; |
0c22a365 | 53 | |
ef733077 | 54 | fNMaxiparent = 0; |
55 | fPrimary = 0 ; | |
56 | fIparent = 0 ; | |
0c22a365 | 57 | fMaxIter = 0; |
61e0abb5 | 58 | } |
59 | ||
60 | //____________________________________________________________________________ | |
814ad4bf | 61 | AliEMCALDigit::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 | ||
0c22a365 | 65 | fNMaxPrimary = 5 ; |
0c22a365 | 66 | fNMaxiparent = 40 ; |
88d764f0 | 67 | fPrimary = new Int_t[fNMaxPrimary] ; |
68 | fIparent = new Int_t[fNMaxiparent] ; | |
61e0abb5 | 69 | fAmp = DigEnergy ; |
814ad4bf | 70 | fTime = time ; |
61e0abb5 | 71 | fId = id ; |
72 | fIndexInList = index ; | |
0c22a365 | 73 | fMaxIter = 5; |
61e0abb5 | 74 | if( primary != -1){ |
75 | fNprimary = 1 ; | |
7b62cd84 | 76 | fPrimary[0] = primary ; |
61e0abb5 | 77 | fNiparent = 1 ; |
78 | fIparent[0] = iparent ; | |
7b62cd84 | 79 | } |
61e0abb5 | 80 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliEMCALv1) |
81 | fNprimary = 0 ; | |
82 | fPrimary[0] = -1 ; | |
83 | fNiparent = 0 ; | |
84 | fIparent[0] = -1 ; | |
85 | ||
86 | } | |
87 | Int_t i ; | |
88 | for ( i = 1; i < fNMaxPrimary ; i++) | |
89 | fPrimary[i] = -1 ; | |
90 | ||
f807c3bd | 91 | for ( i =1; i< fNMaxiparent ; i++) |
92 | fIparent[i] = -1 ; | |
61e0abb5 | 93 | } |
94 | ||
95 | //____________________________________________________________________________ | |
96 | AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) | |
97 | { | |
98 | // copy ctor | |
99 | ||
100 | ||
101 | fNMaxPrimary = digit.fNMaxPrimary ; | |
102 | fNMaxiparent = digit.fNMaxiparent ; | |
88d764f0 | 103 | fPrimary = new Int_t[fNMaxPrimary] ; |
104 | fIparent = new Int_t[fNMaxiparent] ; | |
61e0abb5 | 105 | Int_t i ; |
106 | for ( i = 0; i < fNMaxPrimary ; i++) | |
107 | fPrimary[i] = digit.fPrimary[i] ; | |
108 | Int_t j ; | |
109 | for (j = 0; j< fNMaxiparent ; j++) | |
110 | fIparent[j] = digit.fIparent[j] ; | |
111 | fAmp = digit.fAmp ; | |
814ad4bf | 112 | fTime = digit.fTime ; |
61e0abb5 | 113 | fId = digit.fId; |
0c22a365 | 114 | fMaxIter = digit.fMaxIter; |
61e0abb5 | 115 | fIndexInList = digit.fIndexInList ; |
116 | fNprimary = digit.fNprimary ; | |
117 | fNiparent = digit.fNiparent ; | |
118 | } | |
119 | ||
120 | //____________________________________________________________________________ | |
121 | AliEMCALDigit::~AliEMCALDigit() | |
122 | { | |
123 | // Delete array of primiries if any | |
88d764f0 | 124 | delete [] fPrimary ; |
125 | delete [] fIparent ; | |
61e0abb5 | 126 | } |
127 | ||
128 | //____________________________________________________________________________ | |
129 | Int_t AliEMCALDigit::Compare(const TObject * obj) const | |
130 | { | |
131 | // Compares two digits with respect to its Id | |
132 | // to sort according increasing Id | |
133 | ||
134 | Int_t rv ; | |
135 | ||
136 | AliEMCALDigit * digit = (AliEMCALDigit *)obj ; | |
137 | ||
138 | Int_t iddiff = fId - digit->GetId() ; | |
139 | ||
140 | if ( iddiff > 0 ) | |
141 | rv = 1 ; | |
142 | else if ( iddiff < 0 ) | |
143 | rv = -1 ; | |
144 | else | |
145 | rv = 0 ; | |
146 | ||
147 | return rv ; | |
148 | ||
149 | } | |
150 | ||
814ad4bf | 151 | //____________________________________________________________________________ |
152 | const Float_t AliEMCALDigit::GetEta() const | |
153 | { | |
154 | Float_t eta=-10., phi=-10.; | |
563aa66c | 155 | Int_t id = GetId(); |
da98933e | 156 | const AliEMCALGeometry *g = AliEMCALGetter::GetInstance()->EMCALGeometry(); |
563aa66c | 157 | g->EtaPhiFromIndex(id,eta,phi); |
814ad4bf | 158 | return eta ; |
159 | } | |
160 | ||
161 | //____________________________________________________________________________ | |
162 | const Float_t AliEMCALDigit::GetPhi() const | |
163 | { | |
164 | Float_t eta=-10., phi=-10.; | |
563aa66c | 165 | Int_t id = GetId(); |
da98933e | 166 | const AliEMCALGeometry *g = AliEMCALGetter::GetInstance()->EMCALGeometry(); |
563aa66c | 167 | g->EtaPhiFromIndex(id,eta,phi); |
814ad4bf | 168 | return phi ; |
169 | } | |
170 | ||
61e0abb5 | 171 | //____________________________________________________________________________ |
172 | Int_t AliEMCALDigit::GetPrimary(Int_t index) const | |
173 | { | |
174 | // retrieves the primary particle number given its index in the list | |
175 | Int_t rv = -1 ; | |
814ad4bf | 176 | if ( index <= fNprimary && index > 0){ |
61e0abb5 | 177 | rv = fPrimary[index-1] ; |
178 | } | |
179 | ||
180 | return rv ; | |
181 | ||
182 | } | |
183 | ||
184 | //____________________________________________________________________________ | |
185 | Int_t AliEMCALDigit::GetIparent(Int_t index) const | |
186 | { | |
187 | // retrieves the primary particle number given its index in the list | |
188 | Int_t rv = -1 ; | |
189 | if ( index <= fNiparent ){ | |
190 | rv = fIparent[index-1] ; | |
191 | } | |
192 | ||
193 | return rv ; | |
194 | ||
195 | } | |
196 | ||
88d764f0 | 197 | //______________________________________________________________________ |
198 | const Bool_t AliEMCALDigit::IsInPreShower() const | |
199 | { | |
200 | Bool_t rv = kFALSE ; | |
201 | const AliEMCALGeometry * geom = AliEMCALGetter::GetInstance()->EMCALGeometry() ; | |
202 | if( GetId() > (geom->GetNZ() * geom->GetNPhi() )) | |
203 | rv = kTRUE; | |
204 | return rv; | |
205 | } | |
61e0abb5 | 206 | |
207 | //____________________________________________________________________________ | |
208 | void AliEMCALDigit::ShiftPrimary(Int_t shift){ | |
209 | //shifts primary nimber to BIG offset, to separate primary in different TreeK | |
210 | Int_t index ; | |
211 | for(index = 0; index <fNprimary; index++ ){ | |
212 | fPrimary[index] = fPrimary[index]+ shift * 10000000 ;} | |
213 | for(index =0; index <fNiparent; index++){ | |
214 | fIparent[index] = fIparent[index] + shift * 10000000 ;} | |
215 | } | |
216 | //____________________________________________________________________________ | |
217 | Bool_t AliEMCALDigit::operator==(AliEMCALDigit const & digit) const | |
218 | { | |
219 | // Two digits are equal if they have the same Id | |
220 | ||
221 | if ( fId == digit.fId ) | |
222 | return kTRUE ; | |
223 | else | |
224 | return kFALSE ; | |
225 | } | |
226 | ||
227 | //____________________________________________________________________________ | |
228 | AliEMCALDigit& AliEMCALDigit::operator+(AliEMCALDigit const & digit) | |
229 | { | |
230 | // Adds the amplitude of digits and completes the list of primary particles | |
231 | // if amplitude is larger than | |
232 | ||
233 | fAmp += digit.fAmp ; | |
814ad4bf | 234 | if(fTime > digit.fTime) |
235 | fTime = digit.fTime ; | |
7b62cd84 | 236 | |
61e0abb5 | 237 | Int_t max1 = fNprimary ; |
238 | Int_t max2 = fNiparent ; | |
239 | Int_t index ; | |
7b62cd84 | 240 | for (index = 0 ; index < digit.fNprimary ; index++){ |
61e0abb5 | 241 | Bool_t deja = kTRUE ; |
242 | Int_t old ; | |
243 | for ( old = 0 ; (old < max1) && deja; old++) { //already have this primary? | |
7b62cd84 | 244 | if(fPrimary[old] == digit.fPrimary[index]) |
61e0abb5 | 245 | deja = kFALSE; |
246 | } | |
247 | if(deja){ | |
7b62cd84 | 248 | if(max1<fNMaxPrimary){ fPrimary[max1] = digit.fPrimary[index] ; |
61e0abb5 | 249 | fNprimary++ ; |
7b62cd84 | 250 | max1++;} |
251 | if(fNprimary==fNMaxPrimary) { | |
0c22a365 | 252 | fNMaxPrimary += fMaxIter ; |
01da1eeb | 253 | Int_t * tempo = new Int_t[fNprimary] ; |
0c22a365 | 254 | Int_t i ; |
255 | for (i=0; i < fNprimary; i++) | |
256 | tempo[i] = fPrimary[i] ; | |
257 | delete [] fPrimary ; | |
258 | fPrimary = new Int_t[fNMaxPrimary]; | |
01da1eeb | 259 | for (i=0; i < fNprimary; i++) |
260 | fPrimary[i] = tempo[i] ; | |
261 | delete [] tempo ; | |
0c22a365 | 262 | for (i=fNprimary; i < fNMaxPrimary; i++) |
263 | fPrimary[i] = -1 ; | |
264 | cout << "AliEMCALDigit >> NMaxPrimary has been increased to "<< fNMaxPrimary << endl ; | |
f807c3bd | 265 | return *this ; |
61e0abb5 | 266 | } |
267 | } | |
268 | } | |
269 | ||
270 | for (index = 0 ; index < digit.fNiparent ; index++){ | |
271 | Bool_t dejavu = kTRUE ; | |
272 | Int_t old ; | |
273 | for ( old = 0 ; (old < max2) && dejavu; old++) { //already have this primary? | |
7b62cd84 | 274 | if(fIparent[old] == digit.fIparent[index]) |
61e0abb5 | 275 | dejavu = kFALSE; |
276 | } | |
277 | if(dejavu){ | |
7b62cd84 | 278 | if(max2<fNMaxiparent){ fIparent[max2] = digit.fIparent[index] ; |
61e0abb5 | 279 | fNiparent++ ; |
7b62cd84 | 280 | max2++;} |
281 | if(fNiparent==fNMaxiparent) { | |
0c22a365 | 282 | fNMaxiparent += fMaxIter ; |
01da1eeb | 283 | Int_t * tempo = new Int_t[fNiparent] ; |
0c22a365 | 284 | Int_t i ; |
285 | for (i=0; i < fNiparent; i++) | |
286 | tempo[i] = fIparent[i] ; | |
287 | delete [] fIparent ; | |
288 | fIparent = new Int_t[fNMaxiparent]; | |
01da1eeb | 289 | for (i=0; i < fNiparent; i++) |
290 | fIparent[i] = tempo[i] ; | |
291 | delete [] tempo ; | |
0c22a365 | 292 | for (i=fNiparent; i < fNMaxiparent; i++) |
293 | fIparent[i] = -1 ; | |
294 | cout << "AliEMCALDigit >> Increasing fNMaxiparent to " << fNMaxiparent << endl ; | |
61e0abb5 | 295 | return *this ; |
296 | } | |
297 | } | |
298 | } | |
299 | ||
300 | return *this ; | |
301 | } | |
302 | ||
563aa66c | 303 | //____________________________________________________________________________ |
304 | AliEMCALDigit& AliEMCALDigit::operator*(Float_t factor) | |
305 | { | |
306 | // Multiplies the amplitude by a factor | |
307 | ||
308 | Float_t tempo = static_cast<Float_t>(fAmp) ; | |
309 | tempo *= factor ; | |
310 | fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ; | |
311 | return *this ; | |
312 | } | |
313 | ||
61e0abb5 | 314 | //____________________________________________________________________________ |
315 | ostream& operator << ( ostream& out , const AliEMCALDigit & digit) | |
316 | { | |
317 | // Prints the data of the digit | |
318 | ||
814ad4bf | 319 | out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ; |
61e0abb5 | 320 | Int_t i,j ; |
321 | for(i=0;i<digit.fNprimary;i++) | |
322 | out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ; | |
323 | ||
324 | for(j=0;j<digit.fNiparent;j++) | |
325 | out << "Iparent " << j+1 << " = " << digit.fIparent[j] << endl ; | |
326 | out << "Position in list = " << digit.fIndexInList << endl ; | |
327 | return out ; | |
328 | } | |
329 | ||
330 |