11 #include <TGraphAsymmErrors.h>
12 #include <AliAnalysisManager.h>
13 #include <AliAODEvent.h>
14 #include <AliAODHandler.h>
15 #include <AliAODInputHandler.h>
26 DGUARD(fDebug, 3,
"Default CTOR of AliForwarddNdetaTask");
39 DGUARD(fDebug, 3,
"Named CTOR of AliForwarddNdetaTask");
49 DGUARD(fDebug, 3,
"Copy CTOR of AliForwarddNdetaTask");
69 "Make a centrality bin for AliForwarddNdetaTask: %s [%5.1f%%,%5.1f%%]",
91 if (!forward)
return 0;
108 if (aVtx < 37.5 || aVtx > 400)
return;
110 DMSG(fDebug,0,
"Got satelitte vertex %f", vtx);
112 TH2* hists[] = { data, dataMC };
124 for (
Int_t iX = 0; iX<=data->GetNbinsX(); iX++) {
127 Double_t x = data->GetXaxis()->GetBinCenter(iX);
129 if (((vtx > 60 && vtx < 90) && x < 3) ||
130 ((vtx > 330 && vtx < 350) && x > -2.5) ||
131 ((vtx < 100 || vtx > 305) && TMath::Abs(x) < 4.5) ||
132 (vtx < 50 && TMath::Abs(x) < 4.75))
135 for (
Int_t iH = 0; iH < 2; iH++) {
136 if (!hists[iH])
continue;
139 for (
Int_t iY = 0; iY<=hists[iH]->GetNbinsY()+1; iY++) {
140 hists[iH]->SetBinContent(iX, iY, 0);
141 hists[iH]->SetBinError(iX, iY, 0);
147 DMSG(fDebug,1,
"Correcting with corrEmpty=true");
161 const Int_t phiBin1 = 17;
162 const Int_t phiBin2 = 18;
163 for (
Int_t iH = 0; iH < 2; iH++) {
164 if (!hists[iH])
continue;
166 Int_t midX = hists[iH]->GetNbinsX() / 2;
168 for (
Int_t i = 1; i <= midX; i++) {
169 hists[iH]->SetBinContent(i, phiBin1, 0);
170 hists[iH]->SetBinContent(i, phiBin2, 0);
171 hists[iH]->SetBinError(i, phiBin1, 0);
172 hists[iH]->SetBinError(i, phiBin2, 0);
197 if (
gSystem->ExpandPathName(path)) {
201 if (!path.Contains(
"empirical"))
202 path =
gSystem->ConcatFileName(path.Data(),
"empirical.root");
204 if (!empUrl.GetAnchor() || empUrl.GetAnchor()[0] ==
'\0')
205 empUrl.SetAnchor(
"default");
206 empFile = TFile::Open(empUrl.GetUrl());
208 DMSG(fDebug,1,
"%s not found", empUrl.GetUrl());
211 DMSG(fDebug,0,
"Got empirical file %s", empUrl.GetUrl());
213 TString base(GetName()); base.ReplaceAll(
"dNdeta",
"");
214 TString empAnch = empUrl.GetAnchor();
215 TObject* empObj = empFile->Get(Form(
"%s/%s",base.Data(),empAnch.Data()));
217 (empObj->IsA()->InheritsFrom(TH1::Class()) ||
218 empObj->IsA()->InheritsFrom(TGraphAsymmErrors::Class())))) {
219 Warning(
"LoadEmpirical",
"Didn't get Forward/%s from %s",
220 empAnch.Data(), empUrl.GetUrl());
223 DMSG(fDebug,0,
"Got empirical correction %s [%s]", empObj->GetName(),
224 empObj->ClassName());
226 static_cast<TNamed*
>(empObj)->SetName(
"empirical");
229 if (!empObj->IsA()->InheritsFrom(TH1::Class()))
233 TH1* h =
static_cast<TH1*
>(empObj);
237 TH1* xy =
static_cast<TH2*
>(
fSums->FindObject(
"vertexAccXY"));
246 Info(
"LoadEmpirical",
"Shifts (%f-%f)=%f, (%f-%f)=%f",
249 if (TMath::Abs(dx) > 1e-3 || TMath::Abs(dy) > 1e-3)
250 delta = TMath::Sqrt(dx*dx+dy*dy);
256 TF1* f =
new TF1(
"deltaCorr",
"1+[2]*([0]+(x<[1])*pow([0]*(x-[1]),2))");
257 f->SetParNames(
"\\delta",
"\\eta_{0}",
"a");
258 f->SetParameter(0,delta);
259 f->SetParameter(1,-2.0);
260 f->SetParameter(2,.10);
261 Info(
"LoadEmpirical",
"Appying correction for IP delta=%f", delta);
262 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
264 if (c < 1e-6)
continue;
267 Double_t eta = h->GetXaxis()->GetBinCenter(i);
270 h->SetBinContent(i, c*cor);
271 h->SetBinError(i, e*cor);
285 TString oadb(
gSystem->ConcatFileName(AliAnalysisManager::GetOADBPath(),
286 "PWGLF/FORWARD/CORRECTIONS/data"));
287 const char* dirs[] = {
291 "${OADB_PATH}/PWGLF/FORWARD/EMPIRICAL",
292 "${ALICE_PHYSICS}/OADB/PWGLF/FORWARD/EMPIRICAL",
295 const char** pdir = dirs;
298 const char* fns[] = {
"",
"empirical_000138190.root", 0 };
299 const char** pfn = fns;
318 TString base(GetName()); base.ReplaceAll(
"dNdeta",
"");
319 TString hName(Form(
"dndeta%s",base.Data()));
320 TH1* h =
static_cast<TH1*
>(out->FindObject(hName));
322 Warning(
"End",
"%s not found in %s",
323 hName.Data(), out->GetName());
328 TObject* o =
static_cast<TH1*
>(results->FindObject(
"empirical"));
330 Info(
"EmpiricalCorrection",
"Empirical not found in %s",
335 Info(
"EmpiricalCorrection",
"Correcting %s/%s with %s",
336 out->GetName(), h->GetName(), o->GetName());
339 h =
static_cast<TH1*
>(h->Clone(Form(
"%sEmp", h->GetName())));
342 if (o->IsA()->InheritsFrom(TGraphAsymmErrors::Class())) {
344 TAxis* xAxis = h->GetXaxis();
345 for (
Int_t i = 1; i <= xAxis->GetNbins(); i++) {
346 Double_t x = xAxis->GetBinCenter(i);
349 h->SetBinContent(i, y / c);
352 else if (o->IsA()->InheritsFrom(TH1::Class())) {
353 TH1* empCorr =
static_cast<TH1*
>(o);
357 Warning(
"CorrectEmpirical",
358 "Don't know how to apply a %s as an empirical correction",
359 o->IsA()->GetName());
383 DGUARD(fDebug, 1,
"In End of %s with corrEmpty=%d, rootProj=%d",
384 GetName(), corrEmpty, rootProj);
386 trigEff0, rootProj, corrEmpty,
387 triggerMask, marker, color, mclist,
390 TH1* h = EmpiricalCorrection(results);
391 Info(
"End",
"Applied empirical correction: %p (%s)",
392 h, h ? h->GetName() :
"");
394 if (!IsAllBin())
return;
399 TFile*
file = TFile::Open(
"forward.root",
"READ");
402 TList* forward =
static_cast<TList*
>(file->Get(
"ForwardSums"));
404 AliError(
"List Forward not found in forward.root");
407 TList* rings =
static_cast<TList*
>(forward->FindObject(
"ringResults"));
409 AliError(
"List ringResults not found in forward.root");
412 res =
static_cast<THStack*
>(rings->FindObject(
"all"));
414 AliError(Form(
"Stack all not found in %s", rings->GetName()));
419 AliError(
"Triggers histogram not set");
430 AliWarning(Form(
"Using hard-coded NSD trigger efficiency of %f",epsilonT));
433 AliInfo(
"Adding per-ring histograms to output");
436 TIter next(res->GetHists());
438 while ((hist = static_cast<TH1*>(next()))) hist->Scale(scaler);
439 res->SetName(
"dndetaRings");
441 fOutput->Add(
new TNamed(
"normCalc", text.Data()));
virtual void CheckEventData(Double_t vtx, TH2 *data, TH2 *mcData)
#define DMSG(L, N, F,...)
Bool_t LoadEmpirical(const char *path)
virtual void End(TList *sums, TList *results, UShort_t scheme, Double_t trigEff, Double_t trigEff0, Bool_t rootProj, Bool_t corrEmpty, Int_t triggerMask, Int_t marker, Int_t color, TList *mclist, TList *truthlist)
virtual Bool_t Finalize()
Various utilities used in PWGLF/FORWARD.
TH1 * EmpiricalCorrection(TList *results)
#define DGUARD(L, N, F,...)
static TObject * MakeParameter(const char *name, UShort_t value)
TH2D * GetHistogram(const AliAODEvent &aod, Bool_t mc)
AliAODForwardMult * GetForward(const AliAODEvent &aod, Bool_t mc=false, Bool_t verb=true)
AliBasedNdetaTask::CentralityBin * MakeCentralityBin(const char *name, Float_t l, Float_t h) const
virtual void End(TList *sums, TList *results, UShort_t scheme, Double_t trigEff, Double_t trigEff0, Bool_t rootProj, Bool_t corrEmpty, Int_t triggerMask, Int_t marker, Int_t color, TList *mclist, TList *truthlist)
const TH2D & GetHistogram() const