1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // AOD track base class
20 // Author: Markus Oldenburg, CERN
21 //-------------------------------------------------------------------------
23 #include "AliAODTrack.h"
27 //______________________________________________________________________________
28 AliAODTrack::AliAODTrack() :
36 fITSMuonClusterMap(0),
39 // default constructor
42 SetPosition((Float_t*)NULL);
43 SetPID((Float_t*)NULL);
46 //______________________________________________________________________________
47 AliAODTrack::AliAODTrack(Int_t id,
53 Double_t covMatrix[21],
57 AliAODVertex *prodVertex,
59 Bool_t usedForPrimVtxFit,
66 fProdVertex(prodVertex),
68 fITSMuonClusterMap(itsClusMap),
74 SetPosition(x, isDCA);
75 SetUsedForVtxFit(usedForVtxFit);
76 SetUsedForPrimVtxFit(usedForPrimVtxFit);
77 if(covMatrix) SetCovMatrix(covMatrix);
82 //______________________________________________________________________________
83 AliAODTrack::AliAODTrack(Int_t id,
89 Float_t covMatrix[21],
93 AliAODVertex *prodVertex,
95 Bool_t usedForPrimVtxFit,
102 fProdVertex(prodVertex),
104 fITSMuonClusterMap(itsClusMap),
110 SetPosition(x, isDCA);
111 SetUsedForVtxFit(usedForVtxFit);
112 SetUsedForPrimVtxFit(usedForPrimVtxFit);
113 if(covMatrix) SetCovMatrix(covMatrix);
117 //______________________________________________________________________________
118 AliAODTrack::~AliAODTrack()
125 //______________________________________________________________________________
126 AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
127 AliVirtualParticle(trk),
128 fChi2perNDF(trk.fChi2perNDF),
132 fProdVertex(trk.fProdVertex),
133 fCharge(trk.fCharge),
134 fITSMuonClusterMap(trk.fITSMuonClusterMap),
140 trk.GetPosition(fPosition);
141 SetUsedForVtxFit(trk.GetUsedForVtxFit());
142 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
143 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
148 //______________________________________________________________________________
149 AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
151 // Assignment operator
154 AliVirtualParticle::operator=(trk);
157 trk.GetPosition(fPosition);
160 fChi2perNDF = trk.fChi2perNDF;
166 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
167 else fCovMatrix=NULL;
168 fProdVertex = trk.fProdVertex;
170 fCharge = trk.fCharge;
171 fITSMuonClusterMap = trk.fITSMuonClusterMap;
172 SetUsedForVtxFit(trk.GetUsedForVtxFit());
173 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
180 //______________________________________________________________________________
181 Double_t AliAODTrack::M(AODTrkPID_t pid) const
184 // In the case of elementary particles the hard coded mass values were taken
185 // from the PDG. In all cases the errors on the values do not affect
236 //______________________________________________________________________________
237 Double_t AliAODTrack::E(AODTrkPID_t pid) const
239 // Returns the energy of the particle of a given pid.
241 if (pid != kUnknown) { // particle was identified
243 return TMath::Sqrt(P()*P() + m*m);
244 } else { // pid unknown
249 //______________________________________________________________________________
250 Double_t AliAODTrack::Y(AODTrkPID_t pid) const
252 // Returns the energy of the particle of a given pid.
254 if (pid != kUnknown) { // particle was identified
257 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
258 return 0.5*TMath::Log((e+pz)/(e-pz));
259 } else { // energy not known or equal to pz
262 } else { // pid unknown
267 //______________________________________________________________________________
268 Double_t AliAODTrack::Y(Double_t m) const
270 // Returns the energy of the particle of a given mass.
272 if (m >= 0.) { // mass makes sense
275 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
276 return 0.5*TMath::Log((e+pz)/(e-pz));
277 } else { // energy not known or equal to pz
280 } else { // pid unknown
285 //______________________________________________________________________________
286 AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
288 // Returns the most probable PID array element.
292 AODTrkPID_t loc = kUnknown;
294 Bool_t allTheSame = kTRUE;
296 for (Int_t iPID = 0; iPID < nPID; iPID++) {
297 if (fPID[iPID] >= max) {
298 if (fPID[iPID] > max) {
301 loc = (AODTrkPID_t)iPID;
308 return allTheSame ? kUnknown : loc;
314 //______________________________________________________________________________
315 void AliAODTrack::ConvertAliPIDtoAODPID()
317 // Converts AliPID array.
318 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
319 // Everything else has to be set to zero.
321 fPID[kDeuteron] = 0.;
331 //______________________________________________________________________________
332 template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
338 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
339 Double_t P = TMath::Sqrt(pt2 + p[2]*p[2]);
341 fMomentum[0] = TMath::Sqrt(pt2); // pt
342 fMomentum[1] = (pt2 != 0.) ? TMath::ATan2(p[1], p[0]) : -999; // phi
343 fMomentum[2] = (P != 0.) ? TMath::ACos(p[2]/P) : -999.; // theta
345 fMomentum[0] = p[0]; // pt
346 fMomentum[1] = p[1]; // phi
347 fMomentum[2] = p[2]; // theta
350 fMomentum[0] = -999.;
351 fMomentum[1] = -999.;
352 fMomentum[2] = -999.;
356 //______________________________________________________________________________
357 template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
370 // don't know any better yet
371 fPosition[0] = -999.;
372 fPosition[1] = -999.;
373 fPosition[2] = -999.;
378 fPosition[0] = -999.;
379 fPosition[1] = -999.;
380 fPosition[2] = -999.;
384 //______________________________________________________________________________
385 void AliAODTrack::SetDCA(Double_t d, Double_t z)
394 //______________________________________________________________________________
395 void AliAODTrack::Print(Option_t* /* option */) const
397 // prints information about AliAODTrack
399 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
400 printf(" px = %f\n", Px());
401 printf(" py = %f\n", Py());
402 printf(" pz = %f\n", Pz());
403 printf(" pt = %f\n", Pt());
404 printf(" 1/pt = %f\n", OneOverPt());
405 printf(" theta = %f\n", Theta());
406 printf(" phi = %f\n", Phi());
407 printf(" chi2/NDF = %f\n", Chi2perNDF());
408 printf(" charge = %d\n", Charge());
409 printf(" PID object: %p\n", PID());