3 #include "AlidNdEtaAnalysisESDSelector.h"
13 #include <AliESDVertex.h>
16 #include "esdTrackCuts/AliESDtrackCuts.h"
17 #include "dNdEta/dNdEtaAnalysis.h"
18 #include "AliPWG0Helper.h"
20 #include "AliGenEventHeader.h"
21 #include "AliHeader.h"
23 #include "TParticle.h"
25 ClassImp(AlidNdEtaAnalysisESDSelector)
27 AlidNdEtaAnalysisESDSelector::AlidNdEtaAnalysisESDSelector() :
33 // Constructor. Initialization of pointers
36 AliLog::SetClassDebugLevel("AlidNdEtaAnalysisESDSelector", AliLog::kDebug);
39 AlidNdEtaAnalysisESDSelector::~AlidNdEtaAnalysisESDSelector()
45 // histograms are in the output list and deleted when the output
46 // list is deleted by the TSelector dtor
49 void AlidNdEtaAnalysisESDSelector::Begin(TTree* tree)
53 ReadUserObjects(tree);
56 void AlidNdEtaAnalysisESDSelector::ReadUserObjects(TTree* tree)
58 // read the user objects, called from slavebegin and begin
60 if (!fEsdTrackCuts && fInput)
61 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts"));
63 if (!fEsdTrackCuts && tree)
64 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (tree->GetUserInfo()->FindObject("AliESDtrackCuts"));
67 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list.");
70 void AlidNdEtaAnalysisESDSelector::SlaveBegin(TTree* tree)
72 // The SlaveBegin() function is called after the Begin() function.
73 // When running with PROOF SlaveBegin() is called on each slave server.
74 // The tree argument is deprecated (on PROOF 0 is passed).
76 AliSelectorRL::SlaveBegin(tree);
78 ReadUserObjects(tree);
80 fdNdEtaAnalysis = new dNdEtaAnalysis("dndeta", "dndeta");
83 void AlidNdEtaAnalysisESDSelector::Init(TTree* tree)
85 // read the user objects
87 AliSelectorRL::Init(tree);
89 // Enable only the needed branches
92 tree->SetBranchStatus("*", 0);
93 tree->SetBranchStatus("fTriggerMask", 1);
94 tree->SetBranchStatus("fSPDVertex*", 1);
95 tree->SetBranchStatus("fTracks.fLabel", 1);
97 AliESDtrackCuts::EnableNeededBranches(tree);
101 Bool_t AlidNdEtaAnalysisESDSelector::Process(Long64_t entry)
103 // loop over all events
105 if (AliSelectorRL::Process(entry) == kFALSE)
108 // Check prerequisites
111 AliDebug(AliLog::kError, "ESD branch not available");
117 AliDebug(AliLog::kError, "fESDTrackCuts not available");
121 if (AliPWG0Helper::IsEventTriggered(fESD) == kFALSE)
123 AliDebug(AliLog::kDebug+1, Form("Skipping event %d because it was not triggered", (Int_t) entry));
127 if (AliPWG0Helper::IsVertexReconstructed(fESD) == kFALSE)
129 AliDebug(AliLog::kDebug+1, Form("Skipping event %d because its vertex was not reconstructed", (Int_t) entry));
133 AliHeader* header = GetHeader();
136 AliDebug(AliLog::kError, "Header not available");
140 AliStack* stack = GetStack();
143 AliDebug(AliLog::kError, "Stack not available");
148 AliGenEventHeader* genHeader = header->GenEventHeader();
151 genHeader->PrimaryVertex(vtxMC);
153 // ########################################################
154 // get the ESD vertex
155 const AliESDVertex* vtxESD = fESD->GetVertex();
161 // get number of "good" tracks
162 TObjArray* list = fEsdTrackCuts->GetAcceptedTracks(fESD);
163 Int_t nGoodTracks = list->GetEntries();
166 //Int_t nContributors = vtxESD->GetNContributors();
168 // loop over esd tracks
169 for (Int_t t=0; t<nGoodTracks; t++)
171 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (list->At(t));
174 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", t));
178 Int_t label = TMath::Abs(esdTrack->GetLabel());
182 AliDebug(AliLog::kError, Form("Label is 0. Skipping! Track %d.", t));
186 TParticle* particle = stack->Particle(label);
189 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve particle %d.", esdTrack->GetLabel()));
194 esdTrack->GetConstrainedPxPyPz(p); // ### TODO should be okay because we have a vertex, however GetInnerPxPyPy / GetOuterPxPyPy also exist
197 Float_t theta = vector.Theta();
198 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
199 Float_t pt = vector.Pt();
201 //eta = particle->Eta();
202 //pt = particle->Pt();
204 fdNdEtaAnalysis->FillTrack(vtx[2], eta, pt);
205 } // end of track loop
210 // for event count per vertex
211 fdNdEtaAnalysis->FillEvent(vtx[2], nGoodTracks);
216 void AlidNdEtaAnalysisESDSelector::SlaveTerminate()
218 // The SlaveTerminate() function is called after all entries or objects
219 // have been processed. When running with PROOF SlaveTerminate() is called
220 // on each slave server.
222 AliSelectorRL::SlaveTerminate();
224 // Add the histograms to the output on each slave server
227 AliDebug(AliLog::kError, Form("ERROR: Output list not initialized."));
231 // Add the objects to the output list and set them to 0, so that the destructor does not delete them.
233 fOutput->Add(fdNdEtaAnalysis);
237 void AlidNdEtaAnalysisESDSelector::Terminate()
239 // The Terminate() function is the last function to be called during
240 // a query. It always runs on the client, it can be used to present
241 // the results graphically or save the results to file.
243 AliSelectorRL::Terminate();
245 fdNdEtaAnalysis = dynamic_cast<dNdEtaAnalysis*> (fOutput->FindObject("dndeta"));
247 if (!fdNdEtaAnalysis)
249 AliDebug(AliLog::kError, "ERROR: Histograms not available");
253 TFile* fout = new TFile("analysis_esd_raw.root", "RECREATE");
256 fdNdEtaAnalysis->SaveHistograms();
259 fEsdTrackCuts->SaveHistograms("esd_tracks_cuts");