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