3 #include "AlidNdEtaAnalysisESDSelector.h"
11 #include <AliGenEventHeader.h>
13 #include "esdTrackCuts/AliESDtrackCuts.h"
14 #include "dNdEtaCorrection.h"
15 #include "dNdEtaAnalysis.h"
17 ClassImp(AlidNdEtaAnalysisESDSelector)
19 AlidNdEtaAnalysisESDSelector::AlidNdEtaAnalysisESDSelector() :
20 AlidNdEtaAnalysisSelector(),
25 // Constructor. Initialization of pointers
29 AlidNdEtaAnalysisESDSelector::~AlidNdEtaAnalysisESDSelector()
35 // histograms are in the output list and deleted when the output
36 // list is deleted by the TSelector dtor
39 void AlidNdEtaAnalysisESDSelector::SlaveBegin(TTree * tree)
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).
45 AlidNdEtaAnalysisSelector::SlaveBegin(tree);
49 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fChain->GetUserInfo()->FindObject("AliESDtrackCuts"));
50 fdNdEtaCorrection = dynamic_cast<dNdEtaCorrection*> (fChain->GetUserInfo()->FindObject("dNdEtaCorrection"));
54 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from user info.");
57 AliDebug(AliLog::kError, "ERROR: Could not read dNdEtaCorrection from user info.");
60 Bool_t AlidNdEtaAnalysisESDSelector::Process(Long64_t entry)
62 // The Process() function is called for each entry in the tree (or possibly
63 // keyed object in the case of PROOF) to be processed. The entry argument
64 // specifies which entry in the currently loaded tree is to be processed.
65 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
66 // to read either all or the required parts of the data. When processing
67 // keyed objects with PROOF, the object is already loaded and is available
68 // via the fObject pointer.
70 // This function should contain the "body" of the analysis. It can contain
71 // simple or elaborate selection criteria, run algorithms on the data
72 // of the event and typically fill histograms.
74 // WARNING when a selector is used with a TChain, you must use
75 // the pointer to the current TTree to call GetEntry(entry).
76 // The entry is always the local entry number in the current tree.
77 // Assuming that fChain is the pointer to the TChain being processed,
78 // use fChain->GetTree()->GetEntry(entry).
80 if (AlidNdEtaAnalysisSelector::Process(entry) == kFALSE)
83 // Check prerequisites
86 AliDebug(AliLog::kError, "ESD branch not available");
92 AliDebug(AliLog::kError, "fESDTrackCuts not available");
96 // ########################################################
98 const AliESDVertex* vtxESD = fESD->GetVertex();
100 // the vertex should be reconstructed
101 if (strcmp(vtxESD->GetName(),"default")==0)
105 vtx_res[0] = vtxESD->GetXRes();
106 vtx_res[1] = vtxESD->GetYRes();
107 vtx_res[2] = vtxESD->GetZRes();
109 // the resolution should be reasonable???
110 if (vtx_res[2]==0 || vtx_res[2]>0.1)
116 // ########################################################
117 // loop over esd tracks
118 Int_t nTracks = fESD->GetNumberOfTracks();
119 for (Int_t t=0; t<nTracks; t++)
121 AliESDtrack* esdTrack = fESD->GetTrack(t);
124 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", t));
128 // cut the esd track?
129 if (!fEsdTrackCuts->AcceptTrack(esdTrack))
133 esdTrack->GetConstrainedPxPyPz(p); // ### TODO or GetInnerPxPyPy / GetOuterPxPyPy
136 Float_t theta = vector.Theta();
137 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
139 Float_t correction = fdNdEtaCorrection->GetCorrection(vtx[2], eta);
141 fdNdEtaAnalysis->FillTrack(vtx[2], eta, correction);
143 } // end of track loop
145 // for event count per vertex
146 fdNdEtaAnalysis->FillEvent(vtx[2]);
151 void AlidNdEtaAnalysisESDSelector::WriteObjects()
153 AlidNdEtaAnalysisSelector::WriteObjects();
156 fEsdTrackCuts->SaveHistograms("esd_tracks_cuts");
158 if (fdNdEtaCorrection)
159 fdNdEtaCorrection->SaveHistograms();