]>
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$ | |
f146da82 | 21 | * Revision 1.38 2006/04/22 10:30:17 hristov |
22 | * Add fEnergy to AliPHOSDigit and operate with EMC amplitude in energy units (Yu.Kharlov) | |
23 | * | |
27a73a5d | 24 | * Revision 1.37 2005/05/28 14:19:04 schutz |
25 | * Compilation warnings fixed by T.P. | |
26 | * | |
702ab87e | 27 | */ |
28 | ||
d15a28e7 | 29 | //_________________________________________________________________________ |
b2a60966 | 30 | // PHOS digit: Id |
31 | // energy | |
32 | // 3 identifiers for the primary particle(s) at the origine of the digit | |
33 | // The digits are made in FinishEvent() by summing all the hits in a single PHOS crystal or PPSD gas cell | |
b2a60966 | 34 | // |
9688c1dd | 35 | //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) |
b2a60966 | 36 | |
d15a28e7 | 37 | |
38 | // --- ROOT system --- | |
39 | ||
88cb7938 | 40 | #include "TMath.h" |
41 | ||
d15a28e7 | 42 | // --- Standard library --- |
43 | ||
d15a28e7 | 44 | // --- AliRoot header files --- |
45 | ||
46 | #include "AliPHOSDigit.h" | |
47 | ||
48 | ||
88cb7938 | 49 | |
50 | ||
d15a28e7 | 51 | ClassImp(AliPHOSDigit) |
52 | ||
cf239357 | 53 | //____________________________________________________________________________ |
f146da82 | 54 | AliPHOSDigit::AliPHOSDigit() : |
55 | AliDigitNew(), | |
56 | fNprimary(0), | |
57 | fPrimary(0x0), | |
58 | fEnergy(0.), | |
59 | fTime(0.), | |
60 | fTimeR(0.) | |
61 | ||
cf239357 | 62 | { |
b2a60966 | 63 | // default ctor |
cf239357 | 64 | } |
65 | ||
d15a28e7 | 66 | //____________________________________________________________________________ |
9688c1dd | 67 | AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Float_t time, Int_t index) |
d15a28e7 | 68 | { |
b2a60966 | 69 | // ctor with all data |
70 | ||
7b7c1533 | 71 | fAmp = digEnergy ; |
27a73a5d | 72 | fEnergy = 0 ; |
73 | fTime = time ; | |
74 | fTimeR = fTime ; | |
75 | fId = id ; | |
76 | fIndexInList = index ; | |
77 | if( primary != -1){ | |
78 | fNprimary = 1 ; | |
79 | fPrimary = new Int_t[fNprimary] ; | |
80 | fPrimary[0] = primary ; | |
81 | } | |
82 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1) | |
83 | fNprimary = 0 ; | |
84 | fPrimary = 0 ; | |
85 | } | |
86 | } | |
87 | ||
88 | //____________________________________________________________________________ | |
89 | AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Float_t energy, Float_t time, Int_t index) | |
90 | { | |
91 | // ctor with all data | |
92 | ||
93 | fAmp = 0 ; | |
94 | fEnergy = energy ; | |
9688c1dd | 95 | fTime = time ; |
04f0bda3 | 96 | fTimeR = fTime ; |
83974468 | 97 | fId = id ; |
98 | fIndexInList = index ; | |
4a2ca5e9 | 99 | if( primary != -1){ |
100 | fNprimary = 1 ; | |
adc232ca | 101 | fPrimary = new Int_t[fNprimary] ; |
366c5d6f | 102 | fPrimary[0] = primary ; |
4a2ca5e9 | 103 | } |
104 | else{ //If the contribution of this primary smaller than fDigitThreshold (AliPHOSv1) | |
adc232ca | 105 | fNprimary = 0 ; |
106 | fPrimary = 0 ; | |
4a2ca5e9 | 107 | } |
cf239357 | 108 | } |
109 | ||
110 | //____________________________________________________________________________ | |
a8c47ab6 | 111 | AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit) : AliDigitNew(digit) |
b2a60966 | 112 | { |
113 | // copy ctor | |
36d93c12 | 114 | |
adc232ca | 115 | fNprimary = digit.fNprimary ; |
116 | if(fNprimary){ | |
117 | fPrimary = new Int_t[fNprimary] ; | |
118 | for (Int_t i = 0; i < fNprimary ; i++) | |
119 | fPrimary[i] = digit.fPrimary[i] ; | |
120 | } | |
121 | else | |
122 | fPrimary = 0 ; | |
83974468 | 123 | fAmp = digit.fAmp ; |
27a73a5d | 124 | fEnergy = digit.fEnergy ; |
9688c1dd | 125 | fTime = digit.fTime ; |
04f0bda3 | 126 | fTimeR = digit.fTimeR ; |
83974468 | 127 | fId = digit.fId; |
128 | fIndexInList = digit.fIndexInList ; | |
ff4c968a | 129 | } |
130 | ||
2e5c3041 | 131 | //____________________________________________________________________________ |
36d93c12 | 132 | AliPHOSDigit::~AliPHOSDigit() |
2e5c3041 | 133 | { |
134 | // Delete array of primiries if any | |
adc232ca | 135 | if(fPrimary) |
136 | delete [] fPrimary ; | |
2e5c3041 | 137 | } |
138 | ||
d15a28e7 | 139 | //____________________________________________________________________________ |
037cc66d | 140 | Int_t AliPHOSDigit::Compare(const TObject * obj) const |
d15a28e7 | 141 | { |
b2a60966 | 142 | // Compares two digits with respect to its Id |
143 | // to sort according increasing Id | |
144 | ||
88714635 | 145 | Int_t rv ; |
cf239357 | 146 | |
147 | AliPHOSDigit * digit = (AliPHOSDigit *)obj ; | |
148 | ||
149 | Int_t iddiff = fId - digit->GetId() ; | |
150 | ||
151 | if ( iddiff > 0 ) | |
152 | rv = 1 ; | |
153 | else if ( iddiff < 0 ) | |
154 | rv = -1 ; | |
155 | else | |
156 | rv = 0 ; | |
157 | ||
158 | return rv ; | |
159 | ||
160 | } | |
26d4b141 | 161 | |
162 | //____________________________________________________________________________ | |
163 | Int_t AliPHOSDigit::GetPrimary(Int_t index) const | |
164 | { | |
2f04ed65 | 165 | // retrieves the primary particle number given its index in the list |
36d93c12 | 166 | Int_t rv = -1 ; |
36641f9d | 167 | if ( index <= fNprimary && index > 0){ |
36d93c12 | 168 | rv = fPrimary[index-1] ; |
169 | } | |
26d4b141 | 170 | |
171 | return rv ; | |
366c5d6f | 172 | |
26d4b141 | 173 | } |
990119d6 | 174 | //____________________________________________________________________________ |
702ab87e | 175 | void AliPHOSDigit::Print(const Option_t *) const |
d8ca0b45 | 176 | { |
e957fea8 | 177 | // Print the digit together with list of primaries |
27a73a5d | 178 | printf("PHOS digit: Amp=%d/E=%.3f, Id=%d, Time=%.3e, TimeR=%.3e, NPrim=%d ",fAmp,fEnergy,fId,fTime,fTimeR,fNprimary); |
adc232ca | 179 | for(Int_t index = 0; index <fNprimary; index ++ ) |
180 | printf(" %d ",fPrimary[index]); | |
181 | printf("\n") ; | |
d8ca0b45 | 182 | } |
183 | //____________________________________________________________________________ | |
a4e98857 | 184 | void AliPHOSDigit::ShiftPrimary(Int_t shift) |
185 | { | |
186 | //shifts primary number to BIG offset, to separate primary in different TreeK | |
adc232ca | 187 | for(Int_t index = 0; index <fNprimary; index ++ ){ |
188 | fPrimary[index]+= shift ; | |
990119d6 | 189 | } |
190 | } | |
cf239357 | 191 | //____________________________________________________________________________ |
192 | Bool_t AliPHOSDigit::operator==(AliPHOSDigit const & digit) const | |
193 | { | |
b2a60966 | 194 | // Two digits are equal if they have the same Id |
195 | ||
cf239357 | 196 | if ( fId == digit.fId ) |
d15a28e7 | 197 | return kTRUE ; |
198 | else | |
199 | return kFALSE ; | |
200 | } | |
cf239357 | 201 | |
d15a28e7 | 202 | //____________________________________________________________________________ |
cf239357 | 203 | AliPHOSDigit& AliPHOSDigit::operator+(AliPHOSDigit const & digit) |
d15a28e7 | 204 | { |
adc232ca | 205 | |
b2a60966 | 206 | // Adds the amplitude of digits and completes the list of primary particles |
adc232ca | 207 | if(digit.fNprimary>0){ |
208 | Int_t *tmp = new Int_t[fNprimary+digit.fNprimary] ; | |
27a73a5d | 209 | if(fAmp < digit.fAmp || fEnergy < digit.fEnergy){//most energetic primary in second digit => first primaries in list from second digit |
adc232ca | 210 | for (Int_t index = 0 ; index < digit.fNprimary ; index++) |
211 | tmp[index]=(digit.fPrimary)[index] ; | |
212 | for (Int_t index = 0 ; index < fNprimary ; index++) | |
213 | tmp[index+digit.fNprimary]=fPrimary[index] ; | |
214 | } | |
215 | else{ //add new primaries to the end | |
216 | for (Int_t index = 0 ; index < fNprimary ; index++) | |
217 | tmp[index]=fPrimary[index] ; | |
218 | for (Int_t index = 0 ; index < digit.fNprimary ; index++) | |
219 | tmp[index+fNprimary]=(digit.fPrimary)[index] ; | |
220 | } | |
221 | if(fPrimary) | |
222 | delete []fPrimary ; | |
223 | fPrimary = tmp ; | |
224 | } | |
225 | fNprimary+=digit.fNprimary ; | |
27a73a5d | 226 | fAmp += digit.fAmp ; |
227 | fEnergy += digit.fEnergy ; | |
adc232ca | 228 | if(fTime > digit.fTime) |
229 | fTime = digit.fTime ; | |
04f0bda3 | 230 | fTimeR = fTime ; |
adc232ca | 231 | return *this ; |
88cb7938 | 232 | } |
88cb7938 | 233 | //____________________________________________________________________________ |
234 | AliPHOSDigit& AliPHOSDigit::operator*(Float_t factor) | |
235 | { | |
236 | // Multiplies the amplitude by a factor | |
bb53c80c | 237 | |
88cb7938 | 238 | Float_t tempo = static_cast<Float_t>(fAmp) ; |
239 | tempo *= factor ; | |
240 | fAmp = static_cast<Int_t>(TMath::Ceil(tempo)) ; | |
d15a28e7 | 241 | return *this ; |
242 | } | |
243 | ||
244 | //____________________________________________________________________________ | |
cf239357 | 245 | ostream& operator << ( ostream& out , const AliPHOSDigit & digit) |
d15a28e7 | 246 | { |
b2a60966 | 247 | // Prints the data of the digit |
248 | ||
21cd0c07 | 249 | // out << "ID " << digit.fId << " Energy = " << digit.fAmp << " Time = " << digit.fTime << endl ; |
250 | // Int_t i ; | |
251 | // for(i=0;i<digit.fNprimary;i++) | |
252 | // out << "Primary " << i+1 << " = " << digit.fPrimary[i] << endl ; | |
253 | // out << "Position in list = " << digit.fIndexInList << endl ; | |
254 | digit.Warning("operator <<", "Implement differently") ; | |
d15a28e7 | 255 | return out ; |
256 | } | |
257 | ||
cf239357 | 258 |