o) splitted analysis and correction of dneta
[u/mrichter/AliRoot.git] / PWG0 / dNdEta / AlidNdEtaAnalysisESDSelector.cxx
CommitLineData
dc740de4 1/* $Id$ */
2
3#include "AlidNdEtaAnalysisESDSelector.h"
4
5#include <TStyle.h>
6#include <TSystem.h>
7#include <TCanvas.h>
8#include <TVector3.h>
7029240a 9#include <TChain.h>
dc740de4 10
11#include <AliLog.h>
fcf2fb36 12#include <AliESDVertex.h>
13#include <AliESD.h>
dc740de4 14
15#include "esdTrackCuts/AliESDtrackCuts.h"
dc740de4 16#include "dNdEtaAnalysis.h"
17
18ClassImp(AlidNdEtaAnalysisESDSelector)
19
20AlidNdEtaAnalysisESDSelector::AlidNdEtaAnalysisESDSelector() :
21 AlidNdEtaAnalysisSelector(),
fcf2fb36 22 fEsdTrackCuts(0)
dc740de4 23{
24 //
25 // Constructor. Initialization of pointers
26 //
27}
28
29AlidNdEtaAnalysisESDSelector::~AlidNdEtaAnalysisESDSelector()
30{
31 //
32 // Destructor
33 //
34
35 // histograms are in the output list and deleted when the output
36 // list is deleted by the TSelector dtor
37}
38
39void AlidNdEtaAnalysisESDSelector::SlaveBegin(TTree * tree)
40{
41 // The SlaveBegin() function is called after the Begin() function.
42 // When running with PROOF SlaveBegin() is called on each slave server.
43 // The tree argument is deprecated (on PROOF 0 is passed).
44
45 AlidNdEtaAnalysisSelector::SlaveBegin(tree);
46
47 if (fChain)
48 {
49 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fChain->GetUserInfo()->FindObject("AliESDtrackCuts"));
dc740de4 50 }
51
52 if (!fEsdTrackCuts)
53 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from user info.");
dc740de4 54}
55
56Bool_t AlidNdEtaAnalysisESDSelector::Process(Long64_t entry)
57{
58 // The Process() function is called for each entry in the tree (or possibly
59 // keyed object in the case of PROOF) to be processed. The entry argument
60 // specifies which entry in the currently loaded tree is to be processed.
61 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
62 // to read either all or the required parts of the data. When processing
63 // keyed objects with PROOF, the object is already loaded and is available
64 // via the fObject pointer.
65 //
66 // This function should contain the "body" of the analysis. It can contain
67 // simple or elaborate selection criteria, run algorithms on the data
68 // of the event and typically fill histograms.
69
70 // WARNING when a selector is used with a TChain, you must use
71 // the pointer to the current TTree to call GetEntry(entry).
72 // The entry is always the local entry number in the current tree.
73 // Assuming that fChain is the pointer to the TChain being processed,
74 // use fChain->GetTree()->GetEntry(entry).
75
76 if (AlidNdEtaAnalysisSelector::Process(entry) == kFALSE)
77 return kFALSE;
78
79 // Check prerequisites
80 if (!fESD)
81 {
82 AliDebug(AliLog::kError, "ESD branch not available");
83 return kFALSE;
84 }
85
86 if (!fEsdTrackCuts)
87 {
88 AliDebug(AliLog::kError, "fESDTrackCuts not available");
89 return kFALSE;
90 }
91
92 // ########################################################
93 // get the EDS vertex
94 const AliESDVertex* vtxESD = fESD->GetVertex();
95
96 // the vertex should be reconstructed
97 if (strcmp(vtxESD->GetName(),"default")==0)
98 return kTRUE;
99
100 Double_t vtx_res[3];
101 vtx_res[0] = vtxESD->GetXRes();
102 vtx_res[1] = vtxESD->GetYRes();
103 vtx_res[2] = vtxESD->GetZRes();
104
105 // the resolution should be reasonable???
106 if (vtx_res[2]==0 || vtx_res[2]>0.1)
107 return kTRUE;
108
109 Double_t vtx[3];
110 vtxESD->GetXYZ(vtx);
111
112 // ########################################################
113 // loop over esd tracks
114 Int_t nTracks = fESD->GetNumberOfTracks();
115 for (Int_t t=0; t<nTracks; t++)
116 {
117 AliESDtrack* esdTrack = fESD->GetTrack(t);
118 if (!esdTrack)
119 {
120 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", t));
121 continue;
122 }
123
124 // cut the esd track?
125 if (!fEsdTrackCuts->AcceptTrack(esdTrack))
126 continue;
127
128 Double_t p[3];
129 esdTrack->GetConstrainedPxPyPz(p); // ### TODO or GetInnerPxPyPy / GetOuterPxPyPy
130 TVector3 vector(p);
131
132 Float_t theta = vector.Theta();
133 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
134
5fbd0b17 135 fdNdEtaAnalysis->FillTrack(vtx[2], eta);
dc740de4 136
137 } // end of track loop
138
139 // for event count per vertex
140 fdNdEtaAnalysis->FillEvent(vtx[2]);
141
142 return kTRUE;
143}
144
145void AlidNdEtaAnalysisESDSelector::WriteObjects()
146{
147 AlidNdEtaAnalysisSelector::WriteObjects();
148
149 if (fEsdTrackCuts)
150 fEsdTrackCuts->SaveHistograms("esd_tracks_cuts");
dc740de4 151}