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 AliVParticle
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 AliVParticle::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, Char_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);
563 Bool_t AliAODTrack::PropagateTo(Double_t xk, Double_t b) {
564 //----------------------------------------------------------------
565 // Propagate this track to the plane X=xk (cm) in the field "b" (kG)
566 // This is in local coordinates!!!
567 //----------------------------------------------------------------
570 Double_t localP[3] = {Px(), Py(), Pz()}; // set global (sic!) p
571 Global2LocalMomentum(localP, Charge(), alpha); // convert global to local momentum
573 AliAODVertex *origin = (AliAODVertex*)fProdVertex.GetObject();
574 Double_t localX[3] = {origin->GetX(), origin->GetY(), origin->GetZ()}; // set global (sic!) location of first track point
575 Global2LocalPosition(localX, alpha); // convert global to local position
577 Double_t &fX = localX[0];
580 if (TMath::Abs(dx)<=kAlmost0) return kTRUE;
582 Double_t crv=localP[0]*b*kB2C;
583 if (TMath::Abs(b) < kAlmost0Field) crv=0.;
585 Double_t f1=localP[1], f2=f1 + crv*dx;
586 if (TMath::Abs(f1) >= kAlmost1) return kFALSE;
587 if (TMath::Abs(f2) >= kAlmost1) return kFALSE;
589 Double_t &fP0=localX[1], &fP1=localX[2], &fP2=localP[0], &fP3=localP[1], &fP4=localP[2];
590 /* covariance matrix to be fixed!
593 &fC10=fC[1], &fC11=fC[2],
594 &fC20=fC[3], &fC21=fC[4], &fC22=fC[5],
595 &fC30=fC[6], &fC31=fC[7], &fC32=fC[8], &fC33=fC[9],
596 &fC40=fC[10], &fC41=fC[11], &fC42=fC[12], &fC43=fC[13], &fC44=fC[14];
598 Double_t r1=TMath::Sqrt(1.- f1*f1), r2=TMath::Sqrt(1.- f2*f2);
601 fP0 += dx*(f1+f2)/(r1+r2);
602 fP1 += dx*(r2 + f2*(f1+f2)/(r1+r2))*fP3;
607 //Double_t f02= dx/(r1*r1*r1);
609 Double_t f04=0.5*dx*dx/(r1*r1*r1); f04*=cc;
610 //Double_t f12= dx*fP3*f1/(r1*r1*r1);
611 Double_t f14=0.5*dx*dx*fP3*f1/(r1*r1*r1); f14*=cc;
612 //Double_t f13= dx/r1;
613 Double_t f24= dx; f24*=cc;
615 /* covariance matrix to be fixed!
617 Double_t b00=f02*fC20 + f04*fC40, b01=f12*fC20 + f14*fC40 + f13*fC30;
618 Double_t b02=f24*fC40;
619 Double_t b10=f02*fC21 + f04*fC41, b11=f12*fC21 + f14*fC41 + f13*fC31;
620 Double_t b12=f24*fC41;
621 Double_t b20=f02*fC22 + f04*fC42, b21=f12*fC22 + f14*fC42 + f13*fC32;
622 Double_t b22=f24*fC42;
623 Double_t b40=f02*fC42 + f04*fC44, b41=f12*fC42 + f14*fC44 + f13*fC43;
624 Double_t b42=f24*fC44;
625 Double_t b30=f02*fC32 + f04*fC43, b31=f12*fC32 + f14*fC43 + f13*fC33;
626 Double_t b32=f24*fC43;
629 Double_t a00=f02*b20+f04*b40,a01=f02*b21+f04*b41,a02=f02*b22+f04*b42;
630 Double_t a11=f12*b21+f14*b41+f13*b31,a12=f12*b22+f14*b42+f13*b32;
631 Double_t a22=f24*b42;
633 //F*C*Ft = C + (b + bt + a)
634 fC00 += b00 + b00 + a00;
635 fC10 += b10 + b01 + a01;
636 fC20 += b20 + b02 + a02;
639 fC11 += b11 + b11 + a11;
640 fC21 += b21 + b12 + a12;
643 fC22 += b22 + b22 + a22;
648 Local2GlobalMomentum(localP, alpha); // convert local to global momentum