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 base class
20 // Author: Markus Oldenburg, CERN
21 //-------------------------------------------------------------------------
23 #include "AliAODTrack.h"
25 //#include <TPDGCode.h>
26 //#include <TDatabasePDG.h>
30 //______________________________________________________________________________
31 AliAODTrack::AliAODTrack() :
34 fChi2MatchTrigger(0.),
36 fITSMuonClusterMap(0),
44 // default constructor
47 SetPosition((Float_t*)NULL);
48 SetPID((Float_t*)NULL);
51 //______________________________________________________________________________
52 AliAODTrack::AliAODTrack(Short_t id,
58 Double_t covMatrix[21],
62 AliAODVertex *prodVertex,
64 Bool_t usedForPrimVtxFit,
69 fChi2MatchTrigger(0.),
71 fITSMuonClusterMap(itsClusMap),
72 fFilterMap(selectInfo),
77 fProdVertex(prodVertex)
82 SetPosition(x, isDCA);
83 SetUsedForVtxFit(usedForVtxFit);
84 SetUsedForPrimVtxFit(usedForPrimVtxFit);
85 if(covMatrix) SetCovMatrix(covMatrix);
90 //______________________________________________________________________________
91 AliAODTrack::AliAODTrack(Short_t id,
97 Float_t covMatrix[21],
101 AliAODVertex *prodVertex,
102 Bool_t usedForVtxFit,
103 Bool_t usedForPrimVtxFit,
108 fChi2MatchTrigger(0.),
110 fITSMuonClusterMap(itsClusMap),
111 fFilterMap(selectInfo),
116 fProdVertex(prodVertex)
121 SetPosition(x, isDCA);
122 SetUsedForVtxFit(usedForVtxFit);
123 SetUsedForPrimVtxFit(usedForPrimVtxFit);
124 if(covMatrix) SetCovMatrix(covMatrix);
128 //______________________________________________________________________________
129 AliAODTrack::~AliAODTrack()
136 //______________________________________________________________________________
137 AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
139 fChi2perNDF(trk.fChi2perNDF),
140 fChi2MatchTrigger(trk.fChi2MatchTrigger),
142 fITSMuonClusterMap(trk.fITSMuonClusterMap),
143 fFilterMap(trk.fFilterMap),
145 fCharge(trk.fCharge),
148 fProdVertex(trk.fProdVertex)
153 trk.GetPosition(fPosition);
154 SetUsedForVtxFit(trk.GetUsedForVtxFit());
155 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
156 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
161 //______________________________________________________________________________
162 AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
164 // Assignment operator
167 AliVParticle::operator=(trk);
170 trk.GetPosition(fPosition);
173 fChi2perNDF = trk.fChi2perNDF;
174 fChi2MatchTrigger = trk.fChi2MatchTrigger;
179 fITSMuonClusterMap = trk.fITSMuonClusterMap;
180 fFilterMap = trk.fFilterMap;
182 fCharge = trk.fCharge;
186 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
187 else fCovMatrix=NULL;
188 fProdVertex = trk.fProdVertex;
190 SetUsedForVtxFit(trk.GetUsedForVtxFit());
191 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
197 //______________________________________________________________________________
198 Double_t AliAODTrack::M(AODTrkPID_t pid) const
201 // Masses for nuclei don't exist in the PDG tables, therefore they were put by hand.
206 return 0.000510999; //TDatabasePDG::Instance()->GetParticle(11/*::kElectron*/)->Mass();
210 return 0.1056584; //TDatabasePDG::Instance()->GetParticle(13/*::kMuonMinus*/)->Mass();
214 return 0.13957; //TDatabasePDG::Instance()->GetParticle(211/*::kPiPlus*/)->Mass();
218 return 0.4937; //TDatabasePDG::Instance()->GetParticle(321/*::kKPlus*/)->Mass();
222 return 0.9382720; //TDatabasePDG::Instance()->GetParticle(2212/*::kProton*/)->Mass();
226 return 1.8756; //TDatabasePDG::Instance()->GetParticle(1000010020)->Mass();
230 return 2.8089; //TDatabasePDG::Instance()->GetParticle(1000010030)->Mass();
234 return 2.8084; //TDatabasePDG::Instance()->GetParticle(1000020030)->Mass();
238 return 3.7274; //TDatabasePDG::Instance()->GetParticle(1000020040)->Mass();
250 //______________________________________________________________________________
251 Double_t AliAODTrack::E(AODTrkPID_t pid) const
253 // Returns the energy of the particle of a given pid.
255 if (pid != kUnknown) { // particle was identified
257 return TMath::Sqrt(P()*P() + m*m);
258 } else { // pid unknown
263 //______________________________________________________________________________
264 Double_t AliAODTrack::Y(AODTrkPID_t pid) const
266 // Returns the rapidity of a particle of a given pid.
268 if (pid != kUnknown) { // particle was identified
271 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
272 return 0.5*TMath::Log((e+pz)/(e-pz));
273 } else { // energy not known or equal to pz
276 } else { // pid unknown
281 //______________________________________________________________________________
282 Double_t AliAODTrack::Y(Double_t m) const
284 // Returns the rapidity of a particle of a given mass.
286 if (m >= 0.) { // mass makes sense
289 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
290 return 0.5*TMath::Log((e+pz)/(e-pz));
291 } else { // energy not known or equal to pz
294 } else { // pid unknown
299 //______________________________________________________________________________
300 AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
302 // Returns the most probable PID array element.
306 AODTrkPID_t loc = kUnknown;
308 Bool_t allTheSame = kTRUE;
310 for (Int_t iPID = 0; iPID < nPID; iPID++) {
311 if (fPID[iPID] >= max) {
312 if (fPID[iPID] > max) {
315 loc = (AODTrkPID_t)iPID;
322 return allTheSame ? kUnknown : loc;
328 //______________________________________________________________________________
329 void AliAODTrack::ConvertAliPIDtoAODPID()
331 // Converts AliPID array.
332 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
333 // Everything else has to be set to zero.
335 fPID[kDeuteron] = 0.;
345 //______________________________________________________________________________
346 template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
352 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
353 Double_t P = TMath::Sqrt(pt2 + p[2]*p[2]);
355 fMomentum[0] = TMath::Sqrt(pt2); // pt
356 fMomentum[1] = (pt2 != 0.) ? TMath::Pi()+TMath::ATan2(-p[1], -p[0]) : -999; // phi
357 fMomentum[2] = (P != 0.) ? TMath::ACos(p[2]/P) : -999.; // theta
359 fMomentum[0] = p[0]; // pt
360 fMomentum[1] = p[1]; // phi
361 fMomentum[2] = p[2]; // theta
364 fMomentum[0] = -999.;
365 fMomentum[1] = -999.;
366 fMomentum[2] = -999.;
370 //______________________________________________________________________________
371 template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
384 // don't know any better yet
385 fPosition[0] = -999.;
386 fPosition[1] = -999.;
387 fPosition[2] = -999.;
392 fPosition[0] = -999.;
393 fPosition[1] = -999.;
394 fPosition[2] = -999.;
398 //______________________________________________________________________________
399 void AliAODTrack::SetDCA(Double_t d, Double_t z)
408 //______________________________________________________________________________
409 void AliAODTrack::Print(Option_t* /* option */) const
411 // prints information about AliAODTrack
413 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
414 printf(" px = %f\n", Px());
415 printf(" py = %f\n", Py());
416 printf(" pz = %f\n", Pz());
417 printf(" pt = %f\n", Pt());
418 printf(" 1/pt = %f\n", OneOverPt());
419 printf(" theta = %f\n", Theta());
420 printf(" phi = %f\n", Phi());
421 printf(" chi2/NDF = %f\n", Chi2perNDF());
422 printf(" charge = %d\n", Charge());
423 printf(" PID object: %p\n", PID());
426 void AliAODTrack::SetMatchTrigger(Int_t MatchTrigger){
428 // Set the MUON trigger information
429 switch(MatchTrigger){
430 case 0: // 0 track does not match trigger
431 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
433 case 1: // 1 track match but does not pass pt cut
434 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x40000000;
436 case 2: // 2 track match Low pt cut
437 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x80000000;
439 case 3: // 3 track match High pt cut
440 fITSMuonClusterMap=fITSMuonClusterMap|0xc0000000;
443 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
444 printf("AliAODTrack::SetMatchTrigger unknown case for MatchTrigger: %d\n",MatchTrigger);
448 void AliAODTrack::SetHitsPatternInTrigCh(UShort_t hitsPatternInTrigCh){
450 // Set the MUON hit pattern (1 bit per chamber)
451 fITSMuonClusterMap=(fITSMuonClusterMap&0xffff00ff)|(hitsPatternInTrigCh<<8);
454 Int_t AliAODTrack::HitsMT(Int_t istation, Int_t iplane, Char_t *cathode){
456 // Retrieve hit information for MUON identified by (station, plane, cathode)
458 if(cathode[0]=='x'||cathode[0]=='X'){
461 return (fITSMuonClusterMap&0x8000)?1:0;
463 return (fITSMuonClusterMap&0x4000)?1:0;
466 }else if(istation==2){
468 return (fITSMuonClusterMap&0x2000)?1:0;
470 return (fITSMuonClusterMap&0x1000)?1:0;
476 }else if(cathode[0]=='y'||cathode[0]=='Y'){
479 return (fITSMuonClusterMap&0x0800)?1:0;
481 return (fITSMuonClusterMap&0x0400)?1:0;
484 }else if(istation==2){
486 return (fITSMuonClusterMap&0x0200)?1:0;
488 return (fITSMuonClusterMap&0x0100)?1:0;
500 return (HitsMT(1,1,"X")||HitsMT(1,1,"Y"))?1:0;
502 return (HitsMT(1,2,"X")||HitsMT(1,2,"Y"))?1:0;
505 }else if(istation==2){
507 return (HitsMT(2,1,"X")||HitsMT(2,1,"Y"))?1:0;
509 return (HitsMT(2,2,"X")||HitsMT(2,2,"Y"))?1:0;
518 Int_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber){
519 // Retrieve hit information for MUON Chamber
530 printf("Unknown MUON chamber: %d\n",MuonChamber);
537 Bool_t AliAODTrack::PropagateTo(Double_t xk, Double_t b) {
538 //----------------------------------------------------------------
539 // Propagate this track to the plane X=xk (cm) in the field "b" (kG)
540 // This is in local coordinates!!!
541 //----------------------------------------------------------------
544 Double_t localP[3] = {Px(), Py(), Pz()}; // set global (sic!) p
545 Global2LocalMomentum(localP, Charge(), alpha); // convert global to local momentum
547 AliAODVertex *origin = (AliAODVertex*)fProdVertex.GetObject();
548 Double_t localX[3] = {origin->GetX(), origin->GetY(), origin->GetZ()}; // set global (sic!) location of first track point
549 Global2LocalPosition(localX, alpha); // convert global to local position
551 Double_t &fX = localX[0];
554 if (TMath::Abs(dx)<=kAlmost0) return kTRUE;
556 Double_t crv=localP[0]*b*kB2C;
557 if (TMath::Abs(b) < kAlmost0Field) crv=0.;
559 Double_t f1=localP[1], f2=f1 + crv*dx;
560 if (TMath::Abs(f1) >= kAlmost1) return kFALSE;
561 if (TMath::Abs(f2) >= kAlmost1) return kFALSE;
563 Double_t &fP0=localX[1], &fP1=localX[2], &fP2=localP[0], &fP3=localP[1], &fP4=localP[2];
564 /* covariance matrix to be fixed!
567 &fC10=fC[1], &fC11=fC[2],
568 &fC20=fC[3], &fC21=fC[4], &fC22=fC[5],
569 &fC30=fC[6], &fC31=fC[7], &fC32=fC[8], &fC33=fC[9],
570 &fC40=fC[10], &fC41=fC[11], &fC42=fC[12], &fC43=fC[13], &fC44=fC[14];
572 Double_t r1=TMath::Sqrt(1.- f1*f1), r2=TMath::Sqrt(1.- f2*f2);
575 fP0 += dx*(f1+f2)/(r1+r2);
576 fP1 += dx*(r2 + f2*(f1+f2)/(r1+r2))*fP3;
581 Double_t f02= dx/(r1*r1*r1); Double_t cc=crv/fP4;
582 Double_t f04=0.5*dx*dx/(r1*r1*r1); f04*=cc;
583 Double_t f12= dx*fP3*f1/(r1*r1*r1);
584 Double_t f14=0.5*dx*dx*fP3*f1/(r1*r1*r1); f14*=cc;
586 Double_t f24= dx; f24*=cc;
588 /* covariance matrix to be fixed!
590 Double_t b00=f02*fC20 + f04*fC40, b01=f12*fC20 + f14*fC40 + f13*fC30;
591 Double_t b02=f24*fC40;
592 Double_t b10=f02*fC21 + f04*fC41, b11=f12*fC21 + f14*fC41 + f13*fC31;
593 Double_t b12=f24*fC41;
594 Double_t b20=f02*fC22 + f04*fC42, b21=f12*fC22 + f14*fC42 + f13*fC32;
595 Double_t b22=f24*fC42;
596 Double_t b40=f02*fC42 + f04*fC44, b41=f12*fC42 + f14*fC44 + f13*fC43;
597 Double_t b42=f24*fC44;
598 Double_t b30=f02*fC32 + f04*fC43, b31=f12*fC32 + f14*fC43 + f13*fC33;
599 Double_t b32=f24*fC43;
602 Double_t a00=f02*b20+f04*b40,a01=f02*b21+f04*b41,a02=f02*b22+f04*b42;
603 Double_t a11=f12*b21+f14*b41+f13*b31,a12=f12*b22+f14*b42+f13*b32;
604 Double_t a22=f24*b42;
606 //F*C*Ft = C + (b + bt + a)
607 fC00 += b00 + b00 + a00;
608 fC10 += b10 + b01 + a01;
609 fC20 += b20 + b02 + a02;
612 fC11 += b11 + b11 + a11;
613 fC21 += b21 + b12 + a12;
616 fC22 += b22 + b22 + a22;
621 Local2GlobalMomentum(localP, alpha); // convert local to global momentum