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);
199 if (
gSystem->ExpandPathName(path)) {
203 if (!path.Contains(
"empirical"))
204 path =
gSystem->ConcatFileName(path.Data(),
"empirical.root");
206 if (!empUrl.GetAnchor() || empUrl.GetAnchor()[0] ==
'\0')
207 empUrl.SetAnchor(
"default");
208 empFile = TFile::Open(empUrl.GetUrl());
210 DMSG(fDebug,1,
"%s not found", empUrl.GetUrl());
214 DMSG(fDebug,0,
"Got empirical file %s", empUrl.GetUrl());
216 TString base(GetName()); base.ReplaceAll(
"dNdeta",
"");
217 TString empAnch = empUrl.GetAnchor();
218 TObject* empObj = empFile->Get(Form(
"%s/%s",base.Data(),empAnch.Data()));
220 (empObj->IsA()->InheritsFrom(TH1::Class()) ||
221 empObj->IsA()->InheritsFrom(TF1::Class()) ||
222 empObj->IsA()->InheritsFrom(TGraphAsymmErrors::Class())))) {
223 Warning(
"LoadEmpirical",
"Didn't get Forward/%s from %s",
224 empAnch.Data(), empUrl.GetUrl());
227 DMSG(fDebug,0,
"Got empirical correction %s [%s]", empObj->GetName(),
228 empObj->ClassName());
230 static_cast<TNamed*
>(empObj)->SetName(
"empirical");
233 if (!empObj->IsA()->InheritsFrom(TH1::Class()))
237 TH1* h =
static_cast<TH1*
>(empObj);
241 TH1* xy =
static_cast<TH2*
>(
fSums->FindObject(
"vertexAccXY"));
250 Info(
"LoadEmpirical",
"Shifts (%f-%f)=%f, (%f-%f)=%f",
253 if (TMath::Abs(dx) > 1e-3 || TMath::Abs(dy) > 1e-3)
254 delta = TMath::Sqrt(dx*dx+dy*dy);
260 TF1* f =
new TF1(
"deltaCorr",
"1+[2]*([0]+(x<[1])*pow([0]*(x-[1]),2))");
261 f->SetParNames(
"\\delta",
"\\eta_{0}",
"a");
262 f->SetParameter(0,delta);
263 f->SetParameter(1,-2.0);
264 f->SetParameter(2,.10);
265 Info(
"LoadEmpirical",
"Appying correction for IP delta=%f", delta);
266 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
268 if (c < 1e-6)
continue;
271 Double_t eta = h->GetXaxis()->GetBinCenter(i);
274 h->SetBinContent(i, c*cor);
275 h->SetBinError(i, e*cor);
289 TString oadb(
gSystem->ConcatFileName(AliAnalysisManager::GetOADBPath(),
290 "PWGLF/FORWARD/CORRECTIONS/data"));
291 const char* dirs[] = {
295 "${OADB_PATH}/PWGLF/FORWARD/EMPIRICAL",
296 "${ALICE_PHYSICS}/OADB/PWGLF/FORWARD/EMPIRICAL",
299 const char** pdir = dirs;
302 const char* fns[] = {
"",
"empirical_000138190.root", 0 };
303 const char** pfn = fns;
304 const char*
dir = *pdir;
310 const char* ancs[] = {
"param",
"default", 0 };
311 const char** pan = ancs;
313 const char* anch = *pan;
315 TString u(path); u.Append(
"#"); u.Append(anch);
329 TList* out = fOutput;
331 TString base(GetName()); base.ReplaceAll(
"dNdeta",
"");
332 TString hName(Form(
"dndeta%s",base.Data()));
333 TH1* h =
static_cast<TH1*
>(out->FindObject(hName));
335 Warning(
"End",
"%s not found in %s",
336 hName.Data(), out->GetName());
341 TObject* o =
static_cast<TH1*
>(results->FindObject(
"empirical"));
343 Info(
"EmpiricalCorrection",
"Empirical not found in %s",
348 Info(
"EmpiricalCorrection",
"Correcting %s/%s with %s [%s]",
349 out->GetName(), h->GetName(), o->GetName(), o->ClassName());
352 h =
static_cast<TH1*
>(h->Clone(Form(
"%sEmp", h->GetName())));
355 if (o->IsA()->InheritsFrom(TGraphAsymmErrors::Class())) {
357 TAxis* xAxis = h->GetXaxis();
358 for (
Int_t i = 1; i <= xAxis->GetNbins(); i++) {
359 Double_t x = xAxis->GetBinCenter(i);
362 h->SetBinContent(i, y / c);
365 else if (o->IsA()->InheritsFrom(TF1::Class())) {
366 TF1* empCorr =
static_cast<TF1*
>(o);
369 else if (o->IsA()->InheritsFrom(TH1::Class())) {
370 TH1* empCorr =
static_cast<TH1*
>(o);
374 Warning(
"CorrectEmpirical",
375 "Don't know how to apply a %s as an empirical correction",
376 o->IsA()->GetName());
400 DGUARD(fDebug, 1,
"In End of %s with corrEmpty=%d, rootProj=%d",
401 GetName(), corrEmpty, rootProj);
403 trigEff0, rootProj, corrEmpty,
405 marker, color, mclist,
409 TH1* h = EmpiricalCorrection(results);
410 Info(
"End",
"Applied empirical correction: %p (%s)",
411 h, h ? h->GetName() :
"");
413 if (!IsAllBin())
return true;
417 if (
gSystem->AccessPathName(
"forward.root"))
return true;
419 TFile*
file = TFile::Open(
"forward.root",
"READ");
420 if (!file)
return false;
422 TList* forward =
static_cast<TList*
>(file->Get(
"ForwardSums"));
424 AliError(
"List Forward not found in forward.root");
427 TList* rings =
static_cast<TList*
>(forward->FindObject(
"ringResults"));
429 AliError(
"List ringResults not found in forward.root");
432 res =
static_cast<THStack*
>(rings->FindObject(
"all"));
434 AliError(Form(
"Stack all not found in %s", rings->GetName()));
439 AliError(
"Triggers histogram not set");
450 AliWarning(Form(
"Using hard-coded NSD trigger efficiency of %f",epsilonT));
453 AliInfo(
"Adding per-ring histograms to output");
456 TIter next(res->GetHists());
458 while ((hist = static_cast<TH1*>(next()))) hist->Scale(scaler);
459 res->SetName(
"dndetaRings");
461 fOutput->Add(
new TNamed(
"normCalc", text.Data()));
Int_t color[]
print message on plot with ok/not ok
virtual void CheckEventData(Double_t vtx, TH2 *data, TH2 *mcData)
#define DMSG(L, N, F,...)
Bool_t LoadEmpirical(const char *path)
virtual bool 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)
TLatex * text[5]
option to what and if export to output file
virtual Bool_t Finalize()
Various utilities used in PWGLF/FORWARD.
TH1 * EmpiricalCorrection(TList *results)
#define DGUARD(L, N, F,...)
virtual bool 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)
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
TFile * file
TList with histograms for a given trigger.
const TH2D & GetHistogram() const