]>
Commit | Line | Data |
---|---|---|
d15a28e7 | 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 | ||
b2a60966 | 16 | /* $Id$ */ |
17 | ||
702ab87e | 18 | /* History of cvs commits: |
19 | * | |
20 | * $Log$ | |
3663622c | 21 | * Revision 1.39 2006/04/22 15:04:24 hristov |
22 | * Effective C++ initialization of data members in the default constructor | |
23 | * | |
f146da82 | 24 | * Revision 1.38 2006/04/22 10:30:17 hristov |
25 | * Add fEnergy to AliPHOSDigit and operate with EMC amplitude in energy units (Yu.Kharlov) | |
26 | * | |
27a73a5d | 27 | * Revision 1.37 2005/05/28 14:19:04 schutz |
28 | * Compilation warnings fixed by T.P. | |
29 | * | |
702ab87e | 30 | */ |
31 | ||
d15a28e7 | 32 | //_________________________________________________________________________ |
b2a60966 | 33 | // PHOS digit: Id |
34 | // energy | |
35 | // 3 identifiers for the primary particle(s) at the origine of the digit | |
36 | // The digits are made in FinishEvent() by summing all the hits in a single PHOS crystal or PPSD gas cell | |
b2a60966 | 37 | // |
9688c1dd | 38 | //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) |
b2a60966 | 39 | |
d15a28e7 | 40 | |
41 | // --- ROOT system --- | |
42 | ||
88cb7938 | 43 | #include "TMath.h" |
44 | ||
d15a28e7 | 45 | // --- Standard library --- |
46 | ||
d15a28e7 | 47 | // --- AliRoot header files --- |
48 | ||
49 | #include "AliPHOSDigit.h" | |
46c3076b | 50 | #include "AliLog.h" |
d15a28e7 | 51 | |
88cb7938 | 52 | |
53 | ||
d15a28e7 | 54 | ClassImp(AliPHOSDigit) |
55 | ||
cf239357 | 56 | //____________________________________________________________________________ |
f146da82 | 57 | AliPHOSDigit::AliPHOSDigit() : |
58 | AliDigitNew(), | |
f1731579 | 59 | fIsLG(0), |
f146da82 | 60 | fNprimary(0), |
61 | fPrimary(0x0), | |
62 | fEnergy(0.), | |
63 | fTime(0.), | |
54ac223e | 64 | fTimeR(0.), |
65 | fNSamplesHG(0), | |
66 | fNSamplesLG(0), | |
67 | fSamplesHG(0), | |
68 | fSamplesLG(0) | |
cf239357 | 69 | { |
b2a60966 | 70 | // default ctor |
cf239357 | 71 | } |
72 | ||
d15a28e7 | 73 | //____________________________________________________________________________ |
3663622c | 74 | AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index) : |
f1731579 | 75 | fIsLG(0), |
3663622c | 76 | fNprimary(0), |
77 | fPrimary(0), | |
78 | fEnergy(0.f), | |
79 | fTime(0.f), | |
54ac223e | 80 | fTimeR(0.f), |
81 | fNSamplesHG(0), | |
82 | fNSamplesLG(0), | |
83 | fSamplesHG(0), | |
84 | fSamplesLG(0) | |
d15a28e7 | 85 | { |
b2a60966 | 86 | // ctor with all data |
87 | ||
7b7c1533 | 88 | fAmp = digEnergy ; |
27a73a5d | 89 | fEnergy = 0 ; |
90 | fTime = time ; | |
91 | fTimeR = fTime ; | |
92 | fId = id ; | |
93 | fIndexInList = index ; | |
f1731579 | 94 | |
27a73a5d | 95 | if( primary != -1){ |
96 | fNprimary = 1 ; | |
97 | fPrimary = new Int_t[fNprimary] ; | |
98 | fPrimary[0] = primary ; | |
99 | } | |
100 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1) | |
101 | fNprimary = 0 ; | |
102 | fPrimary = 0 ; | |
103 | } | |
104 | } | |
105 | ||
106 | //____________________________________________________________________________ | |
3663622c | 107 | AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Float_t energy, Float_t time, Int_t index) : |
f1731579 | 108 | fIsLG(0), |
3663622c | 109 | fNprimary(0), |
110 | fPrimary(0), | |
111 | fEnergy(0.f), | |
112 | fTime(0.f), | |
54ac223e | 113 | fTimeR(0.f), |
114 | fNSamplesHG(0), | |
115 | fNSamplesLG(0), | |
116 | fSamplesHG(0), | |
117 | fSamplesLG(0) | |
27a73a5d | 118 | { |
119 | // ctor with all data | |
120 | ||
121 | fAmp = 0 ; | |
122 | fEnergy = energy ; | |
9688c1dd | 123 | fTime = time ; |
04f0bda3 | 124 | fTimeR = fTime ; |
83974468 | 125 | fId = id ; |
126 | fIndexInList = index ; | |
4a2ca5e9 | 127 | if( primary != -1){ |
128 | fNprimary = 1 ; | |
adc232ca | 129 | fPrimary = new Int_t[fNprimary] ; |
366c5d6f | 130 | fPrimary[0] = primary ; |
4a2ca5e9 | 131 | } |
132 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1) | |
adc232ca | 133 | fNprimary = 0 ; |
134 | fPrimary = 0 ; | |
4a2ca5e9 | 135 | } |
cf239357 | 136 | } |
137 | ||
138 | //____________________________________________________________________________ | |
3663622c | 139 | AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) : |
140 | AliDigitNew(digit), | |
141 | fNprimary(digit.fNprimary), | |
f1731579 | 142 | fIsLG(digit.fIsLG), |
3663622c | 143 | fPrimary(0), |
144 | fEnergy(digit.fEnergy), | |
145 | fTime(digit.fTime), | |
54ac223e | 146 | fTimeR(digit.fTimeR), |
147 | fNSamplesHG(0), | |
148 | fNSamplesLG(0), | |
149 | fSamplesHG(0), | |
150 | fSamplesLG(0) | |
b2a60966 | 151 | { |
152 | // copy ctor | |
adc232ca | 153 | if(fNprimary){ |
154 | fPrimary = new Int_t[fNprimary] ; | |
155 | for (Int_t i = 0; i < fNprimary ; i++) | |
156 | fPrimary[i] = digit.fPrimary[i] ; | |
157 | } | |
158 | else | |
159 | fPrimary = 0 ; | |
83974468 | 160 | fAmp = digit.fAmp ; |
161 | fId = digit.fId; | |
162 | fIndexInList = digit.fIndexInList ; | |
ff4c968a | 163 | } |
164 | ||
6c8ba828 | 165 | //____________________________________________________________________________ |
166 | AliPHOSDigit & AliPHOSDigit::operator = (const AliPHOSDigit &) | |
167 | { | |
168 | Fatal("operator =", "not implemented"); | |
169 | return *this; | |
170 | } | |
2e5c3041 | 171 | //____________________________________________________________________________ |
36d93c12 | 172 | AliPHOSDigit::~AliPHOSDigit() |
2e5c3041 | 173 | { |
54ac223e | 174 | // Delete array of primaries if any |
175 | if (fPrimary) delete [] fPrimary ; | |
176 | // Delete arrays of ALTRO samples if any | |
177 | if (fSamplesHG) delete [] fSamplesHG; | |
178 | if (fSamplesLG) delete [] fSamplesLG; | |
2e5c3041 | 179 | } |
180 | ||
d15a28e7 | 181 | //____________________________________________________________________________ |
037cc66d | 182 | Int_t AliPHOSDigit::Compare(const TObject * obj) const |
d15a28e7 | 183 | { |
b2a60966 | 184 | // Compares two digits with respect to its Id |
185 | // to sort according increasing Id | |
186 | ||
88714635 | 187 | Int_t rv ; |
cf239357 | 188 | |
189 | AliPHOSDigit * digit = (AliPHOSDigit *)obj ; | |
190 | ||
191 | Int_t iddiff = fId - digit->GetId() ; | |
192 | ||
193 | if ( iddiff > 0 ) | |
194 | rv = 1 ; | |
195 | else if ( iddiff < 0 ) | |
196 | rv = -1 ; | |
197 | else | |
198 | rv = 0 ; | |
199 | ||
200 | return rv ; | |
201 | ||
202 | } | |
26d4b141 | 203 | |
204 | //____________________________________________________________________________ | |
205 | Int_t AliPHOSDigit::GetPrimary(Int_t index) const | |
206 | { | |
2f04ed65 | 207 | // retrieves the primary particle number given its index in the list |
36d93c12 | 208 | Int_t rv = -1 ; |
36641f9d | 209 | if ( index <= fNprimary && index > 0){ |
36d93c12 | 210 | rv = fPrimary[index-1] ; |
211 | } | |
26d4b141 | 212 | |
213 | return rv ; | |
366c5d6f | 214 | |
26d4b141 | 215 | } |
54ac223e | 216 | |
217 | //____________________________________________________________________________ | |
218 | void AliPHOSDigit::SetALTROSamplesHG(Int_t nSamplesHG, Int_t *samplesHG) | |
219 | { | |
220 | fNSamplesHG = nSamplesHG; | |
48b634ff | 221 | if (fSamplesHG) delete [] fSamplesHG; |
54ac223e | 222 | fSamplesHG = new UShort_t[fNSamplesHG]; |
223 | UShort_t i; | |
224 | for (i=0; i<fNSamplesHG; i++) { | |
225 | fSamplesHG[i] = samplesHG[i]; | |
226 | } | |
227 | } | |
228 | //____________________________________________________________________________ | |
229 | void AliPHOSDigit::SetALTROSamplesLG(Int_t nSamplesLG, Int_t *samplesLG) | |
230 | { | |
231 | fNSamplesLG = nSamplesLG; | |
48b634ff | 232 | if (fSamplesLG) delete [] fSamplesLG; |
54ac223e | 233 | fSamplesLG = new UShort_t[fNSamplesLG]; |
234 | UShort_t i; | |
235 | for (i=0; i<fNSamplesLG; i++) { | |
236 | fSamplesLG[i] = samplesLG[i]; | |
237 | } | |
238 | } | |
990119d6 | 239 | //____________________________________________________________________________ |
702ab87e | 240 | void AliPHOSDigit::Print(const Option_t *) const |
d8ca0b45 | 241 | { |
e957fea8 | 242 | // Print the digit together with list of primaries |
46c3076b | 243 | TString line = Form("PHOS digit: E=%.3f, Id=%d, Time=%.3e, TimeR=%.3e, NPrim=%d, nHG=%d, nLG=%d \n", |
244 | fEnergy,fId,fTime,fTimeR,fNprimary,fNSamplesHG,fNSamplesLG); | |
245 | line += "\tList of primaries: "; | |
54ac223e | 246 | for (Int_t index = 0; index <fNprimary; index ++ ) |
46c3076b | 247 | line += Form(" %d ",fPrimary[index]); |
248 | line += "\n"; | |
249 | line += "\tSamples HG: "; | |
54ac223e | 250 | for (Int_t i = 0; i <fNSamplesHG; i++) |
46c3076b | 251 | line += Form(" %d ",fSamplesHG[i]); |
252 | line += "\n"; | |
253 | line += "\tSamples LG: "; | |
54ac223e | 254 | for (Int_t i = 0; i <fNSamplesLG; i++) |
46c3076b | 255 | line += Form(" %d ",fSamplesLG[i]); |
256 | line += "\n"; | |
257 | AliDebug(2,line); | |
d8ca0b45 | 258 | } |
259 | //____________________________________________________________________________ | |
a4e98857 | 260 | void AliPHOSDigit::ShiftPrimary(Int_t shift) |
261 | { | |
262 | //shifts primary number to BIG offset, to separate primary in different TreeK | |
adc232ca | 263 | for(Int_t index = 0; index <fNprimary; index ++ ){ |
264 | fPrimary[index]+= shift ; | |
990119d6 | 265 | } |
266 | } | |
cf239357 | 267 | //____________________________________________________________________________ |
268 | Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const | |
269 | { | |
b2a60966 | 270 | // Two digits are equal if they have the same Id |
271 | ||
cf239357 | 272 | if ( fId == digit.fId ) |
d15a28e7 | 273 | return kTRUE ; |
274 | else | |
275 | return kFALSE ; | |
276 | } | |
cf239357 | 277 | |
d15a28e7 | 278 | //____________________________________________________________________________ |
3663622c | 279 | AliPHOSDigit& AliPHOSDigit::operator+=(AliPHOSDigit const & digit) |
d15a28e7 | 280 | { |
adc232ca | 281 | |
b2a60966 | 282 | // Adds the amplitude of digits and completes the list of primary particles |
adc232ca | 283 | if(digit.fNprimary>0){ |
284 | Int_t *tmp = new Int_t[fNprimary+digit.fNprimary] ; | |
27a73a5d | 285 | if(fAmp < digit.fAmp || fEnergy < digit.fEnergy){//most energetic primary in second digit => first primaries in list from second digit |
adc232ca | 286 | for (Int_t index = 0 ; index < digit.fNprimary ; index++) |
287 | tmp[index]=(digit.fPrimary)[index] ; | |
288 | for (Int_t index = 0 ; index < fNprimary ; index++) | |
289 | tmp[index+digit.fNprimary]=fPrimary[index] ; | |
290 | } | |
291 | else{ //add new primaries to the end | |
292 | for (Int_t index = 0 ; index < fNprimary ; index++) | |
293 | tmp[index]=fPrimary[index] ; | |
294 | for (Int_t index = 0 ; index < digit.fNprimary ; index++) | |
295 | tmp[index+fNprimary]=(digit.fPrimary)[index] ; | |
296 | } | |
297 | if(fPrimary) | |
298 | delete []fPrimary ; | |
299 | fPrimary = tmp ; | |
300 | } | |
301 | fNprimary+=digit.fNprimary ; | |
27a73a5d | 302 | fAmp += digit.fAmp ; |
303 | fEnergy += digit.fEnergy ; | |
adc232ca | 304 | if(fTime > digit.fTime) |
305 | fTime = digit.fTime ; | |
04f0bda3 | 306 | fTimeR = fTime ; |
54ac223e | 307 | |
308 | // Add high-gain ALTRO samples | |
309 | UShort_t i; | |
310 | if (digit.fNSamplesHG > fNSamplesHG) { | |
311 | UShort_t newNSamplesHG = digit.fNSamplesHG; | |
312 | UShort_t *newSamplesHG = new UShort_t[newNSamplesHG]; | |
313 | for (i=0; i<newNSamplesHG; i++) { | |
314 | if (i<fNSamplesHG) | |
315 | newSamplesHG[i] = TMath::Max(1023,fSamplesHG[i] + (digit.fSamplesHG)[i]); | |
316 | else | |
317 | newSamplesHG[i] = (digit.fSamplesHG)[i]; | |
318 | } | |
319 | delete [] fSamplesHG; | |
320 | fSamplesHG = new UShort_t[newNSamplesHG]; | |
321 | for (i=0; i<newNSamplesHG; i++) { | |
322 | fSamplesHG[i] = newSamplesHG[i]; | |
323 | } | |
324 | delete [] newSamplesHG; | |
325 | } | |
326 | else { | |
327 | for (i=0; i<fNSamplesHG; i++) | |
328 | fSamplesHG[i] = TMath::Max(1023,fSamplesHG[i] + (digit.fSamplesHG)[i]); | |
329 | } | |
330 | ||
331 | // Add low-gain ALTRO samples | |
332 | if (digit.fNSamplesLG > fNSamplesLG) { | |
333 | UShort_t newNSamplesLG = digit.fNSamplesLG; | |
334 | UShort_t *newSamplesLG = new UShort_t[newNSamplesLG]; | |
335 | for (i=0; i<newNSamplesLG; i++) { | |
336 | if (i<fNSamplesLG) | |
337 | newSamplesLG[i] = TMath::Max(1023,fSamplesLG[i] + (digit.fSamplesLG)[i]); | |
338 | else | |
339 | newSamplesLG[i] = (digit.fSamplesLG)[i]; | |
340 | } | |
341 | delete [] fSamplesLG; | |
342 | fSamplesLG = new UShort_t[newNSamplesLG]; | |
343 | for (i=0; i<newNSamplesLG; i++) { | |
344 | fSamplesLG[i] = newSamplesLG[i]; | |
345 | } | |
346 | delete [] newSamplesLG; | |
347 | } | |
348 | else { | |
349 | for (i=0; i<fNSamplesLG; i++) | |
350 | fSamplesLG[i] = TMath::Max(1023,fSamplesLG[i] + (digit.fSamplesLG)[i]); | |
351 | } | |
f1731579 | 352 | |
353 | //If at least one digit in LG, then sum also | |
354 | fIsLG=fIsLG||digit.fIsLG ; | |
54ac223e | 355 | |
adc232ca | 356 | return *this ; |
88cb7938 | 357 | } |
88cb7938 | 358 | //____________________________________________________________________________ |
3663622c | 359 | AliPHOSDigit& AliPHOSDigit::operator *= (Float_t factor) |
88cb7938 | 360 | { |
361 | // Multiplies the amplitude by a factor | |
bb53c80c | 362 | |
88cb7938 | 363 | Float_t tempo = static_cast<Float_t>(fAmp) ; |
364 | tempo *= factor ; | |
365 | fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ; | |
d15a28e7 | 366 | return *this ; |
367 | } | |
368 | ||
369 | //____________________________________________________________________________ | |
cf239357 | 370 | ostream& operator << ( ostream& out , const AliPHOSDigit & digit) |
d15a28e7 | 371 | { |
b2a60966 | 372 | // Prints the data of the digit |
373 | ||
21cd0c07 | 374 | // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ; |
375 | // Int_t i ; | |
376 | // for(i=0;i<digit.fNprimary;i++) | |
377 | // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ; | |
378 | // out << "Position in list = " << digit.fIndexInList << endl ; | |
379 | digit.Warning("operator <<", "Implement differently") ; | |
d15a28e7 | 380 | return out ; |
381 | } | |
382 | ||
cf239357 | 383 |