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> |
75a0c43e |
20 | #include <AliL3Track.h> |
04a02430 |
21 | #include <AliKalmanTrack.h> |
5d60c8f9 |
22 | #include <AliJetEventParticles.h> |
23 | #include "AliJetParticlesReaderHLT.h" |
24 | |
25 | ClassImp(AliJetParticlesReaderHLT) |
26 | |
27 | AliJetParticlesReaderHLT::AliJetParticlesReaderHLT(Bool_t bMapper, const Char_t* esdfilename) : |
d9a296b1 |
28 | AliJetParticlesReaderESD(0,esdfilename), |
04a02430 |
29 | fTrackerType(bMapper), |
30 | fMinHits(0), |
31 | fMinWeight(0) |
5d60c8f9 |
32 | { |
33 | //constructor |
34 | } |
35 | |
36 | /********************************************************************/ |
37 | |
38 | AliJetParticlesReaderHLT::AliJetParticlesReaderHLT( |
39 | Bool_t bMapper, |
40 | TObjArray* dirs, |
41 | const Char_t* esdfilename) : |
d9a296b1 |
42 | AliJetParticlesReaderESD(0,dirs,esdfilename), |
04a02430 |
43 | fTrackerType(bMapper), |
44 | fMinHits(0), |
45 | fMinWeight(0) |
46 | |
5d60c8f9 |
47 | { |
48 | //constructor |
49 | } |
50 | |
51 | /********************************************************************/ |
52 | |
53 | AliJetParticlesReaderHLT::~AliJetParticlesReaderHLT() |
54 | { |
55 | //desctructor |
56 | } |
57 | |
58 | Int_t AliJetParticlesReaderHLT::ReadESD(AliESD* esd) |
59 | { |
60 | //Reads one ESD |
61 | |
62 | if (esd == 0) |
63 | { |
64 | Error("ReadESD","ESD is NULL"); |
65 | return kFALSE; |
66 | } |
67 | |
04a02430 |
68 | Float_t mf = esd->GetMagneticField(); |
69 | if (mf <= 0.0) |
70 | { |
71 | Error("ReadESD","Magnetic Field is 0. Skipping to next event."); |
72 | return kFALSE; |
73 | } |
74 | AliKalmanTrack::SetMagneticField(mf/10.); |
75 | |
a86edc4e |
76 | Info("ReadESD","Reading Event %d",fCurrentDir*1000+fCurrentEvent); |
5d60c8f9 |
77 | if((!fOwner) || (fEventParticles==0)) |
78 | fEventParticles = new AliJetEventParticles(); |
79 | |
04a02430 |
80 | Int_t ntr=0; |
81 | if(fTrackerType){ |
82 | ntr =esd->GetNumberOfHLTHoughTracks(); |
83 | Info("ReadESD","Found %d conformal tracks.",ntr); |
84 | } else { |
85 | ntr=esd->GetNumberOfHLTHoughTracks(); |
86 | Info("ReadESD","Found %d hough tracks.",ntr); |
87 | } |
88 | fEventParticles->Reset(ntr); |
89 | |
90 | TString headdesc=""; |
91 | headdesc+="Run "; |
92 | headdesc+=esd->GetRunNumber(); |
93 | headdesc+=": Ev "; |
94 | headdesc+=esd->GetEventNumber(); |
95 | fEventParticles->SetHeader(headdesc); |
96 | |
5d60c8f9 |
97 | Double_t vertexpos[3];//vertex position |
98 | const AliESDVertex* kvertex = esd->GetVertex(); |
99 | if (kvertex == 0) |
100 | { |
101 | Info("ReadESD","ESD returned NULL pointer to vertex - assuming (0.0,0.0,0.0)"); |
102 | vertexpos[0] = 0.0; |
103 | vertexpos[1] = 0.0; |
104 | vertexpos[2] = 0.0; |
105 | } |
106 | else |
107 | { |
108 | kvertex->GetXYZ(vertexpos); |
109 | } |
110 | |
111 | fEventParticles->SetVertex(vertexpos[0],vertexpos[1],vertexpos[2]); |
112 | |
75a0c43e |
113 | AliL3Track l3; |
04a02430 |
114 | for (Int_t i = 0;i<ntr; i++) { |
115 | AliESDHLTtrack *kesdtrack; |
116 | if(fTrackerType){ |
117 | kesdtrack=esd->GetHLTConfMapTrack(i); |
118 | } else { |
119 | kesdtrack=esd->GetHLTHoughTrack(i); |
120 | } |
5d60c8f9 |
121 | |
04a02430 |
122 | if (kesdtrack == 0) |
5d60c8f9 |
123 | { |
124 | Error("ReadESD","Can not get track %d", i); |
125 | continue; |
126 | } |
127 | |
75a0c43e |
128 | if(fTrackerType){ |
129 | //if(!kesdtrack->ComesFromMainVertex()) continue; |
130 | l3.SetFirstPoint(kesdtrack->GetFirstPointX(),kesdtrack->GetFirstPointY(),kesdtrack->GetFirstPointZ()); |
131 | l3.SetLastPoint(kesdtrack->GetLastPointX(),kesdtrack->GetLastPointY(),kesdtrack->GetLastPointZ()); |
132 | l3.SetCharge(kesdtrack->GetCharge()); |
133 | l3.SetPt(kesdtrack->GetPt()); |
134 | l3.SetTgl(kesdtrack->GetTgl()); |
135 | l3.SetPsi(kesdtrack->GetPsi()); |
136 | l3.CalculateHelix(); |
137 | l3.SetFirstPoint(0,0,0); |
138 | l3.UpdateToFirstPoint(); |
139 | } |
140 | |
04a02430 |
141 | //const Float_t kpid=kesdtrack->GetPID(); |
142 | const Int_t knhits=kesdtrack->GetNHits(); |
143 | const Int_t kweight=kesdtrack->GetWeight(); |
e43c01f2 |
144 | //cout << i << " " << kweight << " " << knhits << endl; |
145 | if((fMinHits>0) && (knhits<fMinHits)) continue; |
146 | if(kweight>1000) continue; //avoid ghosts |
04a02430 |
147 | if((fMinWeight>0) && (kweight<fMinWeight)) continue; |
5d60c8f9 |
148 | |
04a02430 |
149 | const Float_t kpx=kesdtrack->GetPx(); |
150 | const Float_t kpy=kesdtrack->GetPy(); |
151 | const Float_t kpz=kesdtrack->GetPz(); |
152 | const Float_t kpt=kesdtrack->GetPt(); |
153 | const Float_t kp=TMath::Sqrt(kpz*kpz+kpt*kpt); |
154 | const Float_t keta=0.5*TMath::Log((kp+kpz+1e-30)/(kp-kpz+1e-30)); |
155 | const Float_t kphi=TMath::Pi()+TMath::ATan2(-kpy,-kpx); |
5d60c8f9 |
156 | |
04a02430 |
157 | if(IsAcceptedParticle(kpt,kphi,keta)) |
301a24f1 |
158 | fEventParticles->AddParticle(kpx,kpy,kpz,kp,i,kesdtrack->GetMCid(),knhits,kpt,kphi,keta); |
04a02430 |
159 | } //loop over tracks |
5d60c8f9 |
160 | |
5d60c8f9 |
161 | return kTRUE; |
162 | } |