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"
27 //______________________________________________________________________________
28 AliAODTrack::AliAODTrack() :
36 fITSMuonClusterMap(0),
38 fChi2MatchTrigger(0.),
41 // default constructor
44 SetPosition((Float_t*)NULL);
45 SetPID((Float_t*)NULL);
48 //______________________________________________________________________________
49 AliAODTrack::AliAODTrack(Int_t id,
55 Double_t covMatrix[21],
59 AliAODVertex *prodVertex,
61 Bool_t usedForPrimVtxFit,
69 fProdVertex(prodVertex),
71 fITSMuonClusterMap(itsClusMap),
73 fChi2MatchTrigger(0.),
74 fFilterMap(selectInfo)
79 SetPosition(x, isDCA);
80 SetUsedForVtxFit(usedForVtxFit);
81 SetUsedForPrimVtxFit(usedForPrimVtxFit);
82 if(covMatrix) SetCovMatrix(covMatrix);
87 //______________________________________________________________________________
88 AliAODTrack::AliAODTrack(Int_t id,
94 Float_t covMatrix[21],
98 AliAODVertex *prodVertex,
100 Bool_t usedForPrimVtxFit,
103 AliVirtualParticle(),
108 fProdVertex(prodVertex),
110 fITSMuonClusterMap(itsClusMap),
112 fChi2MatchTrigger(0.),
113 fFilterMap(selectInfo)
118 SetPosition(x, isDCA);
119 SetUsedForVtxFit(usedForVtxFit);
120 SetUsedForPrimVtxFit(usedForPrimVtxFit);
121 if(covMatrix) SetCovMatrix(covMatrix);
125 //______________________________________________________________________________
126 AliAODTrack::~AliAODTrack()
133 //______________________________________________________________________________
134 AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
135 AliVirtualParticle(trk),
136 fChi2perNDF(trk.fChi2perNDF),
140 fProdVertex(trk.fProdVertex),
141 fCharge(trk.fCharge),
142 fITSMuonClusterMap(trk.fITSMuonClusterMap),
144 fChi2MatchTrigger(0.),
145 fFilterMap(trk.fFilterMap)
150 trk.GetPosition(fPosition);
151 SetUsedForVtxFit(trk.GetUsedForVtxFit());
152 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
153 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
158 //______________________________________________________________________________
159 AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
161 // Assignment operator
164 AliVirtualParticle::operator=(trk);
167 trk.GetPosition(fPosition);
170 fChi2perNDF = trk.fChi2perNDF;
176 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
177 else fCovMatrix=NULL;
178 fProdVertex = trk.fProdVertex;
180 fCharge = trk.fCharge;
181 fITSMuonClusterMap = trk.fITSMuonClusterMap;
182 SetUsedForVtxFit(trk.GetUsedForVtxFit());
183 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
185 fFilterMap = trk.fFilterMap;
191 //______________________________________________________________________________
192 Double_t AliAODTrack::M(AODTrkPID_t pid) const
195 // In the case of elementary particles the hard coded mass values were taken
196 // from the PDG. In all cases the errors on the values do not affect
247 //______________________________________________________________________________
248 Double_t AliAODTrack::E(AODTrkPID_t pid) const
250 // Returns the energy of the particle of a given pid.
252 if (pid != kUnknown) { // particle was identified
254 return TMath::Sqrt(P()*P() + m*m);
255 } else { // pid unknown
260 //______________________________________________________________________________
261 Double_t AliAODTrack::Y(AODTrkPID_t pid) const
263 // Returns the energy of the particle of a given pid.
265 if (pid != kUnknown) { // particle was identified
268 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
269 return 0.5*TMath::Log((e+pz)/(e-pz));
270 } else { // energy not known or equal to pz
273 } else { // pid unknown
278 //______________________________________________________________________________
279 Double_t AliAODTrack::Y(Double_t m) const
281 // Returns the energy of the particle of a given mass.
283 if (m >= 0.) { // mass makes sense
286 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
287 return 0.5*TMath::Log((e+pz)/(e-pz));
288 } else { // energy not known or equal to pz
291 } else { // pid unknown
296 //______________________________________________________________________________
297 AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
299 // Returns the most probable PID array element.
303 AODTrkPID_t loc = kUnknown;
305 Bool_t allTheSame = kTRUE;
307 for (Int_t iPID = 0; iPID < nPID; iPID++) {
308 if (fPID[iPID] >= max) {
309 if (fPID[iPID] > max) {
312 loc = (AODTrkPID_t)iPID;
319 return allTheSame ? kUnknown : loc;
325 //______________________________________________________________________________
326 void AliAODTrack::ConvertAliPIDtoAODPID()
328 // Converts AliPID array.
329 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
330 // Everything else has to be set to zero.
332 fPID[kDeuteron] = 0.;
342 //______________________________________________________________________________
343 template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
349 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
350 Double_t P = TMath::Sqrt(pt2 + p[2]*p[2]);
352 fMomentum[0] = TMath::Sqrt(pt2); // pt
353 fMomentum[1] = (pt2 != 0.) ? TMath::ATan2(p[1], p[0]) : -999; // phi
354 fMomentum[2] = (P != 0.) ? TMath::ACos(p[2]/P) : -999.; // theta
356 fMomentum[0] = p[0]; // pt
357 fMomentum[1] = p[1]; // phi
358 fMomentum[2] = p[2]; // theta
361 fMomentum[0] = -999.;
362 fMomentum[1] = -999.;
363 fMomentum[2] = -999.;
367 //______________________________________________________________________________
368 template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
381 // don't know any better yet
382 fPosition[0] = -999.;
383 fPosition[1] = -999.;
384 fPosition[2] = -999.;
389 fPosition[0] = -999.;
390 fPosition[1] = -999.;
391 fPosition[2] = -999.;
395 //______________________________________________________________________________
396 void AliAODTrack::SetDCA(Double_t d, Double_t z)
405 //______________________________________________________________________________
406 void AliAODTrack::Print(Option_t* /* option */) const
408 // prints information about AliAODTrack
410 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
411 printf(" px = %f\n", Px());
412 printf(" py = %f\n", Py());
413 printf(" pz = %f\n", Pz());
414 printf(" pt = %f\n", Pt());
415 printf(" 1/pt = %f\n", OneOverPt());
416 printf(" theta = %f\n", Theta());
417 printf(" phi = %f\n", Phi());
418 printf(" chi2/NDF = %f\n", Chi2perNDF());
419 printf(" charge = %d\n", Charge());
420 printf(" PID object: %p\n", PID());
423 void AliAODTrack::SetMatchTrigger(Int_t MatchTrigger){
425 // Set the MUON trigger information
426 switch(MatchTrigger){
427 case 0: // 0 track does not match trigger
428 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
430 case 1: // 1 track match but does not pass pt cut
431 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x40000000;
433 case 2: // 2 track match Low pt cut
434 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x80000000;
436 case 3: // 3 track match High pt cut
437 fITSMuonClusterMap=fITSMuonClusterMap|0xc0000000;
440 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
441 printf("AliAODTrack::SetMatchTrigger unknown case for MatchTrigger: %d\n",MatchTrigger);
445 void AliAODTrack::SetHitsPatternInTrigCh(UShort_t hitsPatternInTrigCh){
447 // Set the MUON hit pattern (1 bit per chamber)
448 fITSMuonClusterMap=(fITSMuonClusterMap&0xffff00ff)|(hitsPatternInTrigCh<<8);
451 Int_t AliAODTrack::HitsMT(Int_t istation, Int_t iplane, Char_t *cathode){
453 // Retrieve hit information for MUON identified by (station, plane, cathode)
455 if(cathode[0]=='x'||cathode[0]=='X'){
458 return (fITSMuonClusterMap&0x8000)?1:0;
460 return (fITSMuonClusterMap&0x4000)?1:0;
463 }else if(istation==2){
465 return (fITSMuonClusterMap&0x2000)?1:0;
467 return (fITSMuonClusterMap&0x1000)?1:0;
473 }else if(cathode[0]=='y'||cathode[0]=='Y'){
476 return (fITSMuonClusterMap&0x0800)?1:0;
478 return (fITSMuonClusterMap&0x0400)?1:0;
481 }else if(istation==2){
483 return (fITSMuonClusterMap&0x0200)?1:0;
485 return (fITSMuonClusterMap&0x0100)?1:0;
497 return (HitsMT(1,1,"X")||HitsMT(1,1,"Y"))?1:0;
499 return (HitsMT(1,2,"X")||HitsMT(1,2,"Y"))?1:0;
502 }else if(istation==2){
504 return (HitsMT(2,1,"X")||HitsMT(2,1,"Y"))?1:0;
506 return (HitsMT(2,2,"X")||HitsMT(2,2,"Y"))?1:0;
515 Int_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber){
516 // Retrieve hit information for MUON Chamber
527 printf("Unknown MUON chamber: %d\n",MuonChamber);