]>
Commit | Line | Data |
---|---|---|
df9db588 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, 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 | ||
18 | //------------------------------------------------------------------------- | |
19 | // AOD track base class | |
20 | // Author: Markus Oldenburg, CERN | |
21 | //------------------------------------------------------------------------- | |
22 | ||
23 | #include "AliAODTrack.h" | |
24 | ||
25 | ClassImp(AliAODTrack) | |
26 | ||
27 | //______________________________________________________________________________ | |
28 | AliAODTrack::AliAODTrack() : | |
29 | AliVirtualParticle(), | |
30 | fChi2(-999.), | |
31 | fID(-999), | |
32 | fLabel(-999), | |
33 | fCovMatrix(NULL), | |
34 | fProdVertex(0x0), | |
14b34be5 | 35 | fCharge(-99), |
df9db588 | 36 | fITSClusterMap(0), |
37 | fType(kUndef) | |
38 | { | |
39 | // default constructor | |
40 | ||
41 | SetP(); | |
42 | SetPosition((Float_t*)NULL); | |
43 | SetPID((Float_t*)NULL); | |
44 | } | |
45 | ||
46 | //______________________________________________________________________________ | |
47 | AliAODTrack::AliAODTrack(Int_t id, | |
48 | Int_t label, | |
49 | Double_t p[3], | |
50 | Bool_t cartesian, | |
51 | Double_t x[3], | |
52 | Bool_t isDCA, | |
53 | Double_t covMatrix[21], | |
54 | Short_t charge, | |
55 | UChar_t itsClusMap, | |
56 | Double_t pid[10], | |
57 | AliAODVertex *prodVertex, | |
dc825b15 | 58 | Bool_t usedForPrimVtxFit, |
df9db588 | 59 | AODTrk_t ttype) : |
60 | AliVirtualParticle(), | |
61 | fChi2(-999.), | |
62 | fID(id), | |
63 | fLabel(label), | |
64 | fCovMatrix(NULL), | |
65 | fProdVertex(prodVertex), | |
66 | fCharge(charge), | |
67 | fITSClusterMap(itsClusMap), | |
68 | fType(ttype) | |
69 | { | |
70 | // constructor | |
71 | ||
72 | SetP(p, cartesian); | |
73 | SetPosition(x, isDCA); | |
dc825b15 | 74 | SetUsedForPrimVtxFit(usedForPrimVtxFit); |
df9db588 | 75 | if(covMatrix) SetCovMatrix(covMatrix); |
76 | SetPID(pid); | |
77 | ||
78 | } | |
79 | ||
80 | //______________________________________________________________________________ | |
81 | AliAODTrack::AliAODTrack(Int_t id, | |
82 | Int_t label, | |
83 | Float_t p[3], | |
84 | Bool_t cartesian, | |
85 | Float_t x[3], | |
86 | Bool_t isDCA, | |
87 | Float_t covMatrix[21], | |
88 | Short_t charge, | |
89 | UChar_t itsClusMap, | |
90 | Float_t pid[10], | |
91 | AliAODVertex *prodVertex, | |
dc825b15 | 92 | Bool_t usedForPrimVtxFit, |
df9db588 | 93 | AODTrk_t ttype) : |
94 | AliVirtualParticle(), | |
95 | fChi2(-999.), | |
96 | fID(id), | |
97 | fLabel(label), | |
98 | fCovMatrix(NULL), | |
99 | fProdVertex(prodVertex), | |
100 | fCharge(charge), | |
101 | fITSClusterMap(itsClusMap), | |
102 | fType(ttype) | |
103 | { | |
104 | // constructor | |
105 | ||
106 | SetP(p, cartesian); | |
107 | SetPosition(x, isDCA); | |
dc825b15 | 108 | SetUsedForPrimVtxFit(usedForPrimVtxFit); |
df9db588 | 109 | if(covMatrix) SetCovMatrix(covMatrix); |
110 | SetPID(pid); | |
df9db588 | 111 | } |
112 | ||
df9db588 | 113 | //______________________________________________________________________________ |
114 | AliAODTrack::~AliAODTrack() | |
115 | { | |
116 | // destructor | |
117 | delete fCovMatrix; | |
118 | } | |
119 | ||
120 | ||
121 | //______________________________________________________________________________ | |
122 | AliAODTrack::AliAODTrack(const AliAODTrack& trk) : | |
123 | AliVirtualParticle(trk), | |
124 | fChi2(trk.fChi2), | |
125 | fID(trk.fID), | |
126 | fLabel(trk.fLabel), | |
127 | fCovMatrix(NULL), | |
128 | fProdVertex(trk.fProdVertex), | |
129 | fCharge(trk.fCharge), | |
130 | fITSClusterMap(trk.fITSClusterMap), | |
131 | fType(trk.fType) | |
132 | { | |
133 | // Copy constructor | |
134 | ||
135 | trk.GetP(fMomentum); | |
136 | trk.GetPosition(fPosition); | |
dc825b15 | 137 | SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit()); |
5d62ce04 | 138 | if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix); |
df9db588 | 139 | SetPID(trk.fPID); |
140 | ||
141 | } | |
142 | ||
143 | //______________________________________________________________________________ | |
144 | AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk) | |
145 | { | |
146 | // Assignment operator | |
147 | if(this!=&trk) { | |
148 | ||
149 | AliVirtualParticle::operator=(trk); | |
150 | ||
151 | trk.GetP(fMomentum); | |
152 | trk.GetPosition(fPosition); | |
153 | trk.GetPID(fPID); | |
154 | ||
155 | fChi2 = trk.fChi2; | |
156 | ||
157 | fID = trk.fID; | |
158 | fLabel = trk.fLabel; | |
159 | ||
160 | delete fCovMatrix; | |
5d62ce04 | 161 | if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix); |
df9db588 | 162 | else fCovMatrix=NULL; |
163 | fProdVertex = trk.fProdVertex; | |
164 | ||
165 | fCharge = trk.fCharge; | |
166 | fITSClusterMap = trk.fITSClusterMap; | |
dc825b15 | 167 | SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit()); |
df9db588 | 168 | fType = trk.fType; |
169 | } | |
170 | ||
171 | return *this; | |
172 | } | |
173 | ||
4697e4fb | 174 | //______________________________________________________________________________ |
175 | Double_t AliAODTrack::M(AODTrkPID_t pid) const | |
176 | { | |
177 | // Returns the mass. | |
178 | // In the case of elementary particles the hard coded mass values were taken | |
179 | // from the PDG. In all cases the error on the values does not affect | |
180 | // the last digit. | |
181 | ||
182 | ||
183 | switch (pid) { | |
184 | ||
185 | case kElectron : | |
186 | return 0.000510999; | |
187 | break; | |
188 | ||
189 | case kMuon : | |
190 | return 0.1056584; | |
191 | break; | |
192 | ||
193 | case kPion : | |
194 | return 0.13957; | |
195 | break; | |
196 | ||
197 | case kKaon : | |
198 | return 0.4937; | |
199 | break; | |
200 | ||
201 | case kProton : | |
202 | return 0.9382720; | |
203 | break; | |
204 | ||
205 | case kDeuteron : | |
206 | return 1.8756; | |
207 | break; | |
208 | ||
209 | case kTriton : | |
210 | return 2.8089; | |
211 | break; | |
212 | ||
213 | case kHelium3 : | |
214 | return 2.8084; | |
215 | break; | |
216 | ||
217 | case kAlpha : | |
218 | return 3.7274; | |
219 | break; | |
220 | ||
221 | case kUnknown : | |
222 | return -999.; | |
223 | break; | |
224 | ||
225 | default : | |
226 | return -999.; | |
227 | } | |
228 | } | |
229 | ||
230 | //______________________________________________________________________________ | |
231 | Double_t AliAODTrack::E(AODTrkPID_t pid) const | |
232 | { | |
233 | // Returns the energy of the particle of a given pid. | |
234 | ||
235 | if (pid != kUnknown) { // particle was identified | |
236 | Double_t m = M(pid); | |
237 | return TMath::Sqrt(P()*P() + m*m); | |
238 | } else { // pid unknown | |
239 | return -999.; | |
240 | } | |
241 | } | |
242 | ||
243 | //______________________________________________________________________________ | |
244 | Double_t AliAODTrack::Y(AODTrkPID_t pid) const | |
245 | { | |
246 | // Returns the energy of the particle of a given pid. | |
247 | ||
248 | if (pid != kUnknown) { // particle was identified | |
249 | Double_t e = E(pid); | |
250 | Double_t pz = Pz(); | |
251 | if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz | |
252 | return 0.5*TMath::Log((e+pz)/(e-pz)); | |
253 | } else { // energy not known or equal to pz | |
254 | return -999.; | |
255 | } | |
256 | } else { // pid unknown | |
257 | return -999.; | |
258 | } | |
259 | } | |
260 | ||
261 | //______________________________________________________________________________ | |
262 | Double_t AliAODTrack::Y(Double_t m) const | |
263 | { | |
264 | // Returns the energy of the particle of a given mass. | |
265 | ||
266 | if (m >= 0.) { // mass makes sense | |
267 | Double_t e = E(m); | |
268 | Double_t pz = Pz(); | |
269 | if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz | |
270 | return 0.5*TMath::Log((e+pz)/(e-pz)); | |
271 | } else { // energy not known or equal to pz | |
272 | return -999.; | |
273 | } | |
274 | } else { // pid unknown | |
275 | return -999.; | |
276 | } | |
277 | } | |
278 | ||
279 | //______________________________________________________________________________ | |
280 | AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const | |
281 | { | |
282 | // Returns the most probable PID array element. | |
283 | ||
284 | Int_t nPID = 10; | |
285 | if (fPID) { | |
286 | AODTrkPID_t loc = kUnknown; | |
287 | Double_t max = 0.; | |
288 | Bool_t allTheSame = kTRUE; | |
289 | ||
290 | for (Int_t iPID = 0; iPID < nPID; iPID++) { | |
291 | if (fPID[iPID] >= max) { | |
292 | if (fPID[iPID] > max) { | |
293 | allTheSame = kFALSE; | |
294 | max = fPID[iPID]; | |
295 | loc = (AODTrkPID_t)iPID; | |
296 | } else { | |
297 | allTheSame = kTRUE; | |
298 | } | |
299 | } | |
300 | } | |
301 | ||
302 | return allTheSame ? kUnknown : loc; | |
303 | } else { | |
304 | return kUnknown; | |
305 | } | |
306 | } | |
307 | ||
308 | //______________________________________________________________________________ | |
309 | void AliAODTrack::ConvertAliPIDtoAODPID() | |
310 | { | |
311 | // Converts AliPID array. | |
312 | // The numbering scheme is the same for electrons, muons, pions, kaons, and protons. | |
313 | // Everything else has to be set to zero. | |
314 | ||
315 | fPID[kDeuteron] = 0.; | |
316 | fPID[kTriton] = 0.; | |
317 | fPID[kHelium3] = 0.; | |
318 | fPID[kAlpha] = 0.; | |
319 | fPID[kUnknown] = 0.; | |
320 | ||
321 | return; | |
322 | } | |
323 | ||
324 | ||
df9db588 | 325 | //______________________________________________________________________________ |
326 | template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian) | |
327 | { | |
328 | // set the momentum | |
329 | ||
330 | if (p) { | |
331 | if (cartesian) { | |
16b65f2a | 332 | Double_t pt2 = p[0]*p[0] + p[1]*p[1]; |
333 | Double_t P = TMath::Sqrt(pt2 + p[2]*p[2]); | |
df9db588 | 334 | |
16b65f2a | 335 | fMomentum[0] = TMath::Sqrt(pt2); // pt |
336 | fMomentum[1] = (pt2 != 0.) ? TMath::ATan2(p[1], p[0]) : -999; // phi | |
337 | fMomentum[2] = (P != 0.) ? TMath::ACos(p[2]/P) : -999.; // theta | |
df9db588 | 338 | } else { |
16b65f2a | 339 | fMomentum[0] = p[0]; // pt |
df9db588 | 340 | fMomentum[1] = p[1]; // phi |
341 | fMomentum[2] = p[2]; // theta | |
342 | } | |
343 | } else { | |
344 | fMomentum[0] = -999.; | |
345 | fMomentum[1] = -999.; | |
346 | fMomentum[2] = -999.; | |
347 | } | |
348 | } | |
349 | ||
350 | //______________________________________________________________________________ | |
351 | template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca) | |
352 | { | |
353 | // set the position | |
354 | ||
355 | if (x) { | |
356 | if (!dca) { | |
357 | ResetBit(kIsDCA); | |
358 | ||
359 | fPosition[0] = x[0]; | |
360 | fPosition[1] = x[1]; | |
361 | fPosition[2] = x[2]; | |
362 | } else { | |
363 | SetBit(kIsDCA); | |
364 | // don't know any better yet | |
365 | fPosition[0] = -999.; | |
366 | fPosition[1] = -999.; | |
367 | fPosition[2] = -999.; | |
368 | } | |
369 | } else { | |
370 | ResetBit(kIsDCA); | |
371 | ||
372 | fPosition[0] = -999.; | |
373 | fPosition[1] = -999.; | |
374 | fPosition[2] = -999.; | |
375 | } | |
376 | } | |
377 | ||
378 | //______________________________________________________________________________ | |
379 | void AliAODTrack::SetDCA(Double_t d, Double_t z) | |
380 | { | |
381 | // set the dca | |
382 | fPosition[0] = d; | |
383 | fPosition[1] = z; | |
384 | fPosition[2] = 0.; | |
385 | SetBit(kIsDCA); | |
386 | } | |
387 | ||
388 | //______________________________________________________________________________ | |
389 | void AliAODTrack::Print(Option_t* /* option */) const | |
390 | { | |
391 | // prints information about AliAODTrack | |
392 | ||
393 | printf("Object name: %s Track type: %s\n", GetName(), GetTitle()); | |
394 | printf(" px = %f\n", Px()); | |
395 | printf(" py = %f\n", Py()); | |
396 | printf(" pz = %f\n", Pz()); | |
397 | printf(" pt = %f\n", Pt()); | |
398 | printf(" 1/pt = %f\n", OneOverPt()); | |
399 | printf(" theta = %f\n", Theta()); | |
400 | printf(" phi = %f\n", Phi()); | |
401 | printf(" chi2 = %f\n", Chi2()); | |
402 | printf(" charge = %d\n", Charge()); | |
403 | printf(" PID object: %p\n", PID()); | |
404 | } | |
405 |