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() :
34 fChi2MatchTrigger(0.),
37 fITSMuonClusterMap(0),
48 // default constructor
51 SetPosition((Float_t*)NULL);
52 SetXYAtDCA(-999., -999.);
53 SetPxPyPzAtDCA(-999., -999., -999.);
54 SetPID((Float_t*)NULL);
57 //______________________________________________________________________________
58 AliAODTrack::AliAODTrack(Short_t id,
64 Double_t covMatrix[21],
68 AliAODVertex *prodVertex,
70 Bool_t usedForPrimVtxFit,
76 fChi2perNDF(chi2perNDF),
77 fChi2MatchTrigger(0.),
80 fITSMuonClusterMap(0),
81 fFilterMap(selectInfo),
89 fProdVertex(prodVertex)
94 SetPosition(x, isDCA);
95 SetXYAtDCA(-999., -999.);
96 SetPxPyPzAtDCA(-999., -999., -999.);
97 SetUsedForVtxFit(usedForVtxFit);
98 SetUsedForPrimVtxFit(usedForPrimVtxFit);
99 if(covMatrix) SetCovMatrix(covMatrix);
101 SetITSClusterMap(itsClusMap);
104 //______________________________________________________________________________
105 AliAODTrack::AliAODTrack(Short_t id,
111 Float_t covMatrix[21],
115 AliAODVertex *prodVertex,
116 Bool_t usedForVtxFit,
117 Bool_t usedForPrimVtxFit,
120 Float_t chi2perNDF) :
123 fChi2perNDF(chi2perNDF),
124 fChi2MatchTrigger(0.),
127 fITSMuonClusterMap(0),
128 fFilterMap(selectInfo),
136 fProdVertex(prodVertex)
141 SetPosition(x, isDCA);
142 SetXYAtDCA(-999., -999.);
143 SetPxPyPzAtDCA(-999., -999., -999.);
144 SetUsedForVtxFit(usedForVtxFit);
145 SetUsedForPrimVtxFit(usedForPrimVtxFit);
146 if(covMatrix) SetCovMatrix(covMatrix);
148 SetITSClusterMap(itsClusMap);
151 //______________________________________________________________________________
152 AliAODTrack::~AliAODTrack()
160 //______________________________________________________________________________
161 AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
163 fRAtAbsorberEnd(trk.fRAtAbsorberEnd),
164 fChi2perNDF(trk.fChi2perNDF),
165 fChi2MatchTrigger(trk.fChi2MatchTrigger),
168 fITSMuonClusterMap(trk.fITSMuonClusterMap),
169 fFilterMap(trk.fFilterMap),
170 fTPCClusterMap(trk.fTPCClusterMap),
171 fTPCSharedMap(trk.fTPCSharedMap),
173 fCharge(trk.fCharge),
177 fProdVertex(trk.fProdVertex)
182 trk.GetPosition(fPosition);
183 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
184 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
185 SetUsedForVtxFit(trk.GetUsedForVtxFit());
186 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
187 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
188 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
192 //______________________________________________________________________________
193 AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
195 // Assignment operator
198 AliVTrack::operator=(trk);
201 trk.GetPosition(fPosition);
204 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
205 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
207 fRAtAbsorberEnd = trk.fRAtAbsorberEnd;
209 fChi2perNDF = trk.fChi2perNDF;
210 fChi2MatchTrigger = trk.fChi2MatchTrigger;
215 fITSMuonClusterMap = trk.fITSMuonClusterMap;
216 fFilterMap = trk.fFilterMap;
220 fCharge = trk.fCharge;
224 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
225 else fCovMatrix=NULL;
226 fProdVertex = trk.fProdVertex;
228 SetUsedForVtxFit(trk.GetUsedForVtxFit());
229 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
232 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
239 //______________________________________________________________________________
240 Double_t AliAODTrack::M(AODTrkPID_t pid) const
243 // Masses for nuclei don't exist in the PDG tables, therefore they were put by hand.
248 return 0.000510999; //TDatabasePDG::Instance()->GetParticle(11/*::kElectron*/)->Mass();
252 return 0.1056584; //TDatabasePDG::Instance()->GetParticle(13/*::kMuonMinus*/)->Mass();
256 return 0.13957; //TDatabasePDG::Instance()->GetParticle(211/*::kPiPlus*/)->Mass();
260 return 0.4937; //TDatabasePDG::Instance()->GetParticle(321/*::kKPlus*/)->Mass();
264 return 0.9382720; //TDatabasePDG::Instance()->GetParticle(2212/*::kProton*/)->Mass();
268 return 1.8756; //TDatabasePDG::Instance()->GetParticle(1000010020)->Mass();
272 return 2.8089; //TDatabasePDG::Instance()->GetParticle(1000010030)->Mass();
276 return 2.8084; //TDatabasePDG::Instance()->GetParticle(1000020030)->Mass();
280 return 3.7274; //TDatabasePDG::Instance()->GetParticle(1000020040)->Mass();
292 //______________________________________________________________________________
293 Double_t AliAODTrack::E(AODTrkPID_t pid) const
295 // Returns the energy of the particle of a given pid.
297 if (pid != kUnknown) { // particle was identified
299 return TMath::Sqrt(P()*P() + m*m);
300 } else { // pid unknown
305 //______________________________________________________________________________
306 Double_t AliAODTrack::Y(AODTrkPID_t pid) const
308 // Returns the rapidity of a particle of a given pid.
310 if (pid != kUnknown) { // particle was identified
313 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
314 return 0.5*TMath::Log((e+pz)/(e-pz));
315 } else { // energy not known or equal to pz
318 } else { // pid unknown
323 //______________________________________________________________________________
324 Double_t AliAODTrack::Y(Double_t m) const
326 // Returns the rapidity of a particle of a given mass.
328 if (m >= 0.) { // mass makes sense
331 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
332 return 0.5*TMath::Log((e+pz)/(e-pz));
333 } else { // energy not known or equal to pz
336 } else { // pid unknown
341 //______________________________________________________________________________
342 AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
344 // Returns the most probable PID array element.
348 AODTrkPID_t loc = kUnknown;
350 Bool_t allTheSame = kTRUE;
352 for (Int_t iPID = 0; iPID < nPID; iPID++) {
353 if (fPID[iPID] >= max) {
354 if (fPID[iPID] > max) {
357 loc = (AODTrkPID_t)iPID;
364 return allTheSame ? kUnknown : loc;
370 //______________________________________________________________________________
371 void AliAODTrack::ConvertAliPIDtoAODPID()
373 // Converts AliPID array.
374 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
375 // Everything else has to be set to zero.
377 fPID[kDeuteron] = 0.;
387 //______________________________________________________________________________
388 template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
394 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
395 Double_t pp = TMath::Sqrt(pt2 + p[2]*p[2]);
397 fMomentum[0] = TMath::Sqrt(pt2); // pt
398 fMomentum[1] = (pt2 != 0.) ? TMath::Pi()+TMath::ATan2(-p[1], -p[0]) : -999; // phi
399 fMomentum[2] = (pp != 0.) ? TMath::ACos(p[2] / pp) : -999.; // theta
401 fMomentum[0] = p[0]; // pt
402 fMomentum[1] = p[1]; // phi
403 fMomentum[2] = p[2]; // theta
406 fMomentum[0] = -999.;
407 fMomentum[1] = -999.;
408 fMomentum[2] = -999.;
412 //______________________________________________________________________________
413 template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
426 // don't know any better yet
427 fPosition[0] = -999.;
428 fPosition[1] = -999.;
429 fPosition[2] = -999.;
434 fPosition[0] = -999.;
435 fPosition[1] = -999.;
436 fPosition[2] = -999.;
440 //______________________________________________________________________________
441 void AliAODTrack::SetDCA(Double_t d, Double_t z)
450 //______________________________________________________________________________
451 void AliAODTrack::Print(Option_t* /* option */) const
453 // prints information about AliAODTrack
455 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
456 printf(" px = %f\n", Px());
457 printf(" py = %f\n", Py());
458 printf(" pz = %f\n", Pz());
459 printf(" pt = %f\n", Pt());
460 printf(" 1/pt = %f\n", OneOverPt());
461 printf(" theta = %f\n", Theta());
462 printf(" phi = %f\n", Phi());
463 printf(" chi2/NDF = %f\n", Chi2perNDF());
464 printf(" charge = %d\n", Charge());
467 //______________________________________________________________________________
468 void AliAODTrack::SetMatchTrigger(Int_t matchTrig)
470 // Set the MUON trigger information
472 case 0: // 0 track does not match trigger
473 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
475 case 1: // 1 track match but does not pass pt cut
476 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x40000000;
478 case 2: // 2 track match Low pt cut
479 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x80000000;
481 case 3: // 3 track match High pt cut
482 fITSMuonClusterMap=fITSMuonClusterMap|0xc0000000;
485 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
486 AliWarning(Form("unknown case for matchTrig: %d\n",matchTrig));
490 //______________________________________________________________________________
491 Bool_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber, Int_t cathode) const
493 // return kTRUE if the track fires the given tracking or trigger chamber.
494 // If the chamber is a trigger one:
495 // - if cathode = 0 or 1, the track matches the corresponding cathode
496 // - if cathode = -1, the track matches both cathodes
498 if (MuonChamber < 0) return kFALSE;
500 if (MuonChamber < 10) return TESTBIT(GetMUONClusterMap(), MuonChamber);
502 if (MuonChamber < 14) {
504 if (cathode < 0) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber) &&
505 TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+4);
507 if (cathode < 2) return TESTBIT(GetHitsPatternInTrigCh(), 13-MuonChamber+(1-cathode)*4);
514 //______________________________________________________________________________
515 Bool_t AliAODTrack::MatchTriggerDigits() const
517 // return kTRUE if the track matches a digit on both planes of at least 2 trigger chambers
519 Int_t nMatchedChambers = 0;
520 for (Int_t ich=10; ich<14; ich++) if (HitsMuonChamber(ich)) nMatchedChambers++;
522 return (nMatchedChambers >= 2);