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),
40 // default constructor
43 SetPosition((Float_t*)NULL);
44 SetPID((Float_t*)NULL);
47 //______________________________________________________________________________
48 AliAODTrack::AliAODTrack(Int_t id,
54 Double_t covMatrix[21],
58 AliAODVertex *prodVertex,
60 Bool_t usedForPrimVtxFit,
67 fProdVertex(prodVertex),
69 fITSMuonClusterMap(itsClusMap),
76 SetPosition(x, isDCA);
77 SetUsedForVtxFit(usedForVtxFit);
78 SetUsedForPrimVtxFit(usedForPrimVtxFit);
79 if(covMatrix) SetCovMatrix(covMatrix);
84 //______________________________________________________________________________
85 AliAODTrack::AliAODTrack(Int_t id,
91 Float_t covMatrix[21],
95 AliAODVertex *prodVertex,
97 Bool_t usedForPrimVtxFit,
104 fProdVertex(prodVertex),
106 fITSMuonClusterMap(itsClusMap),
108 fChi2MatchTrigger(0.)
113 SetPosition(x, isDCA);
114 SetUsedForVtxFit(usedForVtxFit);
115 SetUsedForPrimVtxFit(usedForPrimVtxFit);
116 if(covMatrix) SetCovMatrix(covMatrix);
120 //______________________________________________________________________________
121 AliAODTrack::~AliAODTrack()
128 //______________________________________________________________________________
129 AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
130 AliVirtualParticle(trk),
131 fChi2perNDF(trk.fChi2perNDF),
135 fProdVertex(trk.fProdVertex),
136 fCharge(trk.fCharge),
137 fITSMuonClusterMap(trk.fITSMuonClusterMap),
139 fChi2MatchTrigger(0.)
144 trk.GetPosition(fPosition);
145 SetUsedForVtxFit(trk.GetUsedForVtxFit());
146 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
147 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
152 //______________________________________________________________________________
153 AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
155 // Assignment operator
158 AliVirtualParticle::operator=(trk);
161 trk.GetPosition(fPosition);
164 fChi2perNDF = trk.fChi2perNDF;
170 if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
171 else fCovMatrix=NULL;
172 fProdVertex = trk.fProdVertex;
174 fCharge = trk.fCharge;
175 fITSMuonClusterMap = trk.fITSMuonClusterMap;
176 SetUsedForVtxFit(trk.GetUsedForVtxFit());
177 SetUsedForPrimVtxFit(trk.GetUsedForPrimVtxFit());
184 //______________________________________________________________________________
185 Double_t AliAODTrack::M(AODTrkPID_t pid) const
188 // In the case of elementary particles the hard coded mass values were taken
189 // from the PDG. In all cases the errors on the values do not affect
240 //______________________________________________________________________________
241 Double_t AliAODTrack::E(AODTrkPID_t pid) const
243 // Returns the energy of the particle of a given pid.
245 if (pid != kUnknown) { // particle was identified
247 return TMath::Sqrt(P()*P() + m*m);
248 } else { // pid unknown
253 //______________________________________________________________________________
254 Double_t AliAODTrack::Y(AODTrkPID_t pid) const
256 // Returns the energy of the particle of a given pid.
258 if (pid != kUnknown) { // particle was identified
261 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
262 return 0.5*TMath::Log((e+pz)/(e-pz));
263 } else { // energy not known or equal to pz
266 } else { // pid unknown
271 //______________________________________________________________________________
272 Double_t AliAODTrack::Y(Double_t m) const
274 // Returns the energy of the particle of a given mass.
276 if (m >= 0.) { // mass makes sense
279 if (e>=0 && e!=pz) { // energy was positive (e.g. not -999.) and not equal to pz
280 return 0.5*TMath::Log((e+pz)/(e-pz));
281 } else { // energy not known or equal to pz
284 } else { // pid unknown
289 //______________________________________________________________________________
290 AliAODTrack::AODTrkPID_t AliAODTrack::GetMostProbablePID() const
292 // Returns the most probable PID array element.
296 AODTrkPID_t loc = kUnknown;
298 Bool_t allTheSame = kTRUE;
300 for (Int_t iPID = 0; iPID < nPID; iPID++) {
301 if (fPID[iPID] >= max) {
302 if (fPID[iPID] > max) {
305 loc = (AODTrkPID_t)iPID;
312 return allTheSame ? kUnknown : loc;
318 //______________________________________________________________________________
319 void AliAODTrack::ConvertAliPIDtoAODPID()
321 // Converts AliPID array.
322 // The numbering scheme is the same for electrons, muons, pions, kaons, and protons.
323 // Everything else has to be set to zero.
325 fPID[kDeuteron] = 0.;
335 //______________________________________________________________________________
336 template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian)
342 Double_t pt2 = p[0]*p[0] + p[1]*p[1];
343 Double_t P = TMath::Sqrt(pt2 + p[2]*p[2]);
345 fMomentum[0] = TMath::Sqrt(pt2); // pt
346 fMomentum[1] = (pt2 != 0.) ? TMath::ATan2(p[1], p[0]) : -999; // phi
347 fMomentum[2] = (P != 0.) ? TMath::ACos(p[2]/P) : -999.; // theta
349 fMomentum[0] = p[0]; // pt
350 fMomentum[1] = p[1]; // phi
351 fMomentum[2] = p[2]; // theta
354 fMomentum[0] = -999.;
355 fMomentum[1] = -999.;
356 fMomentum[2] = -999.;
360 //______________________________________________________________________________
361 template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca)
374 // don't know any better yet
375 fPosition[0] = -999.;
376 fPosition[1] = -999.;
377 fPosition[2] = -999.;
382 fPosition[0] = -999.;
383 fPosition[1] = -999.;
384 fPosition[2] = -999.;
388 //______________________________________________________________________________
389 void AliAODTrack::SetDCA(Double_t d, Double_t z)
398 //______________________________________________________________________________
399 void AliAODTrack::Print(Option_t* /* option */) const
401 // prints information about AliAODTrack
403 printf("Object name: %s Track type: %s\n", GetName(), GetTitle());
404 printf(" px = %f\n", Px());
405 printf(" py = %f\n", Py());
406 printf(" pz = %f\n", Pz());
407 printf(" pt = %f\n", Pt());
408 printf(" 1/pt = %f\n", OneOverPt());
409 printf(" theta = %f\n", Theta());
410 printf(" phi = %f\n", Phi());
411 printf(" chi2/NDF = %f\n", Chi2perNDF());
412 printf(" charge = %d\n", Charge());
413 printf(" PID object: %p\n", PID());
416 void AliAODTrack::SetMatchTrigger(Int_t MatchTrigger){
417 switch(MatchTrigger){
418 case 0: // 0 track does not match trigger
419 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
421 case 1: // 1 track match but does not pass pt cut
422 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x40000000;
424 case 2: // 2 track match Low pt cut
425 fITSMuonClusterMap=(fITSMuonClusterMap&0x3fffffff)|0x80000000;
427 case 3: // 3 track match High pt cut
428 fITSMuonClusterMap=fITSMuonClusterMap|0xc0000000;
431 fITSMuonClusterMap=fITSMuonClusterMap&0x3fffffff;
432 printf("AliAODTrack::SetMatchTrigger unknown case for MatchTrigger: %d\n",MatchTrigger);
436 void AliAODTrack::SetHitsPatternInTrigCh(UShort_t hitsPatternInTrigCh){
437 fITSMuonClusterMap=(fITSMuonClusterMap&0xffff00ff)|(hitsPatternInTrigCh<<8);
440 Int_t AliAODTrack::HitsMT(Int_t istation, Int_t iplane, Char_t *cathode){
442 if(cathode[0]=='x'||cathode[0]=='X'){
445 return (fITSMuonClusterMap&0x8000)?1:0;
447 return (fITSMuonClusterMap&0x4000)?1:0;
450 }else if(istation==2){
452 return (fITSMuonClusterMap&0x2000)?1:0;
454 return (fITSMuonClusterMap&0x1000)?1:0;
460 }else if(cathode[0]=='y'||cathode[0]=='Y'){
463 return (fITSMuonClusterMap&0x0800)?1:0;
465 return (fITSMuonClusterMap&0x0400)?1:0;
468 }else if(istation==2){
470 return (fITSMuonClusterMap&0x0200)?1:0;
472 return (fITSMuonClusterMap&0x0100)?1:0;
484 return (HitsMT(1,1,"X")||HitsMT(1,1,"Y"))?1:0;
486 return (HitsMT(1,2,"X")||HitsMT(1,2,"Y"))?1:0;
489 }else if(istation==2){
491 return (HitsMT(2,1,"X")||HitsMT(2,1,"Y"))?1:0;
493 return (HitsMT(2,2,"X")||HitsMT(2,2,"Y"))?1:0;
502 Int_t AliAODTrack::HitsMuonChamber(Int_t MuonChamber){
513 printf("Unknown MUON chamber: %d\n",MuonChamber);