]>
Commit | Line | Data |
---|---|---|
85c60a8e | 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 | ||
16 | /* $Id$ */ | |
17 | /* $Log $ */ | |
18 | ||
19 | //----------------------------------------------------------------- | |
20 | // Implementation of the ESD Calorimeter cluster class | |
21 | // ESD = Event Summary Data | |
22 | // This is the class to deal with during the phisics analysis of data | |
23 | // | |
24 | // J.L. Klay (LLNL) | |
25 | //----------------------------------------------------------------- | |
26 | ||
bab0b5f0 | 27 | #include <TLorentzVector.h> |
85c60a8e | 28 | #include "AliESDCaloCluster.h" |
29 | ||
30 | ClassImp(AliESDCaloCluster) | |
31 | ||
32 | //_______________________________________________________________________ | |
33 | AliESDCaloCluster::AliESDCaloCluster() : | |
8ada0ffe | 34 | TObject(), |
5efdec54 | 35 | fTracksMatched(0x0), |
36 | fLabels(0x0), | |
e649177a | 37 | fNCells(0), |
38 | fCellsAbsId(0x0), | |
39 | fCellsAmpFraction(0x0), | |
40 | fDigitAmplitude(0x0),//not in use | |
41 | fDigitTime(0x0),//not in use | |
42 | fDigitIndex(0x0),//not in use | |
8ada0ffe | 43 | fEnergy(0), |
44 | fDispersion(0), | |
45 | fChi2(0), | |
46 | fM20(0), | |
47 | fM02(0), | |
8ada0ffe | 48 | fEmcCpvDistance(1024), |
f1cedef3 | 49 | fTrackDx(1024),fTrackDz(1024), |
8ada0ffe | 50 | fDistToBadChannel(1024), |
51 | fID(0), | |
52 | fNExMax(0), | |
78902954 | 53 | fClusterType(kUndef), fTOF(0.) |
85c60a8e | 54 | { |
55 | // | |
56 | // The default ESD constructor | |
57 | // | |
58 | fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.; | |
59 | for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = 0.; | |
60 | } | |
61 | ||
62 | //_______________________________________________________________________ | |
63 | AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) : | |
64 | TObject(clus), | |
4dd59c4a | 65 | fTracksMatched(clus.fTracksMatched?new TArrayI(*clus.fTracksMatched):0x0), |
66 | fLabels(clus.fLabels?new TArrayI(*clus.fLabels):0x0), | |
e649177a | 67 | fNCells(clus.fNCells), |
68 | fCellsAbsId(), | |
69 | fCellsAmpFraction(), | |
70 | fDigitAmplitude(clus.fDigitAmplitude?new TArrayS(*clus.fDigitAmplitude):0x0),//not in use | |
71 | fDigitTime(clus.fDigitTime?new TArrayS(*clus.fDigitTime):0x0),//not in use | |
72 | fDigitIndex(clus.fDigitIndex?new TArrayS(*clus.fDigitIndex):0x0),//not in use | |
85c60a8e | 73 | fEnergy(clus.fEnergy), |
74 | fDispersion(clus.fDispersion), | |
75 | fChi2(clus.fChi2), | |
e3e93796 | 76 | fM20(clus.fM20), |
77 | fM02(clus.fM02), | |
e3e93796 | 78 | fEmcCpvDistance(clus.fEmcCpvDistance), |
f1cedef3 | 79 | fTrackDx(clus.fTrackDx), |
80 | fTrackDz(clus.fTrackDz), | |
45636e1b | 81 | fDistToBadChannel(clus.fDistToBadChannel), |
8ada0ffe | 82 | fID(clus.fID), |
83 | fNExMax(clus.fNExMax), | |
78902954 | 84 | fClusterType(clus.fClusterType), |
85 | fTOF(clus.fTOF) | |
85c60a8e | 86 | { |
87 | // | |
88 | // The copy constructor | |
89 | // | |
90 | fGlobalPos[0] = clus.fGlobalPos[0]; | |
91 | fGlobalPos[1] = clus.fGlobalPos[1]; | |
92 | fGlobalPos[2] = clus.fGlobalPos[2]; | |
93 | ||
94 | for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i]; | |
95 | ||
e649177a | 96 | if (clus.fNCells > 0) { |
97 | ||
98 | if(clus.fCellsAbsId){ | |
99 | fCellsAbsId = new UShort_t[clus.fNCells]; | |
100 | for (Int_t i=0; i<clus.fNCells; i++) | |
101 | fCellsAbsId[i]=clus.fCellsAbsId[i]; | |
102 | } | |
103 | ||
104 | if(clus.fCellsAmpFraction){ | |
105 | fCellsAmpFraction = new Double32_t[clus.fNCells]; | |
106 | for (Int_t i=0; i<clus.fNCells; i++) | |
107 | fCellsAmpFraction[i]=clus.fCellsAmpFraction[i]; | |
108 | } | |
109 | ||
110 | } | |
111 | ||
85c60a8e | 112 | } |
113 | ||
fe12e09c | 114 | //_______________________________________________________________________ |
115 | AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source) | |
116 | { | |
117 | // assignment operator | |
118 | ||
119 | if(&source == this) return *this; | |
8ada0ffe | 120 | TObject::operator=(source); |
8ada0ffe | 121 | fGlobalPos[0] = source.fGlobalPos[0]; |
122 | fGlobalPos[1] = source.fGlobalPos[1]; | |
123 | fGlobalPos[2] = source.fGlobalPos[2]; | |
124 | ||
fe12e09c | 125 | fEnergy = source.fEnergy; |
126 | fDispersion = source.fDispersion; | |
127 | fChi2 = source.fChi2; | |
fe12e09c | 128 | fM20 = source.fM20; |
129 | fM02 = source.fM02; | |
fe12e09c | 130 | fEmcCpvDistance = source.fEmcCpvDistance; |
f1cedef3 | 131 | fTrackDx= source.fTrackDx ; |
132 | fTrackDz= source.fTrackDz ; | |
45636e1b | 133 | fDistToBadChannel = source.fDistToBadChannel ; |
fe12e09c | 134 | for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i]; |
8ada0ffe | 135 | fID = source.fID; |
fe12e09c | 136 | |
732a24fe | 137 | fNCells= source.fNCells; |
138 | ||
e649177a | 139 | if (source.fNCells > 0) { |
e649177a | 140 | if(source.fCellsAbsId){ |
85005d58 | 141 | if(fNCells != source.fNCells||!fCellsAbsId){ |
142 | if(fCellsAbsId)delete [] fCellsAbsId; | |
732a24fe | 143 | fCellsAbsId = new UShort_t[source.fNCells]; |
144 | } | |
85005d58 | 145 | for (Int_t i=0; i<source.fNCells; i++){ |
e649177a | 146 | fCellsAbsId[i]=source.fCellsAbsId[i]; |
85005d58 | 147 | } |
e649177a | 148 | } |
149 | ||
150 | if(source.fCellsAmpFraction){ | |
85005d58 | 151 | if(fNCells != source.fNCells||!fCellsAmpFraction){ |
152 | if(fCellsAmpFraction) delete [] fCellsAmpFraction; | |
732a24fe | 153 | fCellsAmpFraction = new Double32_t[source.fNCells]; |
154 | } | |
e649177a | 155 | for (Int_t i=0; i<source.fNCells; i++) |
156 | fCellsAmpFraction[i]=source.fCellsAmpFraction[i]; | |
732a24fe | 157 | } |
e649177a | 158 | } |
159 | ||
160 | fNExMax = source.fNExMax; | |
161 | fClusterType = source.fClusterType; | |
78902954 | 162 | fTOF = source.fTOF; |
e649177a | 163 | |
164 | //not in use | |
732a24fe | 165 | if(source.fTracksMatched){ |
166 | // assign or copy construct | |
85005d58 | 167 | if(fTracksMatched){ |
168 | *fTracksMatched = *source.fTracksMatched; | |
169 | } | |
732a24fe | 170 | else fTracksMatched = new TArrayI(*source.fTracksMatched); |
171 | } | |
172 | else{ | |
85005d58 | 173 | if(fTracksMatched)delete fTracksMatched; |
732a24fe | 174 | fTracksMatched = 0; |
175 | } | |
176 | ||
177 | if(source.fLabels){ | |
178 | // assign or copy construct | |
85005d58 | 179 | if(fLabels){ |
180 | *fLabels = *source.fLabels; | |
181 | } | |
732a24fe | 182 | else fLabels = new TArrayI(*source.fLabels); |
183 | } | |
184 | else{ | |
85005d58 | 185 | if(fLabels)delete fLabels; |
732a24fe | 186 | fLabels = 0; |
187 | } | |
188 | ||
189 | ||
190 | if(source.fDigitAmplitude){ | |
191 | // assign or copy construct | |
192 | if(fDigitAmplitude) *fDigitAmplitude = *source.fDigitAmplitude; | |
193 | else fDigitAmplitude = new TArrayS(*source.fDigitAmplitude); | |
85005d58 | 194 | } |
732a24fe | 195 | else{ |
196 | delete fDigitAmplitude; | |
197 | fDigitAmplitude = 0; | |
198 | } | |
199 | ||
200 | ||
201 | ||
202 | if(source.fDigitTime){ | |
203 | // assign or copy construct | |
204 | if(fDigitTime) *fDigitTime = *source.fDigitTime; | |
205 | else fDigitTime = new TArrayS(*source.fDigitTime); | |
206 | } | |
207 | else{ | |
208 | delete fDigitTime; | |
209 | fDigitTime = 0; | |
210 | } | |
211 | ||
212 | ||
213 | ||
214 | if(source.fDigitIndex){ | |
215 | // assign or copy construct | |
216 | if(fDigitIndex) *fDigitIndex = *source.fDigitIndex; | |
217 | else fDigitIndex = new TArrayS(*source.fDigitIndex); | |
218 | } | |
219 | else{ | |
220 | delete fDigitIndex; | |
221 | fDigitIndex = 0; | |
222 | } | |
e649177a | 223 | |
fe12e09c | 224 | return *this; |
225 | ||
226 | } | |
227 | ||
732a24fe | 228 | void AliESDCaloCluster::Copy(TObject &obj) const { |
229 | ||
230 | // this overwrites the virtual TOBject::Copy() | |
231 | // to allow run time copying without casting | |
232 | // in AliESDEvent | |
233 | ||
234 | if(this==&obj)return; | |
235 | AliESDCaloCluster *robj = dynamic_cast<AliESDCaloCluster*>(&obj); | |
236 | if(!robj)return; // not an AliESDCluster | |
237 | *robj = *this; | |
238 | ||
239 | } | |
85c60a8e | 240 | |
241 | //_______________________________________________________________________ | |
242 | AliESDCaloCluster::~AliESDCaloCluster(){ | |
243 | // | |
5efdec54 | 244 | // This is destructor according Coding Conventions |
85c60a8e | 245 | // |
85005d58 | 246 | if(fTracksMatched)delete fTracksMatched;fTracksMatched = 0; |
247 | if(fLabels) delete fLabels; fLabels = 0; | |
e649177a | 248 | delete fDigitAmplitude; //not in use |
249 | delete fDigitTime; //not in use | |
250 | delete fDigitIndex; //not in use | |
85005d58 | 251 | if(fCellsAmpFraction){ delete[] fCellsAmpFraction; fCellsAmpFraction=0;} |
252 | if(fCellsAbsId){ delete[] fCellsAbsId; fCellsAbsId = 0;} | |
85c60a8e | 253 | } |
254 | ||
255 | //_______________________________________________________________________ | |
256 | void AliESDCaloCluster::SetPid(const Float_t *p) { | |
257 | // Sets the probability of each particle type | |
258 | // Copied from AliESDtrack SetPIDValues | |
259 | // This function copies "n" PID weights from "scr" to "dest" | |
260 | // and normalizes their sum to 1 thus producing conditional | |
261 | // probabilities. | |
262 | // The negative weights are set to 0. | |
263 | // In case all the weights are non-positive they are replaced by | |
264 | // uniform probabilities | |
265 | ||
266 | Int_t n = AliPID::kSPECIESN; | |
267 | ||
268 | Float_t uniform = 1./(Float_t)n; | |
269 | ||
270 | Float_t sum = 0; | |
271 | for (Int_t i=0; i<n; i++) | |
272 | if (p[i]>=0) { | |
273 | sum+=p[i]; | |
274 | fPID[i] = p[i]; | |
275 | } | |
276 | else { | |
277 | fPID[i] = 0; | |
278 | } | |
279 | ||
280 | if(sum>0) | |
281 | for (Int_t i=0; i<n; i++) fPID[i] /= sum; | |
282 | else | |
283 | for (Int_t i=0; i<n; i++) fPID[i] = uniform; | |
284 | ||
285 | } | |
bab0b5f0 | 286 | |
287 | //_______________________________________________________________________ | |
5efdec54 | 288 | void AliESDCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) { |
bab0b5f0 | 289 | // Returns TLorentzVector with momentum of the cluster. Only valid for clusters |
290 | // identified as photons or pi0 (overlapped gamma) produced on the vertex | |
5efdec54 | 291 | //Vertex can be recovered with esd pointer doing: |
292 | //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; " | |
293 | ||
294 | if(vertex){//calculate direction from vertex | |
295 | fGlobalPos[0]-=vertex[0]; | |
296 | fGlobalPos[1]-=vertex[1]; | |
297 | fGlobalPos[2]-=vertex[2]; | |
298 | } | |
bab0b5f0 | 299 | |
300 | Double_t r = TMath::Sqrt(fGlobalPos[0]*fGlobalPos[0]+ | |
301 | fGlobalPos[1]*fGlobalPos[1]+ | |
302 | fGlobalPos[2]*fGlobalPos[2] ) ; | |
303 | ||
304 | p.SetPxPyPzE( fEnergy*fGlobalPos[0]/r, fEnergy*fGlobalPos[1]/r, fEnergy*fGlobalPos[2]/r, fEnergy) ; | |
305 | ||
306 | } | |
ed712271 | 307 | |
308 | //_______________________________________________________________________ | |
309 | void AliESDCaloCluster::SetCellsAbsId(UShort_t *array) | |
310 | { | |
311 | // Set the array of cell absId numbers | |
312 | if (fNCells) { | |
313 | fCellsAbsId = new UShort_t[fNCells]; | |
314 | for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i]; | |
315 | } | |
316 | } | |
317 | ||
318 | //_______________________________________________________________________ | |
319 | void AliESDCaloCluster::SetCellsAmplitudeFraction(Double32_t *array) | |
320 | { | |
321 | // Set the array of cell amplitude fraction | |
322 | if (fNCells) { | |
323 | fCellsAmpFraction = new Double32_t[fNCells]; | |
324 | for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i]; | |
325 | } | |
326 | } |