1 #include <TMultiGraph.h>
5 #include <TGraphAsymmErrors.h>
6 #include <TGraphErrors.h>
9 #include <TLegendEntry.h>
25 return (sys == 4 ? (style == 23 ? 9 : 4) : 0) + style;
44 what.ReplaceAll(
"X", (sys == 3 ?
"A" :
"C"));
45 TString sysN(sys == 3 ?
"pPb" :
"Pbp");
48 cmd = Form(
"Drawer::GetStack(0,\"%s\",5023,\"CENT%s\")",
51 Long_t ret = gROOT->ProcessLine(cmd);
53 Warning(
"GetOne",
"didn't get anything back for %s", what.Data());
56 THStack*
stack =
reinterpret_cast<THStack*
>(ret);
58 Warning(
"GetOne",
"didn't get anything back for %s", what.Data());
62 TMultiGraph* mg =
new TMultiGraph;
63 TIter nextH(stack->GetHists());
65 while ((hist = static_cast<TH1*>(nextH()))) {
66 ret = gROOT->ProcessLine(Form(
"Drawer::H2G((TH1*)%p,0)",hist));
68 Warning(
"GetOne",
"Couldn't convert %s", hist->GetName());
72 g->SetMarkerStyle(sty);
76 Info(
"",
"Got %d graphs", mg->GetListOfGraphs()->GetEntries());
77 mg->GetListOfGraphs()->Sort();
78 mg->SetName(Form(
"fwd_%s_%s", sysN.Data(), meth));
95 what.ReplaceAll(
"X", (sys == 3 ?
"A" :
"C"));
97 if (what.Contains(
"V0M")) cnt = (0x01 << 4);
98 else if (what.Contains(
"V0A")) cnt = (0x02 << 4);
99 else if (what.Contains(
"ZNA")) cnt = (0x04 << 4);
100 else if (what.Contains(
"ZNC")) cnt = (0x08 << 4);
101 else if (what.Contains(
"V0C")) cnt = (0x10 << 4);
102 else if (what.Contains(
"CL1")) cnt = (0x20 << 4);
103 Info(
"GetOne",
"%d/%s -> 0x%04x", sys, meth, cnt);
106 gROOT->ProcessLine(Form(
"RefData::GetData(%d,5023,0x%x,0,100,0xf);",
109 Warning(
"GetOne",
"didn't get anything back for %s", what.Data());
112 TMultiGraph* mg =
reinterpret_cast<TMultiGraph*
>(ret);
114 Warning(
"GetOne",
"didn't get anything back for %s", what.Data());
119 TIter next(mg->GetListOfGraphs());
121 while ((g = static_cast<TGraph*>(next())))
122 g->SetMarkerStyle(sty);
123 Info(
"",
"Got %d graphs", mg->GetListOfGraphs()->GetEntries());
124 mg->GetListOfGraphs()->Sort();
125 mg->SetName(Form(
"fwd_%s_%s", (sys == 3 ?
"pPb" :
"Pbp"), meth));
139 for (
Int_t i = 0; i < n/2; i++) {
142 if (i1 == i2)
continue;
151 g->SetPoint(i1, -x2, y2);
152 g->SetPointError(i1, ex2, ey2);
153 g->SetPoint(i2, -x1, y1);
154 g->SetPointError(i2, ex1, ey1);
167 for (
Int_t i = 0; i < n/2; i++) {
170 if (i1 == i2)
continue;
183 g->SetPoint(i1, -x2, y2);
184 g->SetPointError(i1, exl2, exh2, eyl2, eyh2);
185 g->SetPoint(i2, -x1, y1);
186 g->SetPointError(i2, exl1, exh1, eyl1, eyh1);
198 if (g->IsA()->InheritsFrom(TGraphAsymmErrors::Class()))
199 FlipG(static_cast<TGraphAsymmErrors*>(g));
200 else if (g->IsA()->InheritsFrom(TGraphErrors::Class()))
201 FlipG(static_cast<TGraphErrors*>(g));
203 Warning(
"FlipG",
"Don't know how to flip a %s", g->ClassName());
217 TMultiGraph* ret =
static_cast<TMultiGraph*
>(mg->Clone());
218 TIter next(ret->GetListOfGraphs());
220 while ((g = static_cast<TGraph*>(next())))
235 Info(
"RatioGG(GE)",
"%s (%s:%d)/ %s (%s:%d)",
236 num->GetName(), num->ClassName(), num->GetN(),
237 denom->GetName(), denom->ClassName(), denom->GetN());
238 Int_t n = num->GetN();
239 Double_t dh = denom->GetX()[n-1]+denom->GetEX()[n-1];
240 Double_t dl = denom->GetX()[0] +denom->GetEX()[0];
242 for (
Int_t i = 0; i < n; i++) {
244 if (x > dh || x < dl) {
245 clean.SetBitNumber(i);
252 num->SetPoint(i, x, y/d);
253 num->SetPointError(i, ex, ey/d);
255 for (
Int_t i = clean.GetNbits()-1; i >= 0; i--) {
256 if (clean.TestBitNumber(i)) num->RemovePoint(i);
269 Info(
"RatioGG(GA)",
"%s (%s:%d)/ %s (%s:%d)",
270 num->GetName(), num->ClassName(), num->GetN(),
271 denom->GetName(), denom->ClassName(), denom->GetN());
272 Int_t n = num->GetN();
273 for (
Int_t i = 0; i < n; i++) {
281 num->SetPoint(i, x, y/d);
282 num->SetPointError(i, exl, exh, eyl/d, eyh/d);
295 if (num->IsA()->InheritsFrom(TGraphAsymmErrors::Class()))
296 RatioGG(static_cast<TGraphAsymmErrors*>(num),denom);
297 else if (num->IsA()->InheritsFrom(TGraphErrors::Class()))
298 RatioGG(static_cast<TGraphErrors*>(num),denom);
300 Warning(
"RatioGG",
"Don't know how to ratio a %s to a %s",
301 num->ClassName(), denom->ClassName());
317 TMultiGraph* ret =
static_cast<TMultiGraph*
>(num->Clone());
318 TIter nextN(ret->GetListOfGraphs());
319 TIter nextD(denom->GetListOfGraphs());
322 while ((n = static_cast<TGraph*>(nextN())) &&
323 (d =
static_cast<TGraph*
>(nextD())))
341 const char* ytitle=
"1/#it{N} d#it{N}_{ch}/d#it{#eta}")
343 static Int_t cnt = 0;
344 TMultiGraph* mg =
static_cast<TMultiGraph*
>(o);
345 TH1* h = mg->GetHistogram();
350 Double_t etaMin = (hasFwd ? -6 : -2.5);
351 Double_t etaMax = (hasFwd ? +6 : +2.5);
352 h->GetXaxis()->Set((etaMax-etaMin)/0.5, etaMin, etaMax);
354 h->SetName(Form(
"%s_%d", o->GetName(), cnt++));
356 h->SetXTitle(
"#it{#eta}");
357 h->SetYTitle(ytitle);
358 h->GetXaxis()->SetNdivisions(210);
359 h->GetYaxis()->SetNdivisions(210);
360 h->GetXaxis()->SetLabelFont(42);
361 h->GetXaxis()->SetLabelSize(0.05);
362 h->GetXaxis()->SetTitleFont(42);
363 h->GetXaxis()->SetTitleSize(0.05);
364 h->GetXaxis()->SetTitleOffset(0.7);
365 h->GetYaxis()->SetLabelFont(42);
366 h->GetYaxis()->SetLabelSize(0.05);
367 h->GetYaxis()->SetTitleFont(42);
368 h->GetYaxis()->SetTitleSize(0.05);
369 h->GetYaxis()->SetTitleOffset(0.7);
370 h->SetMaximum(fac*h->GetMaximum());
387 TObjString* oc1 =
static_cast<TObjString*
>(a->At(1));
388 TObjString* oc2 =
static_cast<TObjString*
>(a->At(2));
389 TString sc1 = oc1->String().Strip(TString::kLeading,
'0');
390 TString sc2 = oc2->String().Strip(TString::kLeading,
'0');
392 return Form(
"%3d-%3d%%", sc1.Atoi(), sc2.Atoi());
405 TMultiGraph* fwdpPb =
GetOneFwd(3, meth, style);
406 TMultiGraph* fwdPbp =
GetOneFwd(4, meth, style);
408 if (!fwdpPb || !fwdPbp) {
409 Warning(
"CompareOne",
"FWD pPb=%p Pbp=%p", fwdpPb, fwdPbp);
412 TMultiGraph* cenpPb =
GetOneCen(3, meth, style);
413 TMultiGraph* cenPbp =
GetOneCen(4, meth, style);
415 if (!cenpPb || !cenPbp) {
416 Warning(
"CompareOne",
"CEN pPb=%p Pbp=%p", cenpPb, cenPbp);
419 if (!hasCen && !hasFwd)
return;
421 TCanvas*
c =
new TCanvas(meth, meth, 900, 1000);
422 c->SetTopMargin(0.01);
423 c->SetRightMargin(0.01);
427 c->GetPad(1)->SetRightMargin(1-lx+.01);
428 c->GetPad(2)->SetRightMargin(1-lx+.01);
429 c->GetPad(3)->SetRightMargin(1-lx+.01);
430 c->GetPad(1)->SetGridx();
431 c->GetPad(2)->SetGridx();
432 c->GetPad(3)->SetGridx();
436 TMultiGraph* frame = 0;
443 cenpPb->Draw(frame ?
"p" :
"pa");
445 if (!frame) frame = cenpPb;
449 TLegend* l =
new TLegend(lx, 0.01, 0.99, 0.99,
450 Form(
"%s estimator", meth));
455 TLegendEntry* e = l->AddEntry(
"",
"p-Pb",
"p");
456 e->SetMarkerStyle(
Marker(3, style));
457 e = l->AddEntry(
"",
"Pb-p",
"p");
458 e->SetMarkerStyle(
Marker(4, style));
462 TMultiGraph* ffwdPbp = 0;
465 ffwdPbp->SetName(Form(
"fwd_%s_fPbp", meth));
469 TMultiGraph* fcenPbp = 0;
472 fcenPbp->SetName(Form(
"cen_%s_fPbp", meth));
473 cenpPb->Draw(hasFwd ?
"p" :
"ap");
477 TLegend* ll =
new TLegend(lx, 0.01, 0.99, 0.9,
478 "Pb-p flipped around #it{#eta}=0");
480 ll->SetBorderSize(0);
483 TIter next(frame->GetListOfGraphs());
485 while ((g = static_cast<TGraph*>(next()))) {
486 e = ll->AddEntry(
"",
ExtractCent(g->GetName()),
"f");
487 e->SetFillColor(g->GetMarkerColor());
488 e->SetFillStyle(1001);
489 e->SetLineColor(g->GetMarkerColor());
496 Double_t minEta = (hasFwd ? -3.5 : -2.);
497 Double_t maxEta = (hasFwd ? +5.0 : +2.);
499 band->SetPoint(0, minEta, 1);
500 band->SetPoint(1, maxEta, 1);
501 band->SetPointError(0, 0, .05);
502 band->SetPointError(1, 0, .05);
503 band->SetFillColor(kYellow-8);
504 band->SetFillStyle(3001);
505 band->SetLineColor(kYellow-8);
508 TMultiGraph* fwdRat =
RatioMG(ffwdPbp, fwdpPb);
509 fwdRat->SetName(Form(
"fwd_%s_rat", meth));
510 fwdRat->GetListOfGraphs()->AddFirst(band,
"3");
515 TMultiGraph* cenRat =
RatioMG(fcenPbp, cenpPb);
516 cenRat->SetName(Form(
"cen_%s_rat", meth));
518 cenRat->GetListOfGraphs()->AddFirst(band,
"3");
521 cenRat->Draw(hasFwd ?
"p" :
"ap");
523 FixFrame(frame, hasFwd, 1,
"Flipped Pb-p over p-Pb");
524 if (meth[0] !=
'C') {
525 frame->GetHistogram()->SetMinimum(0.74);
526 frame->GetHistogram()->SetMaximum(1.26);
528 TLegend* lll =
new TLegend(lx, 0.4, 0.99, 0.5);
529 lll->SetFillStyle(0);
530 lll->SetBorderSize(0);
531 lll->SetTextFont(42);
533 lll->AddEntry(band,
"5% error band",
"F");
536 c->Print(Form(
"%s.pdf", meth));
543 gROOT->LoadMacro(
"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dndeta/Drawer.C+g");
544 gROOT->LoadMacro(
"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/OtherData.C+g");
546 const char* meths[] = {
"V0M",
"CL1",
"V0X",
"ZNX", 0 };
547 Int_t styles[] = { 20, 21, 22, 23, 0 };
549 const char** pmeth = meths;
550 Int_t* pstyle = styles;
552 while (*pmeth && *pstyle) {
TMultiGraph * FlipMG(TMultiGraph *mg)
TMultiGraph * RatioMG(TMultiGraph *num, TMultiGraph *denom)
void FixFrame(TObject *o, Bool_t hasFwd, Double_t fac=1.2, const char *ytitle="1/#it{N} d#it{N}_{ch}/d#it{#eta}")
void FlipG(TGraphErrors *g)
TMultiGraph * GetOneCen(UShort_t sys, const char *meth, Int_t style)
Int_t Marker(Int_t sys, Int_t style)
TMultiGraph * GetOneFwd(UShort_t sys, const char *meth, Int_t style)
void CompareOne(const char *meth, Int_t style)
const char * ExtractCent(const char *name)
void RatioGG(TGraphErrors *num, TGraph *denom)