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