2 // Calculate the corrections in the base regions
14 #include "AliBaseMCCorrectionsTask.h"
15 #include "AliBaseMCTrackDensity.h"
16 #include "AliCorrectionManagerBase.h"
18 #include "AliESDEvent.h"
19 #include "AliMCEvent.h"
20 #include "AliAODForwardMult.h"
23 #include <TDirectory.h>
29 //====================================================================
31 const char* GetEventName(Bool_t tr, Bool_t vtx)
33 return Form("nEvents%s%s", (tr ? "Tr" : ""), (vtx ? "Vtx" : ""));
37 //====================================================================
38 AliBaseMCCorrectionsTask::AliBaseMCCorrectionsTask()
58 //____________________________________________________________________
59 AliBaseMCCorrectionsTask::AliBaseMCCorrectionsTask(const char* name,
60 AliCorrectionManagerBase* m)
61 : AliBaseESDTask(name, "", m),
62 fInspector("eventInspector"),
78 "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,"
79 "AliESDFMD.,SPDVertex.,PrimaryVertex.";
83 //____________________________________________________________________
85 AliBaseMCCorrectionsTask::SetVertexAxis(Int_t nBin, Double_t min,
89 // Set the vertex axis to use
92 // nBins Number of bins
93 // vzMin Least @f$z@f$ coordinate of interation point
94 // vzMax Largest @f$z@f$ coordinate of interation point
103 AliWarning(Form("Minimum vertex %f < -10, make sure you want this",min));
105 AliWarning(Form("Minimum vertex %f > +10, make sure you want this",max));
107 fVtxAxis.Set(nBin, min, max);
109 //____________________________________________________________________
111 AliBaseMCCorrectionsTask::SetVertexAxis(const TAxis& axis)
114 // Set the vertex axis to use
119 SetVertexAxis(axis.GetNbins(),axis.GetXmin(),axis.GetXmax());
122 //____________________________________________________________________
124 AliBaseMCCorrectionsTask::SetEtaAxis(Int_t nBin, Double_t min, Double_t max)
127 // Set the eta axis to use
130 // nBins Number of bins
131 // vzMin Least @f$\eta@f$
132 // vzMax Largest @f$\eta@f$
140 AliWarning(Form("Minimum eta %f < -4, make sure you want this",min));
142 AliWarning(Form("Minimum eta %f > +6, make sure you want this",max));
143 fEtaAxis.Set(nBin, min, max);
145 //____________________________________________________________________
147 AliBaseMCCorrectionsTask::SetEtaAxis(const TAxis& axis)
150 // Set the eta axis to use
155 SetEtaAxis(axis.GetNbins(),axis.GetXmin(),axis.GetXmax());
158 //____________________________________________________________________
160 AliBaseMCCorrectionsTask::DefineBins(TList* l)
162 if (!fVtxBins) fVtxBins = new TObjArray(fVtxAxis.GetNbins(), 1);
163 if (fVtxBins->GetEntries() > 0) return;
165 fVtxBins->SetOwner();
166 for (Int_t i = 1; i <= fVtxAxis.GetNbins(); i++) {
167 Double_t low = fVtxAxis.GetBinLowEdge(i);
168 Double_t high = fVtxAxis.GetBinUpEdge(i);
169 VtxBin* bin = CreateVtxBin(low, high);
170 fVtxBins->AddAt(bin, i);
171 bin->CreateOutputObjects(l);
175 //____________________________________________________________________
177 AliBaseMCCorrectionsTask::Book()
180 // Create output objects
184 fNeededCorrections = 0;
185 fExtraCorrections = 0;
187 fHEvents = new TH1I(GetEventName(false,false),
188 "Number of all events",
192 fHEvents->SetXTitle("v_{z} [cm]");
193 fHEvents->SetYTitle("# of events");
194 fHEvents->SetFillColor(kBlue+1);
195 fHEvents->SetFillStyle(3001);
196 fHEvents->SetDirectory(0);
197 fList->Add(fHEvents);
199 fHEventsTr = new TH1I(GetEventName(true, false),
200 "Number of triggered events",
204 fHEventsTr->SetXTitle("v_{z} [cm]");
205 fHEventsTr->SetYTitle("# of events");
206 fHEventsTr->SetFillColor(kRed+1);
207 fHEventsTr->SetFillStyle(3001);
208 fHEventsTr->SetDirectory(0);
209 fList->Add(fHEventsTr);
211 fHEventsTrVtx = new TH1I(GetEventName(true,true),
212 "Number of events w/trigger and vertex",
216 fHEventsTrVtx->SetXTitle("v_{z} [cm]");
217 fHEventsTrVtx->SetYTitle("# of events");
218 fHEventsTrVtx->SetFillColor(kBlue+1);
219 fHEventsTrVtx->SetFillStyle(3001);
220 fHEventsTrVtx->SetDirectory(0);
221 fList->Add(fHEventsTrVtx);
223 // Copy axis objects to output
224 TH1* vtxAxis = new TH1D("vtxAxis", "Vertex axis",
228 TH1* etaAxis = new TH1D("etaAxis", "Eta axis",
235 AliInfo(Form("Initialising sub-routines: %p, %p",
236 &fInspector, &GetTrackDensity()));
237 GetTrackDensity().CreateOutputObjects(fList);
242 //____________________________________________________________________
244 AliBaseMCCorrectionsTask::Event(AliESDEvent& esd)
247 // Process each event
253 // Get the input data - MC event
254 AliMCEvent* mcEvent = MCEvent();
256 AliWarning("No MC event found");
261 UInt_t triggers = 0; // Trigger bits
262 Bool_t lowFlux = true; // Low flux flag
263 UShort_t iVz = 0; // Vertex bin from ESD
264 TVector3 ip(1024,1024,1000);
265 Double_t cent = -1; // Centrality
266 UShort_t iVzMc = 0; // Vertex bin from MC
267 Double_t vZMc = 1000; // Z coordinate of IP vertex from MC
268 Double_t b = -1; // Impact parameter
269 Double_t cMC = -1; // Centrality estimate from b
270 Int_t nPart = -1; // Number of participants
271 Int_t nBin = -1; // Number of binary collisions
272 Double_t phiR = 100; // Reaction plane from MC
273 UShort_t nClusters = 0; // Number of SPD clusters
275 UInt_t retESD = fInspector.Process(&esd, triggers, lowFlux, iVz, ip,
278 Bool_t isAccepted = true;
280 if (retESD & AliFMDEventInspector::kNoEvent) isAccepted = false;
281 if (retESD & AliFMDEventInspector::kNoTriggers) isAccepted = false;
282 if (retESD & AliFMDEventInspector::kNoVertex) isAccepted = false;
283 if (retESD & AliFMDEventInspector::kNoFMD) isAccepted = false;
284 if (!isAccepted) return false;
285 // returns if there is not event , does not pass phys selection ,
286 // has no veretx and lack of FMD data.
287 // with good veretx outside z range it will continue
291 fInspector.ProcessMC(mcEvent, triggers, iVzMc, vZMc,
292 b, cMC, nPart, nBin, phiR);
294 fInspector.CompareResults(ip.Z(), vZMc,
298 Bool_t isInel = triggers & AliAODForwardMult::kInel;
299 Bool_t hasVtx = retESD == AliFMDMCEventInspector::kOk;
301 // Fill the event count histograms
302 if (isInel) fHEventsTr->Fill(vZMc);
303 if (isInel && hasVtx) fHEventsTrVtx->Fill(vZMc);
304 fHEvents->Fill(vZMc);
306 // Now find our vertex bin object
308 UShort_t usedZbin = iVzMc;
309 if (fUseESDVertex) usedZbin = iVz;
312 if (usedZbin > 0 && usedZbin <= fVtxAxis.GetNbins())
313 bin = static_cast<VtxBin*>(fVtxBins->At(usedZbin));
315 // AliError(Form("No vertex bin object @ %d (%f)", iVzMc, vZMc));
319 return ProcessESD(esd, *mcEvent, *bin, vZMc);
322 //____________________________________________________________________
324 AliBaseMCCorrectionsTask::Finalize()
333 CreateCorrections(fResults);
335 TIter next(fVtxBins);
338 while ((bin = static_cast<VtxBin*>(next())))
339 FinalizeVtxBin(bin, iVz++);
344 //____________________________________________________________________
346 AliBaseMCCorrectionsTask::Print(Option_t* option) const
348 AliBaseESDTask::Print(option);
349 std::cout << " Vertex bins: " << fVtxAxis.GetNbins() << '\n'
350 << " Vertex range: [" << fVtxAxis.GetXmin()
351 << "," << fVtxAxis.GetXmax() << "]\n"
352 << " Eta bins: " << fEtaAxis.GetNbins() << '\n'
353 << " Eta range: [" << fEtaAxis.GetXmin()
354 << "," << fEtaAxis.GetXmax() << "]"
358 //====================================================================
360 AliBaseMCCorrectionsTask::VtxBin::BinName(Double_t low,
364 buf = Form("vtx%+05.1f_%+05.1f", low, high);
365 buf.ReplaceAll("+", "p");
366 buf.ReplaceAll("-", "m");
367 buf.ReplaceAll(".", "d");
372 //____________________________________________________________________
373 AliBaseMCCorrectionsTask::VtxBin::VtxBin()
379 //____________________________________________________________________
380 AliBaseMCCorrectionsTask::VtxBin::VtxBin(Double_t low,
384 : TNamed(BinName(low, high),
385 Form("%+5.1fcm<v_{z}<%+5.1fcm", low, high)),
389 fPrimary = new TH2D("primary", "Primaries",
390 axis.GetNbins(), axis.GetXmin(), axis.GetXmax(),
391 nPhi, 0, 2*TMath::Pi());
392 fPrimary->SetXTitle("#eta");
393 fPrimary->SetYTitle("#varphi [radians]");
395 fPrimary->SetDirectory(0);
397 fCounts = new TH1D("counts", "Counts", 1, 0, 1);
398 fCounts->SetXTitle("Events");
399 fCounts->SetYTitle("# of Events");
400 fCounts->SetDirectory(0);
404 //____________________________________________________________________
406 AliBaseMCCorrectionsTask::VtxBin::CreateOutputObjects(TList* l)
408 TList* d = new TList;
409 d->SetName(GetName());