3 #include "AliMultiplicityCorrectionSelector.h"
9 #include <TParticlePDG.h>
13 #include <TSelector.h>
17 #include <AliTracker.h>
18 #include <AliESDVertex.h>
20 #include <AliESDtrack.h>
21 #include <AliRunLoader.h>
24 #include <AliMultiplicity.h>
26 #include <AliHeader.h>
27 #include <AliGenEventHeader.h>
28 #include <../PYTHIA6/AliGenPythiaEventHeader.h>
29 #include <../EVGEN/AliGenCocktailEventHeader.h>
31 #include "esdTrackCuts/AliESDtrackCuts.h"
32 #include "dNdEta/AliMultiplicityCorrection.h"
33 #include "AliPWG0Helper.h"
34 #include "AliPWG0depHelper.h"
36 ClassImp(AliMultiplicityCorrectionSelector)
38 AliMultiplicityCorrectionSelector::AliMultiplicityCorrectionSelector() :
42 // Constructor. Initialization of pointers
46 AliMultiplicityCorrectionSelector::~AliMultiplicityCorrectionSelector()
52 // histograms are in the output list and deleted when the output
53 // list is deleted by the TSelector dtor
57 void AliMultiplicityCorrectionSelector::ReadUserObjects(TTree* tree)
59 // read the user objects, called from slavebegin and begin
61 if (!fEsdTrackCuts && fInput)
62 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fInput->FindObject("AliESDtrackCuts"));
64 if (!fEsdTrackCuts && tree)
65 fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (tree->GetUserInfo()->FindObject("AliESDtrackCuts"));
68 AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from input list.");
71 void AliMultiplicityCorrectionSelector::Begin(TTree * tree)
73 // The Begin() function is called at the start of the query.
74 // When running with PROOF Begin() is only called on the client.
75 // The tree argument is deprecated (on PROOF 0 is passed).
77 AliSelectorRL::Begin(tree);
79 ReadUserObjects(tree);
81 TString option = GetOption();
82 AliInfo(Form("Called with option %s.", option.Data()));
86 void AliMultiplicityCorrectionSelector::SlaveBegin(TTree * tree)
88 // The SlaveBegin() function is called after the Begin() function.
89 // When running with PROOF SlaveBegin() is called on each slave server.
90 // The tree argument is deprecated (on PROOF 0 is passed).
92 AliSelectorRL::SlaveBegin(tree);
94 ReadUserObjects(tree);
96 fMultiplicityCorrection = new AliMultiplicityCorrection("mult_correction", "mult_correction");
100 void AliMultiplicityCorrectionSelector::Init(TTree* tree)
102 // read the user objects
104 AliSelectorRL::Init(tree);
106 // Enable only the needed branches
109 tree->SetBranchStatus("*", 0);
110 tree->SetBranchStatus("fTriggerMask", 1);
111 tree->SetBranchStatus("fSPDVertex*", 1);
112 tree->SetBranchStatus("fTracks.fLabel", 1);
113 tree->SetBranchStatus("fTracks.fITSncls", 1);
114 tree->SetBranchStatus("fTracks.fTPCncls", 1);
115 tree->SetBranchStatus("fSPDMult*", 1);
117 AliESDtrackCuts::EnableNeededBranches(tree);
121 Bool_t AliMultiplicityCorrectionSelector::Process(Long64_t entry)
123 // The Process() function is called for each entry in the tree (or possibly
124 // keyed object in the case of PROOF) to be processed. The entry argument
125 // specifies which entry in the currently loaded tree is to be processed.
126 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
127 // to read either all or the required parts of the data. When processing
128 // keyed objects with PROOF, the object is already loaded and is available
129 // via the fObject pointer.
131 // This function should contain the "body" of the analysis. It can contain
132 // simple or elaborate selection criteria, run algorithms on the data
133 // of the event and typically fill histograms.
135 // WARNING when a selector is used with a TChain, you must use
136 // the pointer to the current TTree to call GetEntry(entry).
137 // The entry is always the local entry number in the current tree.
138 // Assuming that fTree is the pointer to the TChain being processed,
139 // use fTree->GetTree()->GetEntry(entry).
141 AliDebug(AliLog::kDebug+1,"Processing event ...\n");
143 if (AliSelectorRL::Process(entry) == kFALSE)
146 // check prerequesites
149 AliDebug(AliLog::kError, "ESD branch not available");
153 AliHeader* header = GetHeader();
156 AliDebug(AliLog::kError, "Header not available");
161 AliStack* stack = GetStack();
164 AliDebug(AliLog::kError, "Stack not available");
168 // getting the its multiplicity data
169 AliMultiplicity* itsMult = (AliMultiplicity*)fESD->GetMultiplicity();
171 AliDebug(AliLog::kError, "Multiplicity object not found in ESD");
175 // if (!fEsdTrackCuts)
177 // AliDebug(AliLog::kError, "fESDTrackCuts not available");
181 Bool_t vertexReconstructed = AliPWG0Helper::IsVertexReconstructed(fESD);
183 Bool_t eventTriggered = AliPWG0Helper::IsEventTriggered(fESD);
185 // only look at triggered events with a vertex
186 if (!(vertexReconstructed && eventTriggered))
190 AliGenEventHeader* genHeader = header->GenEventHeader();
193 genHeader->PrimaryVertex(vtxMC);
195 // vertex cut - should not be hard coded!!!
196 if (TMath::Abs(vtxMC[2]>10))
199 // loop over mc particles
200 Int_t nPrim = stack->GetNprimary();
202 for (Int_t iMc = 0; iMc < nPrim; ++iMc) {
204 AliDebug(AliLog::kDebug+1, Form("MC Loop: Processing particle %d.", iMc));
206 TParticle* particle = stack->Particle(iMc);
210 AliDebug(AliLog::kError, Form("UNEXPECTED: particle with label %d not found in stack (mc loop).", iMc));
214 if (AliPWG0Helper::IsPrimaryCharged(particle, nPrim) == kFALSE)
217 if (particle->GetPDG()->Charge()==0)
220 Float_t eta = particle->Eta();
222 fMultiplicityCorrection->FillMeasuredMultHit(eta);
224 }// end of mc particle
226 // ########################################################
227 // loop over spd tracklets
230 for(Int_t i=0; i<itsMult->GetNumberOfTracklets(); i++) {
231 Float_t theta = itsMult->GetTheta(i);
232 Float_t eta = -TMath::Log(TMath::Tan(0.5*theta));
234 fMultiplicityCorrection->FillTrueMultHit(eta);
238 fMultiplicityCorrection->NewEvent();
243 void AliMultiplicityCorrectionSelector::SlaveTerminate()
245 // The SlaveTerminate() function is called after all entries or objects
246 // have been processed. When running with PROOF SlaveTerminate() is called
247 // on each slave server.
249 AliSelectorRL::SlaveTerminate();
251 // Add the histograms to the output on each slave server
254 AliDebug(AliLog::kError, "ERROR: Output list not initialized");
258 fOutput->Add(fMultiplicityCorrection);
260 AliDebug(AliLog::kDebug+1,"Slave terminate ...\n");
264 void AliMultiplicityCorrectionSelector::Terminate()
266 // The Terminate() function is the last function to be called during
267 // a query. It always runs on the client, it can be used to present
268 // the results graphically or save the results to file.
270 AliDebug(AliLog::kDebug+1,"Terminate ...\n");
273 AliSelectorRL::Terminate();
275 fMultiplicityCorrection = dynamic_cast<AliMultiplicityCorrection*> (fOutput->FindObject("mult_correction"));
276 if (!fMultiplicityCorrection)
278 AliDebug(AliLog::kError, "Could not read object from output list");
282 fMultiplicityCorrection->Finish();
284 TFile* fout = new TFile(Form("correction_mult%s.root", GetOption()), "RECREATE");
286 // if (fEsdTrackCuts)
287 // fEsdTrackCuts->SaveHistograms("esd_track_cuts");
288 fMultiplicityCorrection->SaveHistograms();
293 fMultiplicityCorrection->DrawHistograms();