3 #include "AlidNdEtaAnalysisESDSelector.h"
14 #include <AliESDVertex.h>
17 #include "esdTrackCuts/AliESDtrackCuts.h"
18 #include "dNdEta/dNdEtaAnalysis.h"
19 #include "AliPWG0Helper.h"
21 #include "AliGenEventHeader.h"
22 #include "AliHeader.h"
24 #include "TParticle.h"
26 ClassImp(AlidNdEtaAnalysisESDSelector)
28 AlidNdEtaAnalysisESDSelector::AlidNdEtaAnalysisESDSelector() :
35 // Constructor. Initialization of pointers
38 AliLog::SetClassDebugLevel("AlidNdEtaAnalysisESDSelector", AliLog::kDebug);
41 AlidNdEtaAnalysisESDSelector::~AlidNdEtaAnalysisESDSelector()
47 // histograms are in the output list and deleted when the output
48 // list is deleted by the TSelector dtor
51 void AlidNdEtaAnalysisESDSelector::Begin(TTree* tree)
55 ReadUserObjects(tree);
58 void AlidNdEtaAnalysisESDSelector::ReadUserObjects(TTree* tree)
60 // read the user objects, called from slavebegin and begin
62 if (!fEsdTrackCuts && fInput)
63 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts"));
65 if (!fEsdTrackCuts && tree)
66 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (tree->GetUserInfo()->FindObject("AliESDtrackCuts"));
69 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list.");
72 void AlidNdEtaAnalysisESDSelector::SlaveBegin(TTree* tree)
74 // The SlaveBegin() function is called after the Begin() function.
75 // When running with PROOF SlaveBegin() is called on each slave server.
76 // The tree argument is deprecated (on PROOF 0 is passed).
78 AliSelectorRL::SlaveBegin(tree);
80 ReadUserObjects(tree);
82 fdNdEtaAnalysis = new dNdEtaAnalysis("dndeta", "dndeta");
83 fMult = new TH1F("fMult", "fMult;Ntracks;Count", 201, -0.5, 200.5);
86 void AlidNdEtaAnalysisESDSelector::Init(TTree* tree)
88 // read the user objects
90 AliSelectorRL::Init(tree);
92 // Enable only the needed branches
95 tree->SetBranchStatus("*", 0);
96 tree->SetBranchStatus("fTriggerMask", 1);
97 tree->SetBranchStatus("fSPDVertex*", 1);
98 tree->SetBranchStatus("fTracks.fLabel", 1);
100 AliESDtrackCuts::EnableNeededBranches(tree);
104 Bool_t AlidNdEtaAnalysisESDSelector::Process(Long64_t entry)
106 // loop over all events
108 if (AliSelectorRL::Process(entry) == kFALSE)
111 // Check prerequisites
114 AliDebug(AliLog::kError, "ESD branch not available");
120 AliDebug(AliLog::kError, "fESDTrackCuts not available");
124 if (AliPWG0Helper::IsEventTriggered(fESD) == kFALSE)
126 AliDebug(AliLog::kDebug+1, Form("Skipping event %d because it was not triggered", (Int_t) entry));
130 if (AliPWG0Helper::IsVertexReconstructed(fESD) == kFALSE)
132 AliDebug(AliLog::kDebug+1, Form("Skipping event %d because its vertex was not reconstructed", (Int_t) entry));
136 AliHeader* header = GetHeader();
139 AliDebug(AliLog::kError, "Header not available");
143 AliStack* stack = GetStack();
146 AliDebug(AliLog::kError, "Stack not available");
151 AliGenEventHeader* genHeader = header->GenEventHeader();
154 genHeader->PrimaryVertex(vtxMC);
156 // ########################################################
157 // get the ESD vertex
158 const AliESDVertex* vtxESD = fESD->GetVertex();
163 //vtx[2] -= 2.951034e-03 + 6.859620e-04 * vtxMC[2];
165 // get number of "good" tracks
166 TObjArray* list = fEsdTrackCuts->GetAcceptedTracks(fESD);
167 Int_t nGoodTracks = list->GetEntries();
170 //Int_t nContributors = vtxESD->GetNContributors();
172 // loop over esd tracks
173 for (Int_t t=0; t<nGoodTracks; t++)
175 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (list->At(t));
178 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", t));
182 Int_t label = TMath::Abs(esdTrack->GetLabel());
184 TParticle* particle = stack->Particle(label);
187 AliDebug(AliLog::kError, Form("ERROR: Could not retrieve particle %d.", esdTrack->GetLabel()));
192 esdTrack->GetConstrainedPxPyPz(p); // ### TODO should be okay because we have a vertex, however GetInnerPxPyPy / GetOuterPxPyPy also exist
195 Float_t theta = vector.Theta();
196 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
197 Float_t pt = vector.Pt();
199 //eta = particle->Eta();
200 //pt = particle->Pt();
202 fdNdEtaAnalysis->FillTrack(vtx[2], eta, pt);
203 } // end of track loop
208 // for event count per vertex
209 fdNdEtaAnalysis->FillEvent(vtx[2], nGoodTracks);
210 fMult->Fill(nGoodTracks);
215 void AlidNdEtaAnalysisESDSelector::SlaveTerminate()
217 // The SlaveTerminate() function is called after all entries or objects
218 // have been processed. When running with PROOF SlaveTerminate() is called
219 // on each slave server.
221 AliSelectorRL::SlaveTerminate();
223 // Add the histograms to the output on each slave server
226 AliDebug(AliLog::kError, Form("ERROR: Output list not initialized."));
230 // Add the objects to the output list and set them to 0, so that the destructor does not delete them.
232 fOutput->Add(fdNdEtaAnalysis);
238 void AlidNdEtaAnalysisESDSelector::Terminate()
240 // The Terminate() function is the last function to be called during
241 // a query. It always runs on the client, it can be used to present
242 // the results graphically or save the results to file.
244 AliSelectorRL::Terminate();
246 fdNdEtaAnalysis = dynamic_cast<dNdEtaAnalysis*> (fOutput->FindObject("dndeta"));
247 fMult = dynamic_cast<TH1F*> (fOutput->FindObject("fMult"));
249 if (!fdNdEtaAnalysis)
251 AliDebug(AliLog::kError, "ERROR: Histograms not available");
255 TFile* fout = new TFile("analysis_esd_raw.root", "RECREATE");
258 fdNdEtaAnalysis->SaveHistograms();
261 fEsdTrackCuts->SaveHistograms("esd_tracks_cuts");