2 #include <TCollection.h>
13 #include <TLegendEntry.h>
15 #include <TParameter.h>
17 #include <TGraphAsymmErrors.h>
26 Error(
"GetOject",
"No directory");
33 Error(
"GetObject",
"No object %s in directory %s", name, d->GetName());
39 if (!o->IsA()->InheritsFrom(cls)) {
41 Error(
"GetObject",
"%s from %s is not a %s, but a %s",
42 o->GetName(), d->GetName(), cls->GetName(), o->ClassName());
54 Error(
"GetOject",
"No collection");
58 TObject* o = d->FindObject(name);
61 Error(
"GetObject",
"No object %s in collection %s", name, d->GetName());
67 if (!o->IsA()->InheritsFrom(cls)) {
69 Error(
"GetObject",
"%s from %s is not a %s, but a %s",
70 o->GetName(), d->GetName(), cls->GetName(), o->ClassName());
92 return static_cast<TH2*
>(
GetObject(c, name, TH2::Class()));
98 return static_cast<TH1*
>(
GetObject(c, name, TH1::Class()));
104 return static_cast<THStack*
>(
GetObject(c, name, THStack::Class(),verb));
127 TFile*
file = TFile::Open(Form(
"PbPb_2760_dndeta_%s_nosec_20140512_1628/"
128 "forward_dndeta.root", meth),
"READ");
132 centAxis =
static_cast<TAxis*
>(
GetObject(res,
"centAxis", TAxis::Class()));
133 Info(
"ProcessOne",
"Got centrality axis %p", centAxis);
137 Info(
"ProcessOne",
"Doing stuff for %s (%sfirst)",
138 meth, (first ?
"" :
"not "));
139 for (
Int_t i = 1; i <= centAxis->GetNbins(); i++) {
140 Double_t c1 = centAxis->GetBinLowEdge(i);
141 Double_t c2 = centAxis->GetBinUpEdge(i);
142 if (meth[0] ==
'Z' && c1 > 30)
break;
144 TString binName(Form(
"cent%03dd%02d_%03dd%02d",
150 TH1* here =
GetH1(bin,
"dndetaForward");
154 THStack* ratio =
GetStack(ratios, binName,
false);
159 Info(
"ProcessOne",
"Creating stacks %s", binName.Data());
160 stack =
new THStack(binName, Form(
"%3d-%3d%%",
Int_t(c1),
Int_t(c2)));
161 stack->SetUniqueID(here->GetMarkerColor());
162 stacks->AddAt(stack, i-1);
163 ratio =
static_cast<THStack*
>(stack->Clone());
164 ratios->AddAt(ratio, i-1);
168 mins->AddAt(pmin, i-1);
169 maxs->AddAt(pmax, i-1);
170 avgs->AddAt(pavg, i-1);
172 here->SetTitle(meth);
173 here->SetMarkerStyle(style);
179 TH1* denom =
static_cast<TH1*
>(stack->GetHists()->At(0));
180 TH1* num =
static_cast<TH1*
>(here->Clone(Form(
"%s/%s",
181 meth, denom->GetName())));
182 num->SetDirectory(0);
189 for (
Int_t j = 1; j <= num->GetNbinsX(); j++) {
191 if (c < 1e-6)
continue;
192 min = TMath::Min(c, min);
193 max = TMath::Max(c, max);
194 sum += TMath::Abs(1-c);
196 num->SetBinContent(j, c+(centAxis->GetNbins()-i));
202 pavg->SetVal(TMath::Max(pavg->GetVal(), sum));
204 Printf(
"Method %10s %16s: min=%7.5f max=%7.5f avg=%7.5f",
205 meth,stack->GetTitle(), min, max, sum);
214 const char* dndeta =
"1/#it{N} d#it{N}_{ch}/d#it{#eta}";
223 const char* meths[] = {
"V0M",
"CL1",
"TRK", (zem ?
"ZEMVSZDC" : 0), 0 };
224 Int_t styles[] = { 20, 21, 22, 23, 0 };
226 const char** pmeth = meths;
227 Int_t* pstyle = styles;
229 TCanvas*
c =
new TCanvas(
"c",
"C", 1200, 800);
230 c->SetTopMargin(0.01);
231 c->SetRightMargin(0.01);
233 c->GetPad(1)->SetRightMargin(0.01);
234 c->GetPad(2)->SetRightMargin(0.01);
235 gStyle->SetOptTitle(0);
237 TLegend* mleg =
new TLegend(0.35, (meths[3] ? 0.05 : 0.3), 0.65, 0.95);
238 mleg->SetFillStyle(0);
239 mleg->SetBorderSize(0);
240 mleg->SetTextFont(42);
241 TLegend* leg =
new TLegend(0.35, 0.15, 0.55, 0.95);
242 leg->SetFillStyle(0);
243 leg->SetBorderSize(0);
244 leg->SetTextFont(42);
249 ProcessOne(*pmeth, *pstyle, stacks, ratios, mins, maxs, avgs, centAxis);
250 TLegendEntry* e = mleg->AddEntry(
"", *pmeth,
"p");
251 e->SetMarkerStyle(*pstyle);
252 all.Append(Form(
"_%s", *pmeth));
259 trend->SetMarkerStyle(20);
260 trend->SetFillColor(kBlue-9);
261 trend->SetFillStyle(3001);
262 trend->SetMarkerColor(kBlue-7);
263 trend->SetLineColor(kBlue-9);
278 while ((stack = static_cast<THStack*>(nextS())) &&
279 (ratio = static_cast<THStack*>(nextR())) &&
285 stack->Draw(first ?
"nostack" :
"nostack same");
287 Int_t y = centAxis->GetNbins()-cnt++;
288 UInt_t col = stack->GetUniqueID();
289 TLegendEntry* e = leg->AddEntry(
"",
291 stack->GetTitle(), y-1),
293 e->SetFillColor(col);
294 e->SetFillStyle(1001);
295 e->SetLineColor(col);
297 ratio->Draw(first ?
"nostack" :
"nostack same");
299 Double_t min = 100*(1 - pmin->GetVal());
300 Double_t max = 100*(pmax->GetVal()-1);
302 Double_t c1 = centAxis->GetBinLowEdge(cnt);
303 Double_t c2 = centAxis->GetBinUpEdge(cnt);
305 trend->SetPoint(cnt-1, cc, avg);
306 trend->SetPointError(cnt-1, cc-c1, c2-cc,
307 (min > 0 ? TMath::Abs(avg-min) : 0), max-avg);
308 least = TMath::Min(avg, least);
309 largest = TMath::Max(avg, largest);
311 TString errs = Form(
"#pm%4.1f%%", avg);
313 if (min > 0) errs = Form(
"{}^{+%4.1f}_{-%4.1f}%%", max, min);
314 else errs = Form(
"+%4.1f%%", TMath::Max(min,max));
316 if (leg->GetNColumns() > 1) {
317 e = leg->AddEntry(
"", errs,
"");
318 e->SetFillColor(kWhite);
320 e->SetLineColor(kWhite);
321 e->SetMarkerColor(kWhite);
324 TLatex* ltx =
new TLatex(5.9, y, errs);
325 ltx->SetTextAlign(32);
326 ltx->SetTextFont(42);
327 ltx->SetTextSize(0.04);
328 ltx->SetTextColor(col+1);
332 if (!first)
continue;
334 ratio->SetMaximum(centAxis->GetNbins()+1.3);
335 ratio->SetMinimum(.1);
338 TH1* hr = ratio->GetHistogram();
339 hr->SetXTitle(
"#it{#eta}");
340 hr->SetYTitle(
"Ratio to V0M");
341 hr->GetXaxis()->SetTitleSize(ts);
342 hr->GetYaxis()->SetTitleSize(ts);
343 hr->GetXaxis()->SetLabelSize(ts);
344 hr->GetYaxis()->SetLabelSize(ts);
345 hr->GetXaxis()->SetTitleOffset(1-4*ts);
346 hr->GetYaxis()->SetTitleOffset(1-5*ts);
347 hr->GetXaxis()->SetNdivisions(10);
348 hr->GetYaxis()->SetNdivisions(10);
350 TH1* hs = stack->GetHistogram();
351 hs->SetXTitle(
"#it{#eta}");
352 hs->SetYTitle(dndeta);
353 hs->GetXaxis()->SetTitleSize(ts);
354 hs->GetYaxis()->SetTitleSize(ts);
355 hs->GetXaxis()->SetLabelSize(ts);
356 hs->GetYaxis()->SetLabelSize(ts);
357 hs->GetXaxis()->SetTitleOffset(1-4*ts);
358 hs->GetYaxis()->SetTitleOffset(1-5*ts);
359 hs->GetXaxis()->SetNdivisions(10);
360 hs->GetYaxis()->SetNdivisions(10);
371 c->Print(Form(
"cent_syserr_%s%s.pdf", (div ?
"div" :
"avg"), all.Data()));
372 c->SaveAs(Form(
"cent_syserr_%s%s.root", (div ?
"div" :
"avg"), all.Data()));
374 TCanvas* aux =
new TCanvas(
"aux",
"aix");
375 aux->SetTopMargin(0.01);
376 aux->SetRightMargin(0.01);
380 trend->GetHistogram()->SetXTitle(
"Centrality [%]");
381 trend->GetHistogram()->SetYTitle(Form(
"#delta#left[%s#right] [%%]",dndeta));
383 TF1* f =
new TF1(
"f",
"[0]*x*x+[1]", 0, 100);
384 f->SetLineColor(kMagenta+2);
385 Double_t cl = centAxis->GetBinCenter(1);
386 Double_t ch = centAxis->GetBinCenter(centAxis->GetNbins());
387 f->SetParameters(largest/ch/ch, least);
390 TLatex* ll =
new TLatex(0.98, 0.98,
391 Form(
"Sys. Uncertainty on %s from Centrality",
393 ll->SetTextAlign(33);
394 ll->SetTextSize(0.05);
399 TLatex* fl =
new TLatex(0.2, 0.8,
400 Form(
"#delta#approx%5.1fc^{2}+%5.1f",
401 largest/ch/ch*100*100,
403 fl->SetTextAlign(13);
404 fl->SetTextSize(0.04);
409 aux->Print(Form(
"cent_syserr_%s%s_trend.pdf",
410 (div ?
"div" :
"avg"), all.Data()));
TObject * GetObject(TDirectory *d, const char *name, TClass *cls=0, Bool_t verb=true)
void CentSysErr(Bool_t div=false, Bool_t zem=false)
TParameter< double > * GetParam(TCollection *c, const char *name, Bool_t verb=false)
TH1 * GetH1(TCollection *c, const char *name)
void ProcessOne(const char *meth, Int_t style, TList *stacks, TList *ratios, TList *mins, TList *maxs, TList *avgs, TAxis *¢Axis)
TH2 * GetH2(TCollection *c, const char *name)
TFile * file
TList with histograms for a given trigger.
THStack * GetStack(TCollection *c, const char *name, Bool_t verb=true)
TCollection * GetCollection(TDirectory *d, const char *name)