1 #include "AlidNdEtaAnalysisSelector.h"
7 #include <TParticlePDG.h>
11 #include <AliGenEventHeader.h>
12 #include <AliTracker.h>
14 #include "../esdTrackCuts/AliESDtrackCuts.h"
15 #include "dNdEtaCorrection.h"
16 #include "dNdEtaAnalysis.h"
18 ClassImp(AlidNdEtaAnalysisSelector)
20 AlidNdEtaAnalysisSelector::AlidNdEtaAnalysisSelector(TTree *) :
25 fdNdEtaAnalysisFinal(0)
28 // Constructor. Initialization of pointers
32 AlidNdEtaAnalysisSelector::~AlidNdEtaAnalysisSelector()
38 // histograms are in the output list and deleted when the output
39 // list is deleted by the TSelector dtor
42 void AlidNdEtaAnalysisSelector::SlaveBegin(TTree * tree)
44 // The SlaveBegin() function is called after the Begin() function.
45 // When running with PROOF SlaveBegin() is called on each slave server.
46 // The tree argument is deprecated (on PROOF 0 is passed).
48 AliSelector::SlaveBegin(tree);
50 fdNdEtaAnalysis = new dNdEtaAnalysis("dndeta");
54 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fChain->GetUserInfo()->FindObject("AliESDtrackCuts"));
55 fdNdEtaCorrection = dynamic_cast<dNdEtaCorrection*> (fChain->GetUserInfo()->FindObject("dNdEtaCorrection"));
59 printf("ERROR: Could not read EsdTrackCuts from user info\n");
62 printf("ERROR: Could not read dNdEtaCorrection from user info\n");
64 AliLog::SetClassDebugLevel("AliESDtrackCuts", 1);
67 Bool_t AlidNdEtaAnalysisSelector::Process(Long64_t entry)
69 // The Process() function is called for each entry in the tree (or possibly
70 // keyed object in the case of PROOF) to be processed. The entry argument
71 // specifies which entry in the currently loaded tree is to be processed.
72 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
73 // to read either all or the required parts of the data. When processing
74 // keyed objects with PROOF, the object is already loaded and is available
75 // via the fObject pointer.
77 // This function should contain the "body" of the analysis. It can contain
78 // simple or elaborate selection criteria, run algorithms on the data
79 // of the event and typically fill histograms.
81 // WARNING when a selector is used with a TChain, you must use
82 // the pointer to the current TTree to call GetEntry(entry).
83 // The entry is always the local entry number in the current tree.
84 // Assuming that fChain is the pointer to the TChain being processed,
85 // use fChain->GetTree()->GetEntry(entry).
87 if (AliSelector::Process(entry) == kFALSE)
90 // Check prerequisites
91 if (!fESD || !fEsdTrackCuts)
94 // ########################################################
96 const AliESDVertex* vtxESD = fESD->GetVertex();
98 // the vertex should be reconstructed
99 if (strcmp(vtxESD->GetName(),"default")==0)
103 vtx_res[0] = vtxESD->GetXRes();
104 vtx_res[1] = vtxESD->GetYRes();
105 vtx_res[2] = vtxESD->GetZRes();
107 // the resolution should be reasonable???
108 if (vtx_res[2]==0 || vtx_res[2]>0.1)
114 // ########################################################
115 // loop over esd tracks
116 Int_t nTracks = fESD->GetNumberOfTracks();
117 for (Int_t t=0; t<nTracks; t++)
119 AliESDtrack* esdTrack = fESD->GetTrack(t);
122 printf("ERROR: Could not retrieve track %d.\n", t);
126 // cut the esd track?
127 if (!fEsdTrackCuts->AcceptTrack(esdTrack))
131 esdTrack->GetConstrainedPxPyPz(p); // ### TODO or GetInnerPxPyPy / GetOuter
134 Float_t theta = vector.Theta();
135 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
137 Float_t correction = fdNdEtaCorrection->GetCorrection(vtx[2], eta);
139 fdNdEtaAnalysis->FillTrack(vtx[2], eta, correction);
141 } // end of track loop
143 // for event count per vertex
144 fdNdEtaAnalysis->FillEvent(vtx[2]);
149 void AlidNdEtaAnalysisSelector::SlaveTerminate()
151 // The SlaveTerminate() function is called after all entries or objects
152 // have been processed. When running with PROOF SlaveTerminate() is called
153 // on each slave server.
155 AliSelector::SlaveTerminate();
157 // Add the histograms to the output on each slave server
160 printf("ERROR: Output list not initialized\n");
164 fOutput->Add(fdNdEtaAnalysis->GetEtaVsVtxHistogram());
165 fOutput->Add(fdNdEtaAnalysis->GetEtaVsVtxUncorrectedHistogram());
166 fOutput->Add(fdNdEtaAnalysis->GetVtxHistogram());
168 fdNdEtaAnalysis->GetVtxHistogram()->Print();
172 void AlidNdEtaAnalysisSelector::Terminate()
174 // The Terminate() function is the last function to be called during
175 // a query. It always runs on the client, it can be used to present
176 // the results graphically or save the results to file.
178 AliSelector::Terminate();
180 TH2F* etaVsVtxHistogram = dynamic_cast<TH2F*> (fOutput->FindObject("eta_vs_vtx"));
181 TH2F* etaVsVtxUncorrectedHistogram = dynamic_cast<TH2F*> (fOutput->FindObject("eta_vs_vtx_uncorrected"));
182 TH1D* vtxHistogram = dynamic_cast<TH1D*> (fOutput->FindObject("vtx"));
184 if (!etaVsVtxHistogram || !vtxHistogram || !etaVsVtxUncorrectedHistogram)
186 printf("ERROR: Histograms not available %p %p %p\n", (void*) etaVsVtxHistogram, (void*) etaVsVtxUncorrectedHistogram, (void*) vtxHistogram);
190 fdNdEtaAnalysisFinal = new dNdEtaAnalysis("dNdEtaResult");
192 fdNdEtaAnalysisFinal->SetEtaVsVtxHistogram(etaVsVtxHistogram);
193 fdNdEtaAnalysisFinal->SetEtaVsVtxUncorrectedHistogram(etaVsVtxUncorrectedHistogram);
194 fdNdEtaAnalysisFinal->SetVtxHistogram(vtxHistogram);
196 fdNdEtaAnalysisFinal->Finish();
198 TFile* fout = new TFile("out.root","RECREATE");
200 fEsdTrackCuts->SaveHistograms("esd_tracks_cuts");
201 fdNdEtaCorrection->SaveHistograms();
202 fdNdEtaAnalysisFinal->SaveHistograms();
207 fdNdEtaAnalysisFinal->DrawHistograms();