5 #include <TCollection.h>
10 #include <TGraphAsymmErrors.h>
11 #include <TGraphErrors.h>
13 #include <TMultiGraph.h>
39 TFile*
file = TFile::Open(fname, rw ?
"RECREATE" :
"READ");
41 ::Error(
"OpenFile",
"Couldn't open %s for %s",
42 fname.Data(), (rw ?
"read/write" :
"read"));
59 if (!quiet) ::Error(
"CheckType",
"No object and/or class given");
62 if (!o->IsA()->InheritsFrom(cl)) {
63 if (!quiet) ::Error(
"CheckType",
"Object %s is not a %s, but a %s",
64 o->GetName(), cl->GetName(), o->ClassName());
80 TClass* cl=0,
Bool_t quiet=
false)
83 if (!quiet) ::Error(
"GetObject",
"No parent directory");
86 TObject* o = d->Get(name.Data());
88 if (!quiet) ::Error(
"GetObject",
"didn't find the object %s in %s",
89 name.Data(), d->GetName());
93 if (cl && !
CheckType(o, cl, quiet))
return 0;
108 TClass* cl=0,
Bool_t quiet=
false)
111 if (!quiet) ::Error(
"GetObject",
"No parent directory");
114 TObject* o = d->FindObject(name.Data());
116 if (!quiet) ::Error(
"GetObject",
"didn't find the object %s in %s",
117 name.Data(), d->GetName());
121 if (cl && !
CheckType(o, cl, quiet))
return 0;
166 return static_cast<TH1*
>(
GetObject(d, name, TH1::Class(), quiet));
179 return static_cast<TH1*
>(
GetObject(d, name, TH1::Class(), quiet));
192 return static_cast<TGraph*
>(
GetObject(d, name, TGraph::Class(), quiet));
206 return static_cast<TAxis*
>(
GetObject(d, name, TAxis::Class(), quiet));
219 if (!h || !g)
return 0;
221 TH1* ret =
static_cast<TH1*
>(h->Clone(
"tmp"));
223 ret->SetDirectory(0);
225 Double_t xhigh = g->GetX()[g->GetN()-1];
226 if (xlow > xhigh) {
Double_t t = xhigh; xhigh = xlow; xlow = t; }
228 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
230 if (c <= 0)
continue;
233 if (x < xlow || x > xhigh)
continue;
236 if (f <= 0)
continue;
238 ret->SetBinContent(i, c / f);
239 ret->SetBinError(i, h->GetBinError(i) / f);
259 TString savPath(gROOT->GetMacroPath());
260 gROOT->SetMacroPath(Form(
"%s:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2",
261 gROOT->GetMacroPath()));
263 if (!gROOT->GetClass(
"RefData"))
264 gROOT->LoadMacro(
"OtherData.C+");
265 gROOT->SetMacroPath(savPath);
284 TMultiGraph* other = 0;
289 gROOT->ProcessLine(Form(
"RefData::GetData(%d,%d,%d,%d,%d,%d);",
290 sys,snn,trg,c1,c2,0xF));
292 Warning(
"GetReference",
293 "No other data for sys=%d trg=%d sNN=%d c=%3d%%-%3d%%",
294 sys, trg, snn, c1, c2);
298 other =
reinterpret_cast<TMultiGraph*
>(ret);
312 TFile* out =
OpenFile(
"empirical.root",
true);
331 TDirectory* store = out->mkdir(name);
334 TString resName(Form(
"%sdNdetaResults", name.Data()));
336 if (!results)
return;
339 if (!centAxis)
return;
341 THStack* corrs =
new THStack(
"empirical",
"Empirical correction");
343 corrs->SetTitle(Form(
"Empirical corrections for %s", name.Data()));
344 for (
Int_t i=1; i<=centAxis->GetNbins(); i++) {
351 if (!corrs->GetHists() ||
352 corrs->GetHists()->GetEntries() <= 0)
return;
356 TH1* sum =
static_cast<TH1*
>(corrs->GetHists()->At(0)->Clone(
"mean"));
357 sum->SetTitle(
"mean");
359 sum->SetMarkerColor(kBlack);
360 sum->SetDirectory(0);
361 Int_t nHist = corrs->GetHists()->GetEntries();
362 for (
Int_t i = 0; i < nHist; i++)
363 sum->Add(static_cast<TH1*>(corrs->GetHists()->At(i)));
364 sum->Scale(1. / nHist);
365 sum->Write(
"default");
367 THStack* ratios =
new THStack(
"ratios",
"Ratio to mean");
368 for (
Int_t i = 0; i < nHist; i++) {
369 TH1* h =
static_cast<TH1*
>(corrs->GetHists()->At(i));
370 TH1* r =
static_cast<TH1*
>(h->Clone());
377 TCanvas*
c =
new TCanvas(name);
378 c->SetRightMargin(0.05);
379 c->SetTopMargin(0.05);
381 TVirtualPad* p = c->cd(1);
383 corrs->DrawClone(
"nostack");
384 p->BuildLegend(0.2, 0.05, 0.4, 0.4);
388 THStack* cpy =
static_cast<THStack*
>(ratios->DrawClone(
"nostack"));
389 cpy->SetMinimum(0.95);
390 cpy->SetMaximum(1.05);
391 p->BuildLegend(0.35,0.15,0.55,0.4);
394 c->Print(Form(
"%sEmpirical.pdf", name.Data()));
407 const TString& name, THStack* s, TDirectory* d)
414 Form(
"alice_pbpb2760"));
417 TString folderName(Form(
"cent%03d_%03d", c1, c2));
419 if (!centBin)
return;
421 TH1*
ana =
GetH1(centBin, Form(
"dndeta%s", name.Data()));
427 ::Info(
"",
"Adding %s/%s", name.Data(), folderName.Data());
428 ratio->SetName(folderName);
429 ratio->SetTitle(Form(
"%3d%% - %3d%%", c1, c2));
433 TDirectory* store = d->mkdir(folderName);
void ana(Int_t mode=mGRID)
static TH1 * RatioHG(const TH1 *h, const TGraph *g)
static Bool_t CheckType(TObject *o, TClass *cl, Bool_t quiet=false)
void Run(const TString &fileName)
static TAxis * GetAxis(TCollection *d, const TString &name, Bool_t quiet=false)
void GenerateEmpirical(const Char_t *fileName="PbPb_2760_dndeta_nosec_CENT_20140513_1349/forward_dndeta.root")
TMultiGraph * GetReference(UShort_t c1, UShort_t c2)
static TH1 * GetH1(TDirectory *d, const TString &name, Bool_t quiet=false)
static TObject * GetObject(TCollection *d, const TString &name, TClass *cl=0, Bool_t quiet=false)
static TFile * OpenFile(const TString &fname, Bool_t rw=false)
void ProcessComponent(TDirectory *d, TDirectory *out, const TString &name)
void ProcessCent(UShort_t c1, UShort_t c2, TCollection *c, const TString &name, THStack *s, TDirectory *d)
static TCollection * GetCollection(TDirectory *d, const TString &name, Bool_t quiet=false)
static TObject * GetObject(TDirectory *d, const TString &name, TClass *cl=0, Bool_t quiet=false)
static TH1 * GetH1(TCollection *d, const TString &name, Bool_t quiet=false)
static TGraph * GetGraph(TCollection *d, const TString &name, Bool_t quiet=false)
static TCollection * GetCollection(TCollection *d, const TString &name, Bool_t quiet=false)