11 # include <TFitResult.h>
34 gSystem->AddIncludePath(Form(
"-I%s", d.Data()));
35 const char* oldPath = gROOT->GetMacroPath();
36 gROOT->SetMacroPath(Form(
".:%s:%s",
37 prepend ? d.Data() : oldPath,
38 prepend ? oldPath : d.Data()));
81 return sMin + TMath::Power(x/xMax, 2)*(sMax-sMin);
86 return SysEval(x, sMin, sMax, 80);
90 return SysEval(x, sMin, sMax, 2);
109 case 0: c1 = 0; c2 = 5;
break;
110 case 1: c1 = 5; c2 = 10;
break;
111 case 2: c1 = 10; c2 = 20;
break;
112 case 3: c1 = 20; c2 = 30;
break;
113 case 4: c1 = 30; c2 = 40;
break;
114 case 5: c1 = 40; c2 = 50;
break;
115 case 6: c1 = 50; c2 = 60;
break;
116 case 7: c1 = 60; c2 = 70;
break;
117 case 8: c1 = 70; c2 = 80;
break;
118 case 9: c1 = 80; c2 = 90;
break;
120 if (!gROOT->GetClass(
"GraphSysErr"))
return 0;
121 TString bnn; bnn.Form(
"%03dd%02d_%03dd%02d",
124 Bool_t mc = g->GetMarkerStyle() == 30;
126 if (mc) nme.Prepend(
"CENTT_");
127 else nme.Prepend(
"CENT_");
129 Color_t col = g->GetMarkerColor();
136 gse->
SetTitle(Form(
"%5.1f - %5.1f%%", c1, c2));
137 gse->
SetKey(
"author",
"PREGHENELLA : 2015");
138 gse->
SetKey(
"title",
"dNch/deta in PbPb at 5023 GeV");
139 gse->
SetKey(
"obskey",
"DN/DETARAP");
140 gse->
SetKey(
"reackey",
"PB PB --> CHARGED X");
141 gse->
SetKey(
"laboratory",
"CERN");
142 gse->
SetKey(
"accelerator",
"LHC");
143 gse->
SetKey(
"detector",
"TRACKLETS");
144 gse->
SetKey(
"reference",
"ALICE-AN-2830");
145 gse->
AddQualifier(
"CENTRALITY IN PCT", Form(
"%.1f TO %.1f",c1,c2));
149 gse->SetMarkerStyle(g->GetMarkerStyle());
150 gse->SetMarkerSize(g->GetMarkerSize());
152 gse->SetMarkerColor(col);
153 gse->SetLineColor(col);
154 gse->SetFillColor(col);
162 MakeCommon(gse,
"Particle composition", 0.01, col);
164 MakeCommon(gse,
"pT extrapolation", 0.02, col);
166 MakeCommon(gse,
"Background subrtaction", bg, col);
170 if (!mc) acc =
MakeP2P(gse,
"Acceptance", col);
173 for (
Int_t i = 1; i <= g->GetNbinsX(); i++) {
174 Double_t eta = g->GetXaxis()->GetBinCenter(i);
175 Double_t eEta = g->GetXaxis()->GetBinWidth(i)/2;
177 if (xo > 2)
continue;
178 Double_t ea = 0.02*TMath::Power(xo/2,2);
179 gse->
SetPoint(j, eta, g->GetBinContent(i));
181 gse->
SetStatError(j, g->GetBinError(i),g->GetBinError(i));
183 gse->
SetSysError(acc, j, eEta, eEta, ea/100, ea/100);
193 TClass* cls=0,
Bool_t verbose=
true)
196 if (verbose) Warning(
"GetHS",
"No directory");
202 if (!par.EqualTo(
".")) {
203 TDirectory* save =
dir;
204 dir = save->GetDirectory(par);
213 if (verbose) Warning(
"GetO",
"%s not found in %s", name, dir->GetName());
217 if (!o->IsA()->InheritsFrom(cls)) {
218 if (verbose) Warning(
"GetO",
"%s is not a %s!", name, cls->GetName());
227 return static_cast<THStack*
>(
GetO(dir,name,THStack::Class(),verbose));
232 return static_cast<TH1*
>(
GetO(dir,name,TH1::Class(),verbose));
237 return static_cast<TH2*
>(
GetO(dir,name,TH2::Class(),verbose));
244 TH1* hs[] = { left, middle, right, 0 };
245 TH1* r =
static_cast<TH1*
>(middle->Clone());
249 if (r->GetMarkerStyle() == 20)
250 r->SetMarkerStyle(29);
252 r->SetMarkerStyle(30);
255 for (
Int_t i = 1; i <= r->GetNbinsX(); i++) {
256 Double_t aeta = TMath::Abs(r->GetXaxis()->GetBinCenter(i));
257 Double_t weta = r->GetXaxis()->GetBinWidth (i);
258 if (cutAtTwo && (aeta + weta/2) > 2)
continue;
269 if (c < 1e-6)
continue;
275 if (n <= 0)
continue;
276 r->SetBinContent(i, sum/n);
277 r->SetBinError (i, TMath::Sqrt(sumw));
285 TH2* hs[] = { left, middle, right, 0 };
286 TH2* r =
static_cast<TH2*
>(middle->Clone());
289 if (r->GetMarkerStyle() == 20)
290 r->SetMarkerStyle(29);
292 r->SetMarkerStyle(30);
295 for (
Int_t i = 1; i <= r->GetNbinsX(); i++) {
296 Double_t aeta = TMath::Abs(r->GetXaxis()->GetBinCenter(i));
297 Double_t weta = r->GetXaxis()->GetBinWidth (i);
298 if ((aeta + weta/2) > 2)
continue;
299 for (
Int_t j = 1; j <= r->GetNbinsY(); j++) {
310 if (c < 1e-6)
continue;
316 if (n <= 0)
continue;
317 r->SetBinContent(i, sum/n);
318 r->SetBinError (i, TMath::Sqrt(sumw));
331 Int_t nyLeft = sleft ->GetYaxis()->GetNbins();
332 Int_t nyMiddle = smiddle->GetYaxis()->GetNbins();
333 Int_t nyRight = sright ->GetYaxis()->GetNbins();
334 TH2* maps[] = { sleft, smiddle, sright };
335 TArrayD bins(nyLeft+nyMiddle+nyRight+1);
336 bins[0] = sleft->GetYaxis()->GetXmin();
338 for (
Int_t k = 0; k < 3; k++) {
340 for (
Int_t i = 1; i <= tmp->GetYaxis()->GetNbins(); i++, j++)
341 bins[j] = tmp->GetYaxis()->GetBinUpEdge(i);
344 TH2* ret =
new TH2D(smiddle->GetName(), smiddle->GetTitle(),
345 smiddle->GetXaxis()->GetNbins(),
346 smiddle->GetXaxis()->GetXmin(),
347 smiddle->GetXaxis()->GetXmax(),
348 nyLeft+nyMiddle+nyRight, bins.GetArray());
349 ret->SetXTitle(smiddle->GetXaxis()->GetTitle());
350 ret->SetYTitle(smiddle->GetYaxis()->GetTitle());
351 ret->SetZTitle(smiddle->GetZaxis()->GetTitle());
352 ret->SetDirectory(out);
353 static_cast<TAttAxis*
>(smiddle->GetXaxis())->Copy(*ret->GetXaxis());
354 static_cast<TAttAxis*
>(smiddle->GetYaxis())->Copy(*ret->GetYaxis());
355 static_cast<TAttAxis*
>(smiddle->GetZaxis())->Copy(*ret->GetZaxis());
358 for (
Int_t k = 0; k < 3; k++) {
360 for (
Int_t i = 1; i <= tmp->GetXaxis()->GetNbins(); i++) {
361 for (
Int_t j = 1; j <= tmp->GetYaxis()->GetNbins(); j++) {
362 ret->SetBinContent(i,base+j,tmp->GetBinContent(i,j));
363 ret->SetBinError (i,base+j,tmp->GetBinError (i,j));
366 base += tmp->GetYaxis()->GetNbins();
389 TIter imiddle(smiddle->GetHists());
395 TH1* mid = cent ?
static_cast<TH1*
>(cent->Clone(
"mid")) : 0;
398 mid->SetDirectory(out);
399 mid->SetXTitle(
"#eta");
400 mid->SetYTitle(
"d#it{N}_{ch}/d#it{#eta}|_{|#it{#eta}|<0.5}");
401 mid->SetTitle(
"Mid-rapidity");
404 while ((hleft = static_cast<TH1*>(ileft ())) &&
405 (hmiddle = static_cast<TH1*>(imiddle())) &&
406 (hright = static_cast<TH1*>(iright ()))) {
407 TH1* h =
Combine(hleft, hmiddle, hright, out, cutAtTwo);
408 if (mid && !
TString(h->GetName()).Contains(
"truth")) {
409 TF1* f =
new TF1(Form(
"f%s", h->GetName()),
"pol0", -.5, +.5);
410 TFitResultPtr s = h->Fit(f,
"QS+",
"", -.5, +.5);
412 mid->SetBinContent(bin, s->Parameter(0));
413 mid->SetBinError (bin, s->ParError (0));
414 Printf(
"dNch/deta %20s: %6.1f +/- %6.1f (%5.2f)",
415 h->GetName(), s->Parameter(0), s->ParError(0), s->Chi2()/s->Ndf());
417 if (result) result->Add(h);
420 if (h->GetMarkerStyle() == 29) cnt++;
430 const char*
fwd =
"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2";
435 if (!gROOT->GetClass(
"GraphSysErr")) gROOT->LoadMacro(
"GraphSysErr.C+g");
438 TFile* fleft = TFile::Open(Form(
"partial/left_%s_0x%x.root", var,which),
440 TFile* fmiddle = TFile::Open(Form(
"partial/middle_%s_0x%x.root",var,which),
442 TFile* fright = TFile::Open(Form(
"partial/right_%s_0x%x.root", var,which),
446 THStack* sleft =
GetHS(fleft);
447 THStack* smiddle =
GetHS(fmiddle);
448 THStack* sright =
GetHS(fright);
451 TFile* out = TFile::Open(Form(
"results/combine_%s_0x%x.root", var, which),
453 const char*
obs =
"\\mathrm{d}N_{\\mathrm{ch}}/\\mathrm{d}\\eta";
455 THStack* result =
new THStack(
"result",
456 Form(
"%s\\hbox{ %s %s}",
457 obs, which == 0x3 ?
"combinatorics" :
459 Combine(sleft, smiddle, sright, result, out, gses, cent);
464 for (
Int_t i = 1; i <= cent->GetNbinsX(); i++) {
466 Double_t c1 = cent->GetXaxis()->GetBinLowEdge(i);
467 Double_t c2 = cent->GetXaxis()->GetBinUpEdge (i);
468 name.Form(
"cent%03dd%02d_%03dd%02d",
470 TString sname(name); sname.Append(
"/summary");
471 sleft =
GetHS(fleft, sname);
472 smiddle =
GetHS(fmiddle,sname);
473 sright =
GetHS(fright, sname);
474 if (!sleft || !smiddle || !sright)
continue;
475 TDirectory*
dir = out->mkdir(name);
477 THStack* summary =
new THStack(
"summary",
"");
478 Combine(sleft,smiddle,sright,summary, 0, 0);
482 TDirectory* det = dir->mkdir(
"details");
483 const char* maps[] = {
"realMeas",
"realBg",
"realSig",
484 "simMeas",
"simBg",
"simSig",
485 "trueGen",
"alpha",
"fiducial", 0 };
486 const char** pmap = maps;
488 sname.Form(
"%s/details/%s", name.Data(), *pmap);
490 TH2* mmiddle =
GetH2(fmiddle,sname);
492 if (!mleft || !mmiddle || !mright)
continue;
496 sname.Form(
"%s/details/scalar", name.Data());
497 TH1* hleft =
GetH1(fleft, sname,
false);
498 TH1* hmiddle =
GetH1(fmiddle,sname,
false);
499 TH1* hright =
GetH1(fright, sname,
false);
500 if (hleft && hmiddle && hright) {
501 TH1* kHist =
Combine(hleft, hmiddle, hright, det);
507 sname.Form(
"%s/details/deltas", name.Data());
508 sleft =
GetHS(fleft, sname);
509 smiddle =
GetHS(fmiddle,sname);
510 sright =
GetHS(fright, sname);
511 if (!sleft || !smiddle || !sright)
continue;
512 THStack* deltas =
new THStack(
"deltas",
"");
513 Combine(sleft,smiddle,sright,deltas, 0, 0, 0,
false);
517 TDirectory* avg = dir->mkdir(
"averages");
519 const char* avgs[] = {
"realAvgMeas",
"realAvgBg",
"realAvgSig",
520 "simAvgMeas",
"simAvgBg",
"simAvgSig",
522 const char** pavg = avgs;
524 sname.Form(
"%s/averages/%s", name.Data(), *pavg);
525 hleft =
GetH1(fleft, sname);
526 hmiddle =
GetH1(fmiddle,sname);
527 hright =
GetH1(fright, sname);
528 if (!hleft || !hmiddle || !hright)
continue;
529 TH1* avgH =
Combine(hleft, hmiddle, hright, avg);
537 TCanvas*
c =
new TCanvas(
"c",
"c",
cW,
cH);
538 c->SetTopMargin(0.01);
539 c->SetRightMargin(0.01);
540 result->Draw(
"nostack");
541 result->GetHistogram()->GetYaxis()->SetTitleOffset(1.5);
542 result->GetHistogram()->SetYTitle(obs);
543 result->GetHistogram()->SetXTitle(
"\\eta");
544 c->Print(Form(
"plots/combine_%s_0x%x.png", var, which));
548 gses->SetName(
"container");
549 gses->Draw(
"quad combine stat xbase=2.2");
550 gses->Write(gses->GetName(), TObject::kSingleKey);
552 Printf(
"Output stored in %s", out->GetName());
void SetSysLineColor(Int_t id, Color_t color)
void SetYTitle(const char *title)
void SetKey(const char *key, const char *value, Bool_t replace=false)
TH1 * GetH1(TDirectory *dir, const char *name="result", Bool_t verbose=true)
void SetPointError(Int_t i, Double_t ex)
void SetSysError(Int_t id, Double_t eyl, Double_t eyh)
TH2 * GetH2(TDirectory *dir, const char *name="result", Bool_t verbose=true)
void AddPath(const TString &dir, Bool_t prepend=true)
void SetCommonSumLineColor(Color_t color)
void AddQualifier(const TString &key, const TString &value, Bool_t replace=false)
void SetCommonSumOption(EDrawOption_t opt)
const Bool_t kCombineLoaded
Double_t EtaSysEval(Double_t x, Double_t sMin, Double_t sMax)
void SetStatError(Int_t i, Double_t ey)
Double_t SysEval(Double_t x, Double_t sMin, Double_t sMax, Double_t xMax)
void SetPoint(Int_t i, Double_t x, Double_t y)
void SetTitle(const char *name)
UInt_t DefineCommon(const char *title, Bool_t relative, Double_t ey, EDrawOption_t option=kFill)
UInt_t DeclarePoint2Point(const char *title, Bool_t relative, EDrawOption_t option=kBar)
void SetDataOption(EDrawOption_t opt)
void SetSysFillColor(Int_t id, Color_t color)
An (X,Y) graph with configurable errors.
TH1 * Combine(TH1 *left, TH1 *middle, TH1 *right, TDirectory *out, Bool_t cutAtTwo=true)
Double_t CSysEval(Double_t x, Double_t sMin, Double_t sMax)
void SetSumOption(EDrawOption_t opt)
Int_t MakeP2P(TObject *o, const char *name, Color_t c)
TObject * MakeGSE(TH1 *g, Int_t bin)
void CombineMap(TH2 *sleft, TH2 *smiddle, TH2 *sright, TDirectory *out)
TObject * GetO(TDirectory *dir, const char *name="result", TClass *cls=0, Bool_t verbose=true)
void SetSumFillColor(Color_t color)
TList * GetHists(UShort_t flags, const char *var, const char *stackName="result", const char *sub="")
void SetSumLineColor(Color_t color)
void SetXTitle(const char *title)
void SetCommonSumFillColor(Color_t color)
void MakeCommon(TObject *o, const char *name, Double_t val, Color_t c)
THStack * GetHS(TDirectory *dir, const char *name="result", Bool_t verbose=true)