Added ESD reader for HLT tracks.
[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>
20#include <AliJetEventParticles.h>
21#include "AliJetParticlesReaderHLT.h"
22
23ClassImp(AliJetParticlesReaderHLT)
24
25AliJetParticlesReaderHLT::AliJetParticlesReaderHLT(Bool_t bMapper, const Char_t* esdfilename) :
26 AliJetParticlesReaderESD(esdfilename),
27 fTrackerType(bMapper)
28{
29 //constructor
30}
31
32/********************************************************************/
33
34AliJetParticlesReaderHLT::AliJetParticlesReaderHLT(
35 Bool_t bMapper,
36 TObjArray* dirs,
37 const Char_t* esdfilename) :
38 AliJetParticlesReaderESD(dirs,esdfilename),
39 fTrackerType(bMapper)
40{
41 //constructor
42}
43
44/********************************************************************/
45
46AliJetParticlesReaderHLT::~AliJetParticlesReaderHLT()
47{
48 //desctructor
49}
50
51Int_t AliJetParticlesReaderHLT::ReadESD(AliESD* esd)
52{
53 //Reads one ESD
54
55 if (esd == 0)
56 {
57 Error("ReadESD","ESD is NULL");
58 return kFALSE;
59 }
60
61 Info("ReadESD","Reading Event %d",fCurrentEvent);
62 if((!fOwner) || (fEventParticles==0))
63 fEventParticles = new AliJetEventParticles();
64
65 Double_t vertexpos[3];//vertex position
66 const AliESDVertex* kvertex = esd->GetVertex();
67 if (kvertex == 0)
68 {
69 Info("ReadESD","ESD returned NULL pointer to vertex - assuming (0.0,0.0,0.0)");
70 vertexpos[0] = 0.0;
71 vertexpos[1] = 0.0;
72 vertexpos[2] = 0.0;
73 }
74 else
75 {
76 kvertex->GetXYZ(vertexpos);
77 }
78
79 fEventParticles->SetVertex(vertexpos[0],vertexpos[1],vertexpos[2]);
80
81 if(fTrackerType){
82 const Int_t kntr =esd->GetNumberOfHLTHoughTracks();
83 Info("ReadESD","Found %d conformal tracks.",kntr);
84 for (Int_t i = 0;i<kntr; i++) {
85 const AliESDHLTtrack *kesdtrack=esd->GetHLTConfMapTrack(i);
86
87 if (kesdtrack == 0)
88 {
89 Error("ReadESD","Can not get track %d", i);
90 continue;
91 }
92
93 //const Float_t kpid=kesdtrack->GetPID();
94 //const Int_t knhits=kesdtrack->GetNHits();
95 const Float_t kpx=kesdtrack->GetPx();
96 const Float_t kpy=kesdtrack->GetPy();
97 const Float_t kpz=kesdtrack->GetPz();
98 const Float_t kpt=kesdtrack->GetPt();
99 const Float_t kp=TMath::Sqrt(kpz*kpz+kpt*kpt);
100 const Float_t keta=0.5*TMath::Log((kp+kpz+1e-30)/(kp-kpz+1e-30));
101 const Float_t kphi=TMath::Pi()+TMath::ATan2(-kpy,-kpx);
102
103 if(IsAcceptedParticle(kpt,kphi,keta))
104 fEventParticles->AddParticle(kpx,kpy,kpz,kp,i,kesdtrack->GetMCid(),kpt,kphi,keta);
105
106 } //loop over conf tracks
107 } else {
108 const Int_t kntr=esd->GetNumberOfHLTHoughTracks();
109 Info("ReadESD","Found %d hough tracks.",kntr);
110
111 for (Int_t i = 0;i<kntr; i++) {
112 const AliESDHLTtrack *kesdtrack=esd->GetHLTHoughTrack(i);
113
114 if (kesdtrack == 0)
115 {
116 Error("ReadESD","Can not get track %d", i);
117 continue;
118 }
119
120 //const Float_t kweight=kesdtrack->GetWeight();
121 const Float_t kpx=kesdtrack->GetPx();
122 const Float_t kpy=kesdtrack->GetPy();
123 const Float_t kpz=kesdtrack->GetPz();
124
125 const Float_t kpt=kesdtrack->GetPt();
126 const Float_t kp=TMath::Sqrt(kpz*kpz+kpt*kpt);
127 const Float_t keta=0.5*TMath::Log((kp+kpz+1e-30)/(kp-kpz+1e-30));
128 const Float_t kphi=TMath::Pi()+TMath::ATan2(-kpy,-kpx);
129
130 if(IsAcceptedParticle(kpt,kphi,keta))
131 fEventParticles->AddParticle(kpx,kpy,kpz,kp,i,kesdtrack->GetMCid(),kpt,kphi,keta);
132 } //loop over hough tracks
133 }
134 return kTRUE;
135}