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 [%d,%d]",
91 if (!forward)
return 0;
103 if (aVtx < 37.5 || aVtx > 400)
return;
105 TH2* hists[] = { data, dataMC };
117 for (
Int_t iX = 0; iX<=data->GetNbinsX(); iX++) {
120 Double_t x = data->GetXaxis()->GetBinCenter(iX);
122 if (((vtx > 60 && vtx < 90) && x < 3) ||
123 ((vtx > 330 && vtx < 350) && x > -2.5) ||
124 ((vtx < 100 || vtx > 305) && TMath::Abs(x) < 4.5) ||
125 (vtx < 50 && TMath::Abs(x) < 4.75))
129 for (
Int_t iH = 0; iH < 2; iH++) {
130 if (!hists[iH])
continue;
133 for (
Int_t iY = 0; iY<=hists[iH]->GetNbinsY()+1; iY++) {
134 hists[iH]->SetBinContent(iX, iY, 0);
135 hists[iH]->SetBinError(iX, iY, 0);
154 const Int_t phiBin1 = 17;
155 const Int_t phiBin2 = 18;
156 for (
Int_t iH = 0; iH < 2; iH++) {
157 if (!hists[iH])
continue;
159 Int_t midX = hists[iH]->GetNbinsX() / 2;
161 for (
Int_t i = 1; i <= midX; i++) {
162 hists[iH]->SetBinContent(i, phiBin1, 0);
163 hists[iH]->SetBinContent(i, phiBin2, 0);
164 hists[iH]->SetBinError(i, phiBin1, 0);
165 hists[iH]->SetBinError(i, phiBin2, 0);
187 if (
gSystem->ExpandPathName(path)) {
191 if (!path.Contains(
"empirical"))
192 path =
gSystem->ConcatFileName(path.Data(),
"empirical.root");
194 if (!empUrl.GetAnchor() || empUrl.GetAnchor()[0] ==
'\0')
195 empUrl.SetAnchor(
"default");
196 TFile* empFile = TFile::Open(empUrl.GetUrl());
197 if (!empFile)
return false;
199 TString base(GetName()); base.ReplaceAll(
"dNdeta",
"");
200 TString empAnch = empUrl.GetAnchor();
201 TObject* empObj = empFile->Get(Form(
"%s/%s",base.Data(),empAnch.Data()));
203 (empObj->IsA()->InheritsFrom(TH1::Class()) ||
204 empObj->IsA()->InheritsFrom(TGraphAsymmErrors::Class())))) {
205 Warning(
"LoadEmpirical",
"Didn't get Forward/%s from %s",
206 empAnch.Data(), empUrl.GetUrl());
210 static_cast<TNamed*
>(empObj)->SetName(
"empirical");
213 if (!empObj->IsA()->InheritsFrom(TH1::Class()))
217 TH1* h =
static_cast<TH1*
>(empObj);
221 TH1* xy =
static_cast<TH2*
>(
fSums->FindObject(
"vertexAccXY"));
230 Info(
"LoadEmpirical",
"Shifts (%f-%f)=%f, (%f-%f)=%f",
233 if (TMath::Abs(dx) > 1e-3 || TMath::Abs(dy) > 1e-3)
234 delta = TMath::Sqrt(dx*dx+dy*dy);
240 TF1* f =
new TF1(
"deltaCorr",
"1+[2]*([0]+(x<[1])*pow([0]*(x-[1]),2))");
241 f->SetParNames(
"\\delta",
"\\eta_{0}",
"a");
242 f->SetParameter(0,delta);
243 f->SetParameter(1,-2.0);
244 f->SetParameter(2,.10);
245 Info(
"LoadEmpirical",
"Appying correction for IP delta=%f", delta);
246 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
248 if (c < 1e-6)
continue;
251 Double_t eta = h->GetXaxis()->GetBinCenter(i);
254 h->SetBinContent(i, c*cor);
255 h->SetBinError(i, e*cor);
269 TString oadb(
gSystem->ConcatFileName(AliAnalysisManager::GetOADBPath(),
270 "PWGLF/FORWARD/CORRECTIONS/data"));
271 const char* dirs[] = {
275 "${OADB_PATH}/PWGLF/FORWARD/EMPIRICAL",
276 "${ALICE_PHYSICS}/OADB/PWGLF/FORWARD/EMPIRICAL",
279 const char** pdir = dirs;
282 const char* fns[] = {
"",
"empirical_000138190.root", 0 };
283 const char** pfn = fns;
301 TString base(GetName()); base.ReplaceAll(
"dNdeta",
"");
302 TString hName(Form(
"dndeta%s",base.Data()));
303 TH1* h =
static_cast<TH1*
>(out->FindObject(hName));
305 Warning(
"End",
"%s not found in %s",
306 hName.Data(), out->GetName());
311 TObject* o =
static_cast<TH1*
>(results->FindObject(
"empirical"));
313 Info(
"EmpiricalCorrection",
"Empirical not found in %s",
318 Info(
"EmpiricalCorrection",
"Correcting %s/%s with %s",
319 out->GetName(), h->GetName(), o->GetName());
322 h =
static_cast<TH1*
>(h->Clone(Form(
"%sEmp", h->GetName())));
325 if (o->IsA()->InheritsFrom(TGraphAsymmErrors::Class())) {
327 TAxis* xAxis = h->GetXaxis();
328 for (
Int_t i = 1; i <= xAxis->GetNbins(); i++) {
329 Double_t x = xAxis->GetBinCenter(i);
332 h->SetBinContent(i, y / c);
335 else if (o->IsA()->InheritsFrom(TH1::Class())) {
336 TH1* empCorr =
static_cast<TH1*
>(o);
340 Warning(
"CorrectEmpirical",
341 "Don't know how to apply a %s as an empirical correction",
342 o->IsA()->GetName());
366 DGUARD(fDebug, 1,
"In End of %s with corrEmpty=%d, rootProj=%d",
367 GetName(), corrEmpty, rootProj);
369 trigEff0, rootProj, corrEmpty,
370 triggerMask, marker, color, mclist,
375 if (!IsAllBin())
return;
376 TFile*
file = TFile::Open(
"forward.root",
"READ");
379 TList* forward =
static_cast<TList*
>(file->Get(
"ForwardSums"));
381 AliError(
"List Forward not found in forward.root");
384 TList* rings =
static_cast<TList*
>(forward->FindObject(
"ringResults"));
386 AliError(
"List ringResults not found in forward.root");
389 THStack* res =
static_cast<THStack*
>(rings->FindObject(
"all"));
391 AliError(Form(
"Stack all not found in %s", rings->GetName()));
395 AliError(
"Triggers histogram not set");
406 AliWarning(Form(
"Using hard-coded NSD trigger efficiency of %f",epsilonT));
409 AliInfo(
"Adding per-ring histograms to output");
412 TIter next(res->GetHists());
414 while ((hist = static_cast<TH1*>(next()))) hist->Scale(scaler);
415 res->SetName(
"dndetaRings");
417 fOutput->Add(
new TNamed(
"normCalc", text.Data()));
virtual void CheckEventData(Double_t vtx, TH2 *data, TH2 *mcData)
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