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