3 #include "AlidNdEtaAnalysisESDSelector.h"
13 #include <AliESDVertex.h>
16 #include "esdTrackCuts/AliESDtrackCuts.h"
17 #include "dNdEta/dNdEtaAnalysis.h"
19 ClassImp(AlidNdEtaAnalysisESDSelector)
21 AlidNdEtaAnalysisESDSelector::AlidNdEtaAnalysisESDSelector() :
26 // Constructor. Initialization of pointers
29 AliLog::SetClassDebugLevel("AlidNdEtaAnalysisESDSelector", AliLog::kDebug);
32 AlidNdEtaAnalysisESDSelector::~AlidNdEtaAnalysisESDSelector()
38 // histograms are in the output list and deleted when the output
39 // list is deleted by the TSelector dtor
42 void AlidNdEtaAnalysisESDSelector::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);
52 printf("Printing input list:\n");
56 if (!fEsdTrackCuts && fInput)
57 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts"));
60 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list.");
62 fdNdEtaAnalysis = new dNdEtaAnalysis("dndeta", "dndeta");
65 void AlidNdEtaAnalysisESDSelector::Init(TTree* tree)
67 // read the user objects
69 AliSelector::Init(tree);
71 if (!fEsdTrackCuts && fTree)
72 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fTree->GetUserInfo()->FindObject("AliESDtrackCuts"));
75 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from user info.");
78 Bool_t AlidNdEtaAnalysisESDSelector::Process(Long64_t entry)
80 // The Process() function is called for each entry in the tree (or possibly
81 // keyed object in the case of PROOF) to be processed. The entry argument
82 // specifies which entry in the currently loaded tree is to be processed.
83 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
84 // to read either all or the required parts of the data. When processing
85 // keyed objects with PROOF, the object is already loaded and is available
86 // via the fObject pointer.
88 // This function should contain the "body" of the analysis. It can contain
89 // simple or elaborate selection criteria, run algorithms on the data
90 // of the event and typically fill histograms.
92 // WARNING when a selector is used with a TChain, you must use
93 // the pointer to the current TTree to call GetEntry(entry).
94 // The entry is always the local entry number in the current tree.
95 // Assuming that fTree is the pointer to the TChain being processed,
96 // use fTree->GetTree()->GetEntry(entry).
98 if (AliSelector::Process(entry) == kFALSE)
101 // Check prerequisites
104 AliDebug(AliLog::kError, "ESD branch not available");
110 AliDebug(AliLog::kError, "fESDTrackCuts not available");
114 // ########################################################
115 // get the EDS vertex
116 const AliESDVertex* vtxESD = fESD->GetVertex();
118 // the vertex should be reconstructed
119 if (strcmp(vtxESD->GetName(),"default")==0)
123 vtx_res[0] = vtxESD->GetXRes();
124 vtx_res[1] = vtxESD->GetYRes();
125 vtx_res[2] = vtxESD->GetZRes();
127 // the resolution should be reasonable???
128 if (vtx_res[2]==0 || vtx_res[2]>0.1)
134 // ########################################################
135 // loop over esd tracks
136 Int_t nTracks = fESD->GetNumberOfTracks();
137 for (Int_t t=0; t<nTracks; t++)
139 AliESDtrack* esdTrack = fESD->GetTrack(t);
142 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", t));
146 // cut the esd track?
147 if (!fEsdTrackCuts->AcceptTrack(esdTrack))
151 esdTrack->GetConstrainedPxPyPz(p); // ### TODO or GetInnerPxPyPy / GetOuterPxPyPy
154 Float_t theta = vector.Theta();
155 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
157 fdNdEtaAnalysis->FillTrack(vtx[2], eta);
159 } // end of track loop
161 // for event count per vertex
162 fdNdEtaAnalysis->FillEvent(vtx[2]);
167 void AlidNdEtaAnalysisESDSelector::SlaveTerminate()
169 // The SlaveTerminate() function is called after all entries or objects
170 // have been processed. When running with PROOF SlaveTerminate() is called
171 // on each slave server.
173 AliSelector::SlaveTerminate();
175 // Add the histograms to the output on each slave server
178 AliDebug(AliLog::kError, Form("ERROR: Output list not initialized."));
182 fOutput->Add(fdNdEtaAnalysis);
185 void AlidNdEtaAnalysisESDSelector::Terminate()
187 // The Terminate() function is the last function to be called during
188 // a query. It always runs on the client, it can be used to present
189 // the results graphically or save the results to file.
191 AliSelector::Terminate();
193 fdNdEtaAnalysis = dynamic_cast<dNdEtaAnalysis*> (fOutput->FindObject("dndeta"));
195 if (!fdNdEtaAnalysis)
197 AliDebug(AliLog::kError, Form("ERROR: Histograms not available %p", (void*) fdNdEtaAnalysis));
201 TFile* fout = new TFile("analysis_esd.root","RECREATE");
204 fdNdEtaAnalysis->SaveHistograms();
207 fEsdTrackCuts->SaveHistograms("esd_tracks_cuts");