New class for PID constants and methods. Changes in all related code (T.Kuhr)
[u/mrichter/AliRoot.git] / JETAN / AliJetParticlesReaderHLT.cxx
CommitLineData
5d60c8f9 1// $Id$
2
3//___________________________________________________________________________
4/////////////////////////////////////////////////////////////////////////////
5// //
6// File reader for HLT tracks ESD //
7// //
8// loizides@ikf.uni-frankfurt.de //
9/////////////////////////////////////////////////////////////////////////////
10
11#include <Riostream.h>
12#include <TMath.h>
13#include <TString.h>
14#include <TObjString.h>
15#include <TTree.h>
16#include <TFile.h>
17#include <AliESD.h>
18#include <AliESDtrack.h>
19#include <AliESDHLTtrack.h>
04a02430 20#include <AliKalmanTrack.h>
5d60c8f9 21#include <AliJetEventParticles.h>
22#include "AliJetParticlesReaderHLT.h"
23
24ClassImp(AliJetParticlesReaderHLT)
25
26AliJetParticlesReaderHLT::AliJetParticlesReaderHLT(Bool_t bMapper, const Char_t* esdfilename) :
d9a296b1 27 AliJetParticlesReaderESD(0,esdfilename),
04a02430 28 fTrackerType(bMapper),
29 fMinHits(0),
30 fMinWeight(0)
5d60c8f9 31{
32 //constructor
33}
34
35/********************************************************************/
36
37AliJetParticlesReaderHLT::AliJetParticlesReaderHLT(
38 Bool_t bMapper,
39 TObjArray* dirs,
40 const Char_t* esdfilename) :
d9a296b1 41 AliJetParticlesReaderESD(0,dirs,esdfilename),
04a02430 42 fTrackerType(bMapper),
43 fMinHits(0),
44 fMinWeight(0)
45
5d60c8f9 46{
47 //constructor
48}
49
50/********************************************************************/
51
52AliJetParticlesReaderHLT::~AliJetParticlesReaderHLT()
53{
54 //desctructor
55}
56
57Int_t AliJetParticlesReaderHLT::ReadESD(AliESD* esd)
58{
59 //Reads one ESD
60
61 if (esd == 0)
62 {
63 Error("ReadESD","ESD is NULL");
64 return kFALSE;
65 }
66
04a02430 67 Float_t mf = esd->GetMagneticField();
68 if (mf <= 0.0)
69 {
70 Error("ReadESD","Magnetic Field is 0. Skipping to next event.");
71 return kFALSE;
72 }
73 AliKalmanTrack::SetMagneticField(mf/10.);
74
a86edc4e 75 Info("ReadESD","Reading Event %d",fCurrentDir*1000+fCurrentEvent);
5d60c8f9 76 if((!fOwner) || (fEventParticles==0))
77 fEventParticles = new AliJetEventParticles();
78
04a02430 79 Int_t ntr=0;
80 if(fTrackerType){
81 ntr =esd->GetNumberOfHLTHoughTracks();
82 Info("ReadESD","Found %d conformal tracks.",ntr);
83 } else {
84 ntr=esd->GetNumberOfHLTHoughTracks();
85 Info("ReadESD","Found %d hough tracks.",ntr);
86 }
87 fEventParticles->Reset(ntr);
88
89 TString headdesc="";
90 headdesc+="Run ";
91 headdesc+=esd->GetRunNumber();
92 headdesc+=": Ev ";
93 headdesc+=esd->GetEventNumber();
94 fEventParticles->SetHeader(headdesc);
95
5d60c8f9 96 Double_t vertexpos[3];//vertex position
97 const AliESDVertex* kvertex = esd->GetVertex();
98 if (kvertex == 0)
99 {
100 Info("ReadESD","ESD returned NULL pointer to vertex - assuming (0.0,0.0,0.0)");
101 vertexpos[0] = 0.0;
102 vertexpos[1] = 0.0;
103 vertexpos[2] = 0.0;
104 }
105 else
106 {
107 kvertex->GetXYZ(vertexpos);
108 }
109
110 fEventParticles->SetVertex(vertexpos[0],vertexpos[1],vertexpos[2]);
111
04a02430 112 for (Int_t i = 0;i<ntr; i++) {
113 AliESDHLTtrack *kesdtrack;
114 if(fTrackerType){
115 kesdtrack=esd->GetHLTConfMapTrack(i);
116 } else {
117 kesdtrack=esd->GetHLTHoughTrack(i);
118 }
5d60c8f9 119
04a02430 120 if (kesdtrack == 0)
5d60c8f9 121 {
122 Error("ReadESD","Can not get track %d", i);
123 continue;
124 }
125
04a02430 126 //const Float_t kpid=kesdtrack->GetPID();
127 const Int_t knhits=kesdtrack->GetNHits();
128 const Int_t kweight=kesdtrack->GetWeight();
e43c01f2 129 //cout << i << " " << kweight << " " << knhits << endl;
130 if((fMinHits>0) && (knhits<fMinHits)) continue;
131 if(kweight>1000) continue; //avoid ghosts
04a02430 132 if((fMinWeight>0) && (kweight<fMinWeight)) continue;
5d60c8f9 133
04a02430 134 const Float_t kpx=kesdtrack->GetPx();
135 const Float_t kpy=kesdtrack->GetPy();
136 const Float_t kpz=kesdtrack->GetPz();
137 const Float_t kpt=kesdtrack->GetPt();
138 const Float_t kp=TMath::Sqrt(kpz*kpz+kpt*kpt);
139 const Float_t keta=0.5*TMath::Log((kp+kpz+1e-30)/(kp-kpz+1e-30));
140 const Float_t kphi=TMath::Pi()+TMath::ATan2(-kpy,-kpx);
5d60c8f9 141
04a02430 142 if(IsAcceptedParticle(kpt,kphi,keta))
301a24f1 143 fEventParticles->AddParticle(kpx,kpy,kpz,kp,i,kesdtrack->GetMCid(),knhits,kpt,kphi,keta);
04a02430 144 } //loop over tracks
5d60c8f9 145
5d60c8f9 146 return kTRUE;
147}