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 "AliExternalTrackParam.h"
26 #include "AliVVertex.h"
27 #include "AliAODTrack.h"
31 //______________________________________________________________________________
32 AliAODTrack::AliAODTrack() :
36 fChi2MatchTrigger(0.),
39 fITSMuonClusterMap(0),
50 // default constructor
53 SetPosition((Float_t*)NULL);
54 SetXYAtDCA(-999., -999.);
55 SetPxPyPzAtDCA(-999., -999., -999.);
56 SetPID((Float_t*)NULL);
59 //______________________________________________________________________________
60 AliAODTrack::AliAODTrack(Short_t id,
66 Double_t covMatrix[21],
70 AliAODVertex *prodVertex,
72 Bool_t usedForPrimVtxFit,
78 fChi2perNDF(chi2perNDF),
79 fChi2MatchTrigger(0.),
82 fITSMuonClusterMap(0),
83 fFilterMap(selectInfo),
91 fProdVertex(prodVertex)
96 SetPosition(x, isDCA);
97 SetXYAtDCA(-999., -999.);
98 SetPxPyPzAtDCA(-999., -999., -999.);
99 SetUsedForVtxFit(usedForVtxFit);
100 SetUsedForPrimVtxFit(usedForPrimVtxFit);
101 if(covMatrix) SetCovMatrix(covMatrix);
103 SetITSClusterMap(itsClusMap);
106 //______________________________________________________________________________
107 AliAODTrack::AliAODTrack(Short_t id,
113 Float_t covMatrix[21],
117 AliAODVertex *prodVertex,
118 Bool_t usedForVtxFit,
119 Bool_t usedForPrimVtxFit,
122 Float_t chi2perNDF) :
125 fChi2perNDF(chi2perNDF),
126 fChi2MatchTrigger(0.),
129 fITSMuonClusterMap(0),
130 fFilterMap(selectInfo),
138 fProdVertex(prodVertex)
143 SetPosition(x, isDCA);
144 SetXYAtDCA(-999., -999.);
145 SetPxPyPzAtDCA(-999., -999., -999.);
146 SetUsedForVtxFit(usedForVtxFit);
147 SetUsedForPrimVtxFit(usedForPrimVtxFit);
148 if(covMatrix) SetCovMatrix(covMatrix);
150 SetITSClusterMap(itsClusMap);
153 //______________________________________________________________________________
154 AliAODTrack::~AliAODTrack()
162 //______________________________________________________________________________
163 AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
165 fRAtAbsorberEnd(trk.fRAtAbsorberEnd),
166 fChi2perNDF(trk.fChi2perNDF),
167 fChi2MatchTrigger(trk.fChi2MatchTrigger),
170 fITSMuonClusterMap(trk.fITSMuonClusterMap),
171 fFilterMap(trk.fFilterMap),
172 fTPCClusterMap(trk.fTPCClusterMap),
173 fTPCSharedMap(trk.fTPCSharedMap),
175 fCharge(trk.fCharge),
179 fProdVertex(trk.fProdVertex)
184 trk.GetPosition(fPosition);
185 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
186 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
187 SetUsedForVtxFit(trk.GetUsedForVtxFit());
188 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
189 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
190 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
194 //______________________________________________________________________________
195 AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
197 // Assignment operator
200 AliVTrack::operator=(trk);
203 trk.GetPosition(fPosition);
206 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
207 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
209 fRAtAbsorberEnd = trk.fRAtAbsorberEnd;
211 fChi2perNDF = trk.fChi2perNDF;
212 fChi2MatchTrigger = trk.fChi2MatchTrigger;
217 fITSMuonClusterMap = trk.fITSMuonClusterMap;
218 fFilterMap = trk.fFilterMap;
222 fCharge = trk.fCharge;
226 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
227 else fCovMatrix=NULL;
228 fProdVertex = trk.fProdVertex;
230 SetUsedForVtxFit(trk.GetUsedForVtxFit());
231 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
234 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
241 //______________________________________________________________________________
242 Double_t AliAODTrack::M(AODTrkPID_t pid) const
245 // Masses for nuclei don't exist in the PDG tables, therefore they were put by hand.
250 return 0.000510999; //TDatabasePDG::Instance()->GetParticle(11/*::kElectron*/)->Mass();
254 return 0.1056584; //TDatabasePDG::Instance()->GetParticle(13/*::kMuonMinus*/)->Mass();
258 return 0.13957; //TDatabasePDG::Instance()->GetParticle(211/*::kPiPlus*/)->Mass();
262 return 0.4937; //TDatabasePDG::Instance()->GetParticle(321/*::kKPlus*/)->Mass();
266 return 0.9382720; //TDatabasePDG::Instance()->GetParticle(2212/*::kProton*/)->Mass();
270 return 1.8756; //TDatabasePDG::Instance()->GetParticle(1000010020)->Mass();
274 return 2.8089; //TDatabasePDG::Instance()->GetParticle(1000010030)->Mass();
278 return 2.8084; //TDatabasePDG::Instance()->GetParticle(1000020030)->Mass();
282 return 3.7274; //TDatabasePDG::Instance()->GetParticle(1000020040)->Mass();
294 //______________________________________________________________________________
295 Double_t AliAODTrack::E(AODTrkPID_t pid) const
297 // Returns the energy of the particle of a given pid.
299 if (pid != kUnknown) { // particle was identified
301 return TMath::Sqrt(P()*P() + m*m);
302 } else { // pid unknown
307 //______________________________________________________________________________
308 Double_t AliAODTrack::Y(AODTrkPID_t pid) const
310 // Returns the rapidity of a particle of a given pid.
312 if (pid != kUnknown) { // particle was identified
315 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
316 return 0.5*TMath::Log((e+pz)/(e-pz));
317 } else { // energy not known or equal to pz
320 } else { // pid unknown
325 //______________________________________________________________________________
326 Double_t AliAODTrack::Y(Double_t m) const
328 // Returns the rapidity of a particle of a given mass.
330 if (m >= 0.) { // mass makes sense
333 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
334 return 0.5*TMath::Log((e+pz)/(e-pz));
335 } else { // energy not known or equal to pz
338 } else { // pid unknown
343 //______________________________________________________________________________
344 AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
346 // Returns the most probable PID array element.
350 AODTrkPID_t loc = kUnknown;
352 Bool_t allTheSame = kTRUE;
354 for (Int_t iPID = 0; iPID < nPID; iPID++) {
355 if (fPID[iPID] >= max) {
356 if (fPID[iPID] > max) {
359 loc = (AODTrkPID_t)iPID;
366 return allTheSame ? kUnknown : loc;
372 //______________________________________________________________________________
373 void AliAODTrack::ConvertAliPIDtoAODPID()
375 // Converts AliPID array.
376 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
377 // Everything else has to be set to zero.
379 fPID[kDeuteron] = 0.;
389 //______________________________________________________________________________
390 template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
396 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
397 Double_t pp = TMath::Sqrt(pt2 + p[2]*p[2]);
399 fMomentum[0] = TMath::Sqrt(pt2); // pt
400 fMomentum[1] = (pt2 != 0.) ? TMath::Pi()+TMath::ATan2(-p[1], -p[0]) : -999; // phi
401 fMomentum[2] = (pp != 0.) ? TMath::ACos(p[2] / pp) : -999.; // theta
403 fMomentum[0] = p[0]; // pt
404 fMomentum[1] = p[1]; // phi
405 fMomentum[2] = p[2]; // theta
408 fMomentum[0] = -999.;
409 fMomentum[1] = -999.;
410 fMomentum[2] = -999.;
414 //______________________________________________________________________________
415 template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
428 // don't know any better yet
429 fPosition[0] = -999.;
430 fPosition[1] = -999.;
431 fPosition[2] = -999.;
436 fPosition[0] = -999.;
437 fPosition[1] = -999.;
438 fPosition[2] = -999.;
442 //______________________________________________________________________________
443 void AliAODTrack::SetDCA(Double_t d, Double_t z)
452 //______________________________________________________________________________
453 void AliAODTrack::Print(Option_t* /* option */) const
455 // prints information about AliAODTrack
457 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
458 printf(" px = %f\n", Px());
459 printf(" py = %f\n", Py());
460 printf(" pz = %f\n", Pz());
461 printf(" pt = %f\n", Pt());
462 printf(" 1/pt = %f\n", OneOverPt());
463 printf(" theta = %f\n", Theta());
464 printf(" phi = %f\n", Phi());
465 printf(" chi2/NDF = %f\n", Chi2perNDF());
466 printf(" charge = %d\n", Charge());
469 //______________________________________________________________________________
470 void AliAODTrack::SetMatchTrigger(Int_t matchTrig)
472 // Set the MUON trigger information
474 case 0: // 0 track does not match trigger
475 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
477 case 1: // 1 track match but does not pass pt cut
478 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x40000000;
480 case 2: // 2 track match Low pt cut
481 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x80000000;
483 case 3: // 3 track match High pt cut
484 fITSMuonClusterMap=fITSMuonClusterMap|0xc0000000;
487 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
488 AliWarning(Form("unknown case for matchTrig: %d\n",matchTrig));
492 //______________________________________________________________________________
493 Bool_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber, Int_t cathode) const
495 // return kTRUE if the track fires the given tracking or trigger chamber.
496 // If the chamber is a trigger one:
497 // - if cathode = 0 or 1, the track matches the corresponding cathode
498 // - if cathode = -1, the track matches both cathodes
500 if (MuonChamber < 0) return kFALSE;
502 if (MuonChamber < 10) return TESTBIT(GetMUONClusterMap(), MuonChamber);
504 if (MuonChamber < 14) {
506 if (cathode < 0) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber) &&
507 TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+4);
509 if (cathode < 2) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+(1-cathode)*4);
516 //______________________________________________________________________________
517 Bool_t AliAODTrack::MatchTriggerDigits() const
519 // return kTRUE if the track matches a digit on both planes of at least 2 trigger chambers
521 Int_t nMatchedChambers = 0;
522 for (Int_t ich=10; ich<14; ich++) if (HitsMuonChamber(ich)) nMatchedChambers++;
524 return (nMatchedChambers >= 2);
527 //______________________________________________________________________________
528 Bool_t AliAODTrack::PropagateToDCA(const AliVVertex *vtx,
529 Double_t b, Double_t maxd, Double_t dz[2], Double_t covar[3])
531 // compute impact parameters to the vertex vtx and their covariance matrix
532 // b is the Bz, needed to propagate correctly the track to vertex
533 // only the track parameters are update after the propagation (pos and mom),
534 // not the covariance matrix. This is OK for propagation over short distance
535 // inside the beam pipe.
536 // return kFALSE is something went wrong
538 // convert to AliExternalTrackParam
539 AliExternalTrackParam etp(this);
541 Float_t xstart = etp.GetX();
543 AliError("This method can be used only for propagation inside the beam pipe");
547 if(!etp.PropagateToDCA(vtx,b,maxd,dz,covar)) return kFALSE;
549 // update track position and momentum
554 SetPosition(mom,kFALSE);
560 //______________________________________________________________________________
561 Bool_t AliAODTrack::GetPxPyPz(Double_t p[3]) const
563 //---------------------------------------------------------------------
564 // This function returns the global track momentum components
565 //---------------------------------------------------------------------
566 p[0]=Px(); p[1]=Py(); p[2]=Pz();