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