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