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 implementation of AliVTrack
20 // Author: Markus Oldenburg, CERN
21 // Markus.Oldenburg@cern.ch
22 //-------------------------------------------------------------------------
25 #include "AliAODTrack.h"
29 //______________________________________________________________________________
30 AliAODTrack::AliAODTrack() :
33 fChi2MatchTrigger(0.),
36 fITSMuonClusterMap(0),
47 // default constructor
50 SetPosition((Float_t*)NULL);
51 SetXYAtDCA(-999., -999.);
52 SetPxPyPzAtDCA(-999., -999., -999.);
53 SetPID((Float_t*)NULL);
56 //______________________________________________________________________________
57 AliAODTrack::AliAODTrack(Short_t id,
63 Double_t covMatrix[21],
67 AliAODVertex *prodVertex,
69 Bool_t usedForPrimVtxFit,
74 fChi2perNDF(chi2perNDF),
75 fChi2MatchTrigger(0.),
78 fITSMuonClusterMap(0),
79 fFilterMap(selectInfo),
87 fProdVertex(prodVertex)
92 SetPosition(x, isDCA);
93 SetXYAtDCA(-999., -999.);
94 SetPxPyPzAtDCA(-999., -999., -999.);
95 SetUsedForVtxFit(usedForVtxFit);
96 SetUsedForPrimVtxFit(usedForPrimVtxFit);
97 if(covMatrix) SetCovMatrix(covMatrix);
99 SetITSClusterMap(itsClusMap);
102 //______________________________________________________________________________
103 AliAODTrack::AliAODTrack(Short_t id,
109 Float_t covMatrix[21],
113 AliAODVertex *prodVertex,
114 Bool_t usedForVtxFit,
115 Bool_t usedForPrimVtxFit,
118 Float_t chi2perNDF) :
120 fChi2perNDF(chi2perNDF),
121 fChi2MatchTrigger(0.),
124 fITSMuonClusterMap(0),
125 fFilterMap(selectInfo),
133 fProdVertex(prodVertex)
138 SetPosition(x, isDCA);
139 SetXYAtDCA(-999., -999.);
140 SetPxPyPzAtDCA(-999., -999., -999.);
141 SetUsedForVtxFit(usedForVtxFit);
142 SetUsedForPrimVtxFit(usedForPrimVtxFit);
143 if(covMatrix) SetCovMatrix(covMatrix);
145 SetITSClusterMap(itsClusMap);
148 //______________________________________________________________________________
149 AliAODTrack::~AliAODTrack()
157 //______________________________________________________________________________
158 AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
160 fChi2perNDF(trk.fChi2perNDF),
161 fChi2MatchTrigger(trk.fChi2MatchTrigger),
164 fITSMuonClusterMap(trk.fITSMuonClusterMap),
165 fFilterMap(trk.fFilterMap),
166 fTPCClusterMap(trk.fTPCClusterMap),
167 fTPCSharedMap(trk.fTPCSharedMap),
169 fCharge(trk.fCharge),
173 fProdVertex(trk.fProdVertex)
178 trk.GetPosition(fPosition);
179 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
180 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
181 SetUsedForVtxFit(trk.GetUsedForVtxFit());
182 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
183 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
184 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
188 //______________________________________________________________________________
189 AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
191 // Assignment operator
194 AliVTrack::operator=(trk);
197 trk.GetPosition(fPosition);
200 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
201 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
203 fChi2perNDF = trk.fChi2perNDF;
204 fChi2MatchTrigger = trk.fChi2MatchTrigger;
209 fITSMuonClusterMap = trk.fITSMuonClusterMap;
210 fFilterMap = trk.fFilterMap;
214 fCharge = trk.fCharge;
218 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
219 else fCovMatrix=NULL;
220 fProdVertex = trk.fProdVertex;
222 SetUsedForVtxFit(trk.GetUsedForVtxFit());
223 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
226 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
233 //______________________________________________________________________________
234 Double_t AliAODTrack::M(AODTrkPID_t pid) const
237 // Masses for nuclei don't exist in the PDG tables, therefore they were put by hand.
242 return 0.000510999; //TDatabasePDG::Instance()->GetParticle(11/*::kElectron*/)->Mass();
246 return 0.1056584; //TDatabasePDG::Instance()->GetParticle(13/*::kMuonMinus*/)->Mass();
250 return 0.13957; //TDatabasePDG::Instance()->GetParticle(211/*::kPiPlus*/)->Mass();
254 return 0.4937; //TDatabasePDG::Instance()->GetParticle(321/*::kKPlus*/)->Mass();
258 return 0.9382720; //TDatabasePDG::Instance()->GetParticle(2212/*::kProton*/)->Mass();
262 return 1.8756; //TDatabasePDG::Instance()->GetParticle(1000010020)->Mass();
266 return 2.8089; //TDatabasePDG::Instance()->GetParticle(1000010030)->Mass();
270 return 2.8084; //TDatabasePDG::Instance()->GetParticle(1000020030)->Mass();
274 return 3.7274; //TDatabasePDG::Instance()->GetParticle(1000020040)->Mass();
286 //______________________________________________________________________________
287 Double_t AliAODTrack::E(AODTrkPID_t pid) const
289 // Returns the energy of the particle of a given pid.
291 if (pid != kUnknown) { // particle was identified
293 return TMath::Sqrt(P()*P() + m*m);
294 } else { // pid unknown
299 //______________________________________________________________________________
300 Double_t AliAODTrack::Y(AODTrkPID_t pid) const
302 // Returns the rapidity of a particle of a given pid.
304 if (pid != kUnknown) { // particle was identified
307 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
308 return 0.5*TMath::Log((e+pz)/(e-pz));
309 } else { // energy not known or equal to pz
312 } else { // pid unknown
317 //______________________________________________________________________________
318 Double_t AliAODTrack::Y(Double_t m) const
320 // Returns the rapidity of a particle of a given mass.
322 if (m >= 0.) { // mass makes sense
325 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
326 return 0.5*TMath::Log((e+pz)/(e-pz));
327 } else { // energy not known or equal to pz
330 } else { // pid unknown
335 //______________________________________________________________________________
336 AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
338 // Returns the most probable PID array element.
342 AODTrkPID_t loc = kUnknown;
344 Bool_t allTheSame = kTRUE;
346 for (Int_t iPID = 0; iPID < nPID; iPID++) {
347 if (fPID[iPID] >= max) {
348 if (fPID[iPID] > max) {
351 loc = (AODTrkPID_t)iPID;
358 return allTheSame ? kUnknown : loc;
364 //______________________________________________________________________________
365 void AliAODTrack::ConvertAliPIDtoAODPID()
367 // Converts AliPID array.
368 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
369 // Everything else has to be set to zero.
371 fPID[kDeuteron] = 0.;
381 //______________________________________________________________________________
382 template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
388 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
389 Double_t pp = TMath::Sqrt(pt2 + p[2]*p[2]);
391 fMomentum[0] = TMath::Sqrt(pt2); // pt
392 fMomentum[1] = (pt2 != 0.) ? TMath::Pi()+TMath::ATan2(-p[1], -p[0]) : -999; // phi
393 fMomentum[2] = (pp != 0.) ? TMath::ACos(p[2] / pp) : -999.; // theta
395 fMomentum[0] = p[0]; // pt
396 fMomentum[1] = p[1]; // phi
397 fMomentum[2] = p[2]; // theta
400 fMomentum[0] = -999.;
401 fMomentum[1] = -999.;
402 fMomentum[2] = -999.;
406 //______________________________________________________________________________
407 template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
420 // don't know any better yet
421 fPosition[0] = -999.;
422 fPosition[1] = -999.;
423 fPosition[2] = -999.;
428 fPosition[0] = -999.;
429 fPosition[1] = -999.;
430 fPosition[2] = -999.;
434 //______________________________________________________________________________
435 void AliAODTrack::SetDCA(Double_t d, Double_t z)
444 //______________________________________________________________________________
445 void AliAODTrack::Print(Option_t* /* option */) const
447 // prints information about AliAODTrack
449 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
450 printf(" px = %f\n", Px());
451 printf(" py = %f\n", Py());
452 printf(" pz = %f\n", Pz());
453 printf(" pt = %f\n", Pt());
454 printf(" 1/pt = %f\n", OneOverPt());
455 printf(" theta = %f\n", Theta());
456 printf(" phi = %f\n", Phi());
457 printf(" chi2/NDF = %f\n", Chi2perNDF());
458 printf(" charge = %d\n", Charge());
461 //______________________________________________________________________________
462 void AliAODTrack::SetMatchTrigger(Int_t matchTrig)
464 // Set the MUON trigger information
466 case 0: // 0 track does not match trigger
467 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
469 case 1: // 1 track match but does not pass pt cut
470 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x40000000;
472 case 2: // 2 track match Low pt cut
473 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x80000000;
475 case 3: // 3 track match High pt cut
476 fITSMuonClusterMap=fITSMuonClusterMap|0xc0000000;
479 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
480 AliWarning(Form("unknown case for matchTrig: %d\n",matchTrig));
484 //______________________________________________________________________________
485 Bool_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber, Int_t cathode) const
487 // return kTRUE if the track fires the given tracking or trigger chamber.
488 // If the chamber is a trigger one:
489 // - if cathode = 0 or 1, the track matches the corresponding cathode
490 // - if cathode = -1, the track matches both cathodes
492 if (MuonChamber < 0) return kFALSE;
494 if (MuonChamber < 10) return TESTBIT(GetMUONClusterMap(), MuonChamber);
496 if (MuonChamber < 14) {
498 if (cathode < 0) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber) &&
499 TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+4);
501 if (cathode < 2) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+(1-cathode)*4);
508 //______________________________________________________________________________
509 Bool_t AliAODTrack::MatchTriggerDigits() const
511 // return kTRUE if the track matches a digit on both planes of at least 2 trigger chambers
513 Int_t nMatchedChambers = 0;
514 for (Int_t ich=10; ich<14; ich++) if (HitsMuonChamber(ich)) nMatchedChambers++;
516 return (nMatchedChambers >= 2);