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