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),
45 // default constructor
48 SetPosition((Float_t*)NULL);
49 SetXYAtDCA(-999., -999.);
50 SetPxPyPzAtDCA(-999., -999., -999.);
51 SetPID((Float_t*)NULL);
54 //______________________________________________________________________________
55 AliAODTrack::AliAODTrack(Short_t id,
61 Double_t covMatrix[21],
65 AliAODVertex *prodVertex,
67 Bool_t usedForPrimVtxFit,
72 fChi2perNDF(chi2perNDF),
73 fChi2MatchTrigger(0.),
76 fITSMuonClusterMap(0),
77 fFilterMap(selectInfo),
83 fProdVertex(prodVertex)
88 SetPosition(x, isDCA);
89 SetXYAtDCA(-999., -999.);
90 SetPxPyPzAtDCA(-999., -999., -999.);
91 SetUsedForVtxFit(usedForVtxFit);
92 SetUsedForPrimVtxFit(usedForPrimVtxFit);
93 if(covMatrix) SetCovMatrix(covMatrix);
95 SetITSClusterMap(itsClusMap);
98 //______________________________________________________________________________
99 AliAODTrack::AliAODTrack(Short_t id,
105 Float_t covMatrix[21],
109 AliAODVertex *prodVertex,
110 Bool_t usedForVtxFit,
111 Bool_t usedForPrimVtxFit,
114 Float_t chi2perNDF) :
116 fChi2perNDF(chi2perNDF),
117 fChi2MatchTrigger(0.),
120 fITSMuonClusterMap(0),
121 fFilterMap(selectInfo),
127 fProdVertex(prodVertex)
132 SetPosition(x, isDCA);
133 SetXYAtDCA(-999., -999.);
134 SetPxPyPzAtDCA(-999., -999., -999.);
135 SetUsedForVtxFit(usedForVtxFit);
136 SetUsedForPrimVtxFit(usedForPrimVtxFit);
137 if(covMatrix) SetCovMatrix(covMatrix);
139 SetITSClusterMap(itsClusMap);
142 //______________________________________________________________________________
143 AliAODTrack::~AliAODTrack()
151 //______________________________________________________________________________
152 AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
154 fChi2perNDF(trk.fChi2perNDF),
155 fChi2MatchTrigger(trk.fChi2MatchTrigger),
158 fITSMuonClusterMap(trk.fITSMuonClusterMap),
159 fFilterMap(trk.fFilterMap),
161 fCharge(trk.fCharge),
165 fProdVertex(trk.fProdVertex)
170 trk.GetPosition(fPosition);
171 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
172 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
173 SetUsedForVtxFit(trk.GetUsedForVtxFit());
174 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
175 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
176 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
180 //______________________________________________________________________________
181 AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
183 // Assignment operator
186 AliVTrack::operator=(trk);
189 trk.GetPosition(fPosition);
192 SetXYAtDCA(trk.XAtDCA(), trk.YAtDCA());
193 SetPxPyPzAtDCA(trk.PxAtDCA(), trk.PyAtDCA(), trk.PzAtDCA());
195 fChi2perNDF = trk.fChi2perNDF;
196 fChi2MatchTrigger = trk.fChi2MatchTrigger;
201 fITSMuonClusterMap = trk.fITSMuonClusterMap;
202 fFilterMap = trk.fFilterMap;
206 fCharge = trk.fCharge;
210 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
211 else fCovMatrix=NULL;
212 fProdVertex = trk.fProdVertex;
214 SetUsedForVtxFit(trk.GetUsedForVtxFit());
215 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
218 if(trk.fDetPid) fDetPid=new AliAODPid(*trk.fDetPid);
225 //______________________________________________________________________________
226 Double_t AliAODTrack::M(AODTrkPID_t pid) const
229 // Masses for nuclei don't exist in the PDG tables, therefore they were put by hand.
234 return 0.000510999; //TDatabasePDG::Instance()->GetParticle(11/*::kElectron*/)->Mass();
238 return 0.1056584; //TDatabasePDG::Instance()->GetParticle(13/*::kMuonMinus*/)->Mass();
242 return 0.13957; //TDatabasePDG::Instance()->GetParticle(211/*::kPiPlus*/)->Mass();
246 return 0.4937; //TDatabasePDG::Instance()->GetParticle(321/*::kKPlus*/)->Mass();
250 return 0.9382720; //TDatabasePDG::Instance()->GetParticle(2212/*::kProton*/)->Mass();
254 return 1.8756; //TDatabasePDG::Instance()->GetParticle(1000010020)->Mass();
258 return 2.8089; //TDatabasePDG::Instance()->GetParticle(1000010030)->Mass();
262 return 2.8084; //TDatabasePDG::Instance()->GetParticle(1000020030)->Mass();
266 return 3.7274; //TDatabasePDG::Instance()->GetParticle(1000020040)->Mass();
278 //______________________________________________________________________________
279 Double_t AliAODTrack::E(AODTrkPID_t pid) const
281 // Returns the energy of the particle of a given pid.
283 if (pid != kUnknown) { // particle was identified
285 return TMath::Sqrt(P()*P() + m*m);
286 } else { // pid unknown
291 //______________________________________________________________________________
292 Double_t AliAODTrack::Y(AODTrkPID_t pid) const
294 // Returns the rapidity of a particle of a given pid.
296 if (pid != kUnknown) { // particle was identified
299 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
300 return 0.5*TMath::Log((e+pz)/(e-pz));
301 } else { // energy not known or equal to pz
304 } else { // pid unknown
309 //______________________________________________________________________________
310 Double_t AliAODTrack::Y(Double_t m) const
312 // Returns the rapidity of a particle of a given mass.
314 if (m >= 0.) { // mass makes sense
317 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
318 return 0.5*TMath::Log((e+pz)/(e-pz));
319 } else { // energy not known or equal to pz
322 } else { // pid unknown
327 //______________________________________________________________________________
328 AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
330 // Returns the most probable PID array element.
334 AODTrkPID_t loc = kUnknown;
336 Bool_t allTheSame = kTRUE;
338 for (Int_t iPID = 0; iPID < nPID; iPID++) {
339 if (fPID[iPID] >= max) {
340 if (fPID[iPID] > max) {
343 loc = (AODTrkPID_t)iPID;
350 return allTheSame ? kUnknown : loc;
356 //______________________________________________________________________________
357 void AliAODTrack::ConvertAliPIDtoAODPID()
359 // Converts AliPID array.
360 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
361 // Everything else has to be set to zero.
363 fPID[kDeuteron] = 0.;
373 //______________________________________________________________________________
374 template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
380 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
381 Double_t pp = TMath::Sqrt(pt2 + p[2]*p[2]);
383 fMomentum[0] = TMath::Sqrt(pt2); // pt
384 fMomentum[1] = (pt2 != 0.) ? TMath::Pi()+TMath::ATan2(-p[1], -p[0]) : -999; // phi
385 fMomentum[2] = (pp != 0.) ? TMath::ACos(p[2] / pp) : -999.; // theta
387 fMomentum[0] = p[0]; // pt
388 fMomentum[1] = p[1]; // phi
389 fMomentum[2] = p[2]; // theta
392 fMomentum[0] = -999.;
393 fMomentum[1] = -999.;
394 fMomentum[2] = -999.;
398 //______________________________________________________________________________
399 template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
412 // don't know any better yet
413 fPosition[0] = -999.;
414 fPosition[1] = -999.;
415 fPosition[2] = -999.;
420 fPosition[0] = -999.;
421 fPosition[1] = -999.;
422 fPosition[2] = -999.;
426 //______________________________________________________________________________
427 void AliAODTrack::SetDCA(Double_t d, Double_t z)
436 //______________________________________________________________________________
437 void AliAODTrack::Print(Option_t* /* option */) const
439 // prints information about AliAODTrack
441 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
442 printf(" px = %f\n", Px());
443 printf(" py = %f\n", Py());
444 printf(" pz = %f\n", Pz());
445 printf(" pt = %f\n", Pt());
446 printf(" 1/pt = %f\n", OneOverPt());
447 printf(" theta = %f\n", Theta());
448 printf(" phi = %f\n", Phi());
449 printf(" chi2/NDF = %f\n", Chi2perNDF());
450 printf(" charge = %d\n", Charge());
453 void AliAODTrack::SetMatchTrigger(Int_t matchTrig){
455 // Set the MUON trigger information
457 case 0: // 0 track does not match trigger
458 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
460 case 1: // 1 track match but does not pass pt cut
461 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x40000000;
463 case 2: // 2 track match Low pt cut
464 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x80000000;
466 case 3: // 3 track match High pt cut
467 fITSMuonClusterMap=fITSMuonClusterMap|0xc0000000;
470 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
471 AliWarning(Form("unknown case for matchTrig: %d\n",matchTrig));
475 Int_t AliAODTrack::HitsMT(Int_t istation, Int_t iplane, Option_t *cathode){
477 // Retrieve hit information for MUON identified by (station, plane, cathode)
479 if(cathode[0]=='x'||cathode[0]=='X'){
482 return (fITSMuonClusterMap&0x8000)?1:0;
484 return (fITSMuonClusterMap&0x4000)?1:0;
487 }else if(istation==2){
489 return (fITSMuonClusterMap&0x2000)?1:0;
491 return (fITSMuonClusterMap&0x1000)?1:0;
497 }else if(cathode[0]=='y'||cathode[0]=='Y'){
500 return (fITSMuonClusterMap&0x0800)?1:0;
502 return (fITSMuonClusterMap&0x0400)?1:0;
505 }else if(istation==2){
507 return (fITSMuonClusterMap&0x0200)?1:0;
509 return (fITSMuonClusterMap&0x0100)?1:0;
521 return (HitsMT(1,1,"X")||HitsMT(1,1,"Y"))?1:0;
523 return (HitsMT(1,2,"X")||HitsMT(1,2,"Y"))?1:0;
526 }else if(istation==2){
528 return (HitsMT(2,1,"X")||HitsMT(2,1,"Y"))?1:0;
530 return (HitsMT(2,2,"X")||HitsMT(2,2,"Y"))?1:0;
539 Int_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber){
541 // Retrieve hit information for MUON Tracker/Trigger Chamber
542 // WARNING: chamber number start from 1 instead of 0
544 if (MuonChamber > 0 && MuonChamber < 11) {
545 return ((GetMUONClusterMap() & BIT(MuonChamber-1)) != 0) ? 1 : 0;
557 printf("Unknown MUON chamber: %d\n",MuonChamber);