6 # include <TInterpreter.h> 9 # include <TMultiGraph.h> 11 # include <TGraphErrors.h> 12 # include <TGraphAsymmErrors.h> 17 # include <TLegendEntry.h> 21 # include <TParameter.h> 56 if (gROOT->GetClass(
"RefData"))
return;
61 fwd =
gSystem->ExpandPathName(
"$ALICE_PHYSICS/PWGLF/FORWARD/analysis2");
62 gROOT->SetMacroPath(Form(
"%s:%s", gROOT->GetMacroPath(),
fwd));
63 TString path(gROOT->GetMacroPath());
65 path.Append(Form(
":%s", fwd));
66 gROOT->SetMacroPath(path);
68 gROOT->LoadMacro(
"OtherData.C+");
92 case 0x004:
if (sys == 3) exps = 0x4;
break;
98 case 0x200: c2 = 100;
break;
102 gROOT->ProcessLine(Form(
"RefData::Verbose(%d);", verbose));
103 ::Info(
"",
"sys=%d sNN=%d trg=0x%x c1=%d c2=%d exp=0x%x",
104 sys, sNN, trg, c1, c2, exps);
106 gROOT->ProcessLine(Form(
"RefData::GetData(%d,%d,%d,%d,%d,%d);",
107 sys,sNN,trg,c1,c2,exps));
110 Warning(
"",
"RefData::GetData(%d,%d,0x%x,%d,%d,0x%x); failed",
111 sys,sNN,trg,c1,c2,exps);
115 TMultiGraph* mg =
reinterpret_cast<TMultiGraph*
>(ret);
135 return GetOther(system, sNN, trigger,
"ALICE WIP", verbose);
158 if (s.EqualTo(
"PP")) sys = 1;
159 else if (s.EqualTo(
"PPB")) sys = 3;
160 else if (s.EqualTo(
"PBPB")) sys = 2;
161 else if (s.EqualTo(
"PBP")) sys = 4;
166 if (e.Contains(
"UA5")) exp |= 0x01;
167 if (e.Contains(
"CMS")) exp |= 0x02;
168 if (e.Contains(
"ALICE")) exp |= 0x04;
169 if (e.Contains(
"WIP")) exp |= 0x08;
170 if (e.Contains(
"EG")) exp |= 0x10;
175 if (t.EqualTo(
"INEL")) trg = 0x1;
176 else if (t.EqualTo(
"INELGT0") || t.EqualTo(
"INEL>0")) trg = 0x2;
177 else if (t.EqualTo(
"NSD") || t.EqualTo(
"V0AND")) trg = 0x4;
178 else if (t.BeginsWith(
"CENT")) {
179 if (t.EndsWith(
"V0M")) trg |= 0x010;
180 else if (t.EndsWith(
"V0A")) trg |= 0x020;
181 else if (t.EndsWith(
"V0X")) trg |= (sys == 3 ? 0x020 : 0x100);
182 else if (t.EndsWith(
"ZNA")) trg |= 0x040;
183 else if (t.EndsWith(
"ZNC")) trg |= 0x080;
184 else if (t.EndsWith(
"V0C")) trg |= 0x100;
185 else if (t.EndsWith(
"ZNX")) trg |= (sys == 3 ? 0x040 : 0x80);
186 else if (t.EndsWith(
"MB")) { trg = 0x4; exp = 0x4; }
189 ::Info(
"",
"sys=%d sNN=%d trg=0x%x exp=0x%x", sys, sNN, trg, exp);
190 TMultiGraph* mg =
GetOther(sys, sNN, trg, exp, verbose);
193 "No other data for %s %s %d (%s)",
194 system.Data(), trigger.Data(), sNN, exps.Data());
204 return TColor::GetColor(40, 58, 68);
213 return TColor::GetColor(226, 0, 26);
222 return TColor::GetColor(202, 71, 67);
231 return TColor::GetColor(238, 125, 17);
235 Int_t origR, origG, origB;
236 TColor::Pixel2RGB(TColor::Number2Pixel(origNum), origR, origG, origB);
237 Int_t off = nTimes*0x33;
238 Int_t newR = TMath::Min((origR+off),0xff);
239 Int_t newG = TMath::Min((origG+off),0xff);
240 Int_t newB = TMath::Min((origB+off),0xff);
241 Int_t newNum = TColor::GetColor(newR, newG, newB);
246 TString e(system.EqualTo(
"pp", TString::kIgnoreCase)
247 ?
"#sqrt{s}=" :
"#sqrt{s_{NN}}=");
248 if (sNN < 1000) e.Append(Form(
"%dGeV", sNN));
249 else if (sNN % 1000 == 0) e.Append(Form(
"%dTeV", sNN/1000));
250 else e.Append(Form(
"%.2fTeV",
float(sNN)/1000));
266 g->SetMarkerStyle(h->GetMarkerStyle());
267 g->SetMarkerColor(h->GetMarkerColor());
268 g->SetLineColor(h->GetLineColor());
269 g->SetName(h->GetName());
270 g->SetTitle(h->GetTitle());
273 Int_t nX = h->GetNbinsX();
274 for (
Int_t iX = 1; iX <= nX; iX++) {
276 if (y < 1e-6)
continue;
277 Double_t x = h->GetXaxis()->GetBinCenter(iX) - xOff;
278 Double_t ex = h->GetXaxis()->GetBinWidth(iX)/2;
281 g->SetPoint(iP, sign * x, y);
282 g->SetPointError(iP++, ex, ey);
299 g->SetMarkerStyle(h->GetMarkerStyle());
300 g->SetMarkerColor(h->GetMarkerColor());
301 g->SetLineColor(h->GetLineColor());
302 g->SetName(h->GetName());
303 g->SetTitle(h->GetTitle());
306 Int_t nX = h->GetNbinsX();
307 for (
Int_t iX = 1; iX <= nX; iX++) {
309 if (y < 1e-6)
continue;
310 Double_t x = h->GetXaxis()->GetBinCenter(iX);
311 Double_t ex = h->GetXaxis()->GetBinWidth(iX)/2;
315 ec = sC->GetBinContent(iX);
316 ee = sC->GetBinError(iX);
319 ec = sA->GetBinContent(iX);
320 ee = sA->GetBinError(iX);
325 g->SetPoint(iP, x, y);
326 g->SetPointError(iP++, ex, ex, eyl, eyh);
339 Warning(
"ErrorGraphs",
"Called with vanila TGraph (%s)",
340 g->IsA()->GetName());
344 for (
Int_t i = 0; i < n; i++) {
345 low->SetPoint(i, 0, 0);
346 up->SetPoint(i, 0, 0);
358 for (
Int_t i = 0; i < n; i++) {
359 low->SetPoint(i, g->GetX()[i], g->GetY()[i] - g->GetEY()[i]);
360 up->SetPoint(i, g->GetX()[i], g->GetY()[i] + g->GetEY()[i]);
372 for (
Int_t i = 0; i < n; i++) {
373 low->SetPoint(i, g->GetX()[i], g->GetY()[i] - g->GetEYlow()[i]);
374 up->SetPoint(i, g->GetX()[i], g->GetY()[i] + g->GetEYhigh()[i]);
389 nm.ReplaceAll(
"Forward",
"SysError");
390 nm.Append(aSide ?
"_a" :
"_c");
391 TH1* ret =
static_cast<TH1*
>(h->Clone(nm.Data()));
392 ret->SetDirectory(0);
393 for (
Int_t i = 1; i <= ret->GetNbinsX(); i++) {
394 Double_t x = ret->GetXaxis()->GetBinCenter(i);
395 if (aSide && x < 0) {
396 ret->SetBinContent(i,0);
397 ret->SetBinError(i,0);
400 if (!aSide && x >= 0) {
401 ret->SetBinContent(i,0);
402 ret->SetBinError(i,0);
404 ret->SetBinError(i, ret->GetBinContent(i)*factor);
427 TH1* ret =
static_cast<TH1*
>(h->Clone());
429 for (
Int_t i = 1; i <= ret->GetNbinsX(); i++) {
431 if (c < 1e-6)
continue;
434 Double_t x = ret->GetXaxis()->GetBinCenter(i);;
438 Double_t ye = TMath::Max(y-yl,yu-yl);
449 e = TMath::Sqrt(e*e*y*y+ye*ye*c*c);
451 ret->SetBinContent(i,c);
452 ret->SetBinError(i,e);
474 g->SetMarkerStyle(den->GetMarkerStyle());
475 g->SetMarkerColor(num->GetMarkerColor());
476 g->SetLineColor(num->GetLineColor());
477 g->SetName(num->GetName());
478 g->SetTitle(num->GetTitle());
485 if (g->IsA()->InheritsFrom(TGraphAsymmErrors::Class())) {
489 else if (g->IsA()->InheritsFrom(TGraphErrors::Class())) {
501 Double_t dMax = den->GetX()[den->GetN()-1];
503 Int_t n = num->GetN();
504 for (
Int_t i = 0; i < n; i++) {
506 if (x < dMin || x > dMax)
continue;
509 Double_t ynl = (nlow ? yn-nlow->Eval(x) : 0);
510 Double_t ynu = (nup ? nup->Eval(x)-yn : 0);
512 Double_t ydl = (dlow ? yd-dlow->Eval(x-dx) : 0);
513 Double_t ydu = (dup ? dup->Eval(x-dx)-yd : 0);
514 if (yd < 1e-6 || yn < 1e-6)
continue;
516 g->SetPoint(iP, x, yn/yd);
520 Double_t el = TMath::Sqrt(ydl*ydl*yn*yn+ynl*ynl*yd*yd) / yd;
521 Double_t eu = TMath::Sqrt(ydu*ydu*yn*yn+ynu*ynu*yd*yd) / yd;
524 ga->SetPointError(iP, nga->GetEXlow()[i], nga->GetEXhigh()[i], el, eu);
526 else if (ge && nge) {
530 Double_t e = TMath::Sqrt(yde*yde*yn*yn+yne*yne*yd*yd) / yd;
532 ge->SetPointError(iP, nge->GetEX()[i], e);
562 TString sys(system); sys.ToUpper();
563 TString trg(trigger); trg.ToUpper();
564 if (trg.EqualTo(
"NSD")) trg =
"V0AND";
566 if (sys.EqualTo(
"PP")) {
568 if (trg.EqualTo(
"INEL")) trg =
"INEL";
569 else if (trg.EqualTo(
"INELGT0") || trg.EqualTo(
"INEL>0")) trg =
"INELGt0";
570 else if (trg.EqualTo(
"V0AND")) trg =
"V0AND";
573 else if (sys.EqualTo(
"PPB")) {
575 if (trg.EqualTo(
"CENTMB") || trg.EqualTo(
"V0AND")) trg =
"CENTMB";
576 else if (trg.EqualTo(
"CENTV0A")) trg =
"CENTV0A";
577 else if (trg.EqualTo(
"CENTV0X")) trg =
"CENTV0A";
578 else if (trg.EqualTo(
"CENTV0M")) trg =
"CENTV0M";
579 else if (trg.EqualTo(
"CENTZNA")) trg =
"CENTZNA";
580 else if (trg.EqualTo(
"CENTZNX")) trg =
"CENTZNA";
583 else if (sys.EqualTo(
"PBP")) {
585 if (trg.EqualTo(
"CENTMB") || trg.EqualTo(
"V0AND")) trg =
"CENTMB";
586 else if (trg.EqualTo(
"CENTV0C")) trg =
"CENTV0C";
587 else if (trg.EqualTo(
"CENTV0X")) trg =
"CENTV0C";
588 else if (trg.EqualTo(
"CENTV0M")) trg =
"CENTV0M";
589 else if (trg.EqualTo(
"CENTZNC")) trg =
"CENTZNC";
590 else if (trg.EqualTo(
"CENTZNX")) trg =
"CENTZNC";
593 else if (sys.EqualTo(
"PBPB")) {
595 if (trg.EqualTo(
"CENT")) trg =
"CENT";
596 else if (trg.EqualTo(
"CENTV0M")) trg =
"CENT";
600 Error(
"",
"Unknown system: %s", system.Data());
604 Error(
"",
"Unknown trigger %s for system %s",
605 trigger.Data(), system.Data());
609 TString path(Form(
"%s/%s/%04d/%s/%s.C",
610 (empirical ?
"nosec" :
"normal"),
611 sys.Data(), sNN, trg.Data(),
612 (rebinned ?
"rebin" :
"full")));
613 if (
gSystem->AccessPathName(path.Data())) {
614 Error(
"",
"Script %s does not exist", path.Data());
615 Error(
"",
"sys=%s, sNN=%d, trg=%s, %d",
616 sys.Data(), sNN, trg.Data(), rebinned);
620 THStack*
stack =
new THStack(
"stack",
"");
622 gROOT->Macro(Form(
"%s((THStack*)%p,(TLegend*)%p,%d)",
623 path.Data(),
stack, legend, marker));
625 gROOT->Macro(Form(
"%s((THStack*)%p,0,%d)",
626 path.Data(),
stack, marker));
628 gInterpreter->UnloadFile(path.Data());
629 if (!stack->GetHists() || stack->GetHists()->GetEntries() <= 0) {
630 Error(
"",
"Got no histograms in stack from %s",
656 TString t(Form(
"%s %s %s", system.Data(), e.Data(), trigger.Data()));
657 TCanvas*
canvas =
new TCanvas(Form(
"%s_%04d_%s_%s_%s",
658 system.Data(), sNN, trigger.Data(),
659 (rebinned ?
"coarse" :
"full"),
660 (empirical ?
"empirical" :
"mc")),
663 canvas->SetTopMargin(0.01);
664 canvas->SetRightMargin(0.01);
665 canvas->SetFillColor(0);
666 canvas->SetFillStyle(0);
667 canvas->SetBorderMode(0);
668 canvas->SetBorderSize(0);
680 if (types.IsNull())
return;
686 TObjArray* tokens = types.Tokenize(
" ,");
689 while ((token = next())) {
690 canvas->Print(Form(
"%s/%s.%s",
PlotPrefix(), canvas->GetName(),
700 if (sNN != 8000 || !sys.EqualTo(
"pp", TString::kIgnoreCase))
705 if (trigger.EqualTo(
"INEL",TString::kIgnoreCase)) {
709 if (trigger.EqualTo(
"NSD", TString::kIgnoreCase) ||
710 trigger.EqualTo(
"V0AND", TString::kIgnoreCase)) {
739 const char* trigs[] = { trigger, 0 };
740 const char* exps[] = {
"ALICE",
"WIP", 0 };
744 TPair* dataOther =
GetDataOther(l, u, system, sNN, trigs, exps, option,
745 rebinned, empirical, effs);
746 if (effs)
delete [] effs;
747 if (!dataOther || !dataOther->Key()) {
748 Error(
"",
"No data found %s", canvas->GetTitle());
751 THStack* data =
static_cast<THStack*
>(dataOther->Key());
752 TMultiGraph* other =
static_cast<TMultiGraph*
>(dataOther->Value());
754 data->Draw(
"nostack");
755 if (other) other->Draw(
"p");
758 data->SetTitle(Form(
"%s %s %s", system.Data(), data->GetTitle(), trigs[0]));
759 data->SetMaximum(data->GetMaximum(
"nostack")*1.2);
760 data->GetXaxis()->SetTitle(
"#eta");
761 data->GetYaxis()->SetTitle(
"1/#it{N} d#it{N}_{ch}/d#it{#eta}");
774 typedef std::map<double,std::vector<double> > ValueMap;
776 mg->GetListOfGraphs()->ls();
777 TIter next(mg->GetListOfGraphs());
779 while ((g = static_cast<TGraph*>(next()))) {
782 if (g->IsA()->InheritsFrom(TGraphErrors::Class()))
783 ge = static_cast<TGraphErrors*>(g);
784 else if (g->IsA()->InheritsFrom(TGraphAsymmErrors::Class()))
785 ga = static_cast<TGraphAsymmErrors*>(g);
788 for (
Int_t i = 0; i < n; i++) {
791 Double_t eyl = (ge ? ge->GetEY()[i] :
792 ga ? ga->GetEYlow()[i] : 0);
793 Double_t eyh = (ge ? ge->GetEY()[i] :
794 ga ? ga->GetEYhigh()[i] : 0);
797 ValueMap::iterator j = m.begin();
798 for (; j != m.end(); ++j) {
799 ValueMap::iterator k = j;
801 if (TMath::Abs(x-j->first)<1e-1 && (k != m.end() && x < k->first)) {
806 j->second.push_back(y);
807 j->second.push_back(eyl);
808 j->second.push_back(eyh);
821 ValueMap::iterator j = m.begin();
823 for (; j != m.end(); ++j) {
825 if (j->second.size() == 3) {
827 ret->SetPoint(i, j->first, j->second[0]);
828 ret->SetPointError(i, 0, 0, j->second[1], j->second[2]);
833 for (
size_t k = 0; k < j->second.size(); k += 3) {
834 l.
Add(j->second[k],j->second[k+1],j->second[k+2]);
842 ret->SetPoint(i, j->first, f.
fX);
843 ret->SetPointError(i, 0, 0, f.
fEl, f.
fEh);
852 Color_t cols[] = { 96, 86, 76, 66, 59, 55, 52, 0 };
856 if (c == *pc)
return idx;
879 TString n(Form(
"%s_%04d_%s_%s_%s.root",
880 system.Data(), sNN, trigger.Data(),
881 (rebinned ?
"coarse" :
"full"),
882 (empirical ?
"empirical" :
"mc")));
883 TFile* f = TFile::Open(n,
"RECREATE");
884 THStack* s =
GetStack(0, system, sNN, trigger, rebinned, empirical);
889 TDirectory* fmd = f->mkdir(
"fmd");
891 TMultiGraph* gf =
new TMultiGraph(
"all",
"All Graphs");
892 TList* listH = s->GetHists();
896 while ((oH = static_cast<TH1*>(nextH()))) {
898 if (nm.Contains(
"syserror", TString::kIgnoreCase))
continue;
903 sys.ReplaceAll(
"Forward",
"SysError");
904 TH1* sA =
static_cast<TH1*
>(listH->FindObject(Form(
"%s_a", sys.Data())));
905 TH1* sC =
static_cast<TH1*
>(listH->FindObject(Form(
"%s_c", sys.Data())));
924 if (!byCent)
continue;
927 Printf(
"W: Export - didn't find centrality bin for %s (%d)",
928 oH->GetName(), g->GetMarkerColor());
931 TMultiGraph* cGraph =
static_cast<TMultiGraph*
>(byCent->At(cBin));
933 nm.ReplaceAll(
"dndetForward_",
"");
934 cGraph =
new TMultiGraph;
936 byCent->AddAtAndExpand(cGraph, cBin);
938 cGraph->Add(g,
"p1");
943 TMultiGraph* other =
GetOther(system, sNN, trigger);
945 TDirectory* spd = f->mkdir(
"spd");
947 TIter nextG(other->GetListOfGraphs());
949 while ((oG = static_cast<TGraph*>(nextG()))) {
954 if (!byCent)
continue;
957 Printf(
"W: Export - didn't find centrality bin for %s (%d)",
958 oG->GetName(), oG->GetMarkerColor());
961 TMultiGraph* cGraph =
static_cast<TMultiGraph*
>(byCent->At(cBin));
963 cGraph =
new TMultiGraph;
964 byCent->AddAtAndExpand(cGraph, cBin);
966 cGraph->Add(oG,
"p1");
971 Warning(
"",
"No other data for %s,%d,%s",
972 system.Data(),sNN,trigger.Data());
982 cf->SetName(
"combined");
983 cf->SetTitle(
"Combined");
984 cf->SetMarkerStyle(24);
985 cf->SetMarkerColor(kGreen+2);
989 TMultiGraph* com =
new TMultiGraph;
990 com->SetName(
"combined");
993 while ((mg = static_cast<TMultiGraph*>(next()))) {
996 cf->SetName(Form(
"combined_%s",mg->GetName()));
997 cf->SetTitle(
"Combined");
998 cf->SetMarkerStyle(24);
999 cf->SetMarkerColor(static_cast<TGraph*>(mg->GetListOfGraphs()->At(0))
1000 ->GetMarkerColor());
1005 byCent->Write(
"bycent", TObject::kSingleKey);
1011 Info(
"Export",
"Exported data to %s", f->GetName());
1021 TIter next(stack->GetHists());
1023 while ((hist = static_cast<TH1*>(next()))) {
1024 Int_t nBins = hist->GetNbinsX();
1025 for (
Int_t bin = 1; bin <= nBins; bin++) {
1027 if (c < 1e-6)
continue;
1028 hist->SetBinError(bin, sys*c);
1043 THStack* res =
new THStack(
"Result",
"Result");
1045 Int_t nHist = s1->GetHists()->GetEntries();
1046 for (
Int_t i = 0; i < nHist; i++) {
1047 TH1* h1 =
static_cast<TH1*
>(s1->GetHists()->At(i));
1048 TH1* h2 =
static_cast<TH1*
>(s2->GetHists()->At(i));
1049 Int_t nb = h1->GetNbinsX();
1050 Double_t x1 = h1->GetXaxis()->GetXmin();
1051 Double_t x2 = h1->GetXaxis()->GetXmax();
1054 Int_t hb = (x2+x2) / dx;
1055 TH1* h =
new TH1D(h1->GetName(), h1->GetTitle(), hb, -x2, x2);
1056 h->SetMarkerStyle(h1->GetMarkerStyle());
1057 h->SetMarkerColor(h1->GetMarkerColor());
1058 h->SetMarkerSize(h1->GetMarkerSize());
1059 h->SetFillStyle(kGray);
1060 h->SetFillColor(1001);
1061 h->SetLineColor(h1->GetLineColor());
1063 for (
Int_t j = 1; j <= hb; j++) {
1064 Double_t x = h->GetXaxis()->GetBinCenter(j);
1065 Int_t b1 = h1->GetXaxis()->FindBin(x);
1066 Int_t b2 = h2->GetXaxis()->FindBin(-x);
1067 Double_t xx1 = h1->GetXaxis()->GetBinCenter(b1);
1068 Double_t xx2 = -h2->GetXaxis()->GetBinCenter(b2);
1069 Double_t c1 = h1->GetBinContent(b1);
1070 Double_t c2 = h2->GetBinContent(b2);
1074 if (TMath::Abs(xx1+xx2) < 1e-6) {
1076 Double_t ee = TMath::Sqrt(e1*e1+e2*e2);
1078 h->SetBinContent(j, cc);
1079 h->SetBinError(j, ee);
1083 h->SetBinContent(j, c1);
1084 h->SetBinError(j, e1);
1088 h->SetBinContent(j, c2);
1089 h->SetBinError(j, e2);
1106 THStack* res =
new THStack(
"res", s->GetTitle());
1108 Int_t nHist = s->GetHists()->GetEntries();
1109 for (
Int_t i = 0; i < nHist; i++) {
1110 TH1* h1 =
static_cast<TH1*
>(s->GetHists()->At(i));
1111 Int_t nb = h1->GetNbinsX();
1112 Double_t x1 = h1->GetXaxis()->GetXmin();
1113 Double_t x2 = h1->GetXaxis()->GetXmax();
1116 Int_t hb = (x2+x2) / dx;
1117 TH1* h =
new TH1D(h1->GetName(), h1->GetTitle(), hb, -x2, x2);
1118 h->SetMarkerStyle(h1->GetMarkerStyle());
1119 h->SetMarkerColor(h1->GetMarkerColor());
1120 h->SetMarkerSize(h1->GetMarkerSize());
1121 h->SetFillStyle(kGray);
1122 h->SetFillColor(1001);
1123 h->SetLineColor(h1->GetLineColor());
1125 for (
Int_t j = 1; j <= hb; j++) {
1126 Double_t x = h->GetXaxis()->GetBinCenter(j);
1127 Int_t b1 = h1->GetXaxis()->FindBin(x);
1128 Int_t b2 = h1->GetXaxis()->FindBin(-x);
1129 Double_t c1 = h1->GetBinContent(b1);
1130 Double_t c2 = h1->GetBinContent(b2);
1134 if (c1 > 0 && c2 > 0) {
1136 Double_t ee = TMath::Sqrt(e1*e1+e2*e2);
1138 h->SetBinContent(j, cc);
1139 h->SetBinError(j, ee);
1143 h->SetBinContent(j, c1);
1144 h->SetBinError(j, e1);
1148 h->SetBinContent(j, c2);
1149 h->SetBinError(j, e2);
1175 TString t1(trigger); t1.ReplaceAll(
"X",
"A");
1176 TString t2(trigger); t2.ReplaceAll(
"X",
"C");
1177 THStack* s1 =
GetStack(0, system, sNN, t1, rebinned, empirical);
1178 THStack* s2 =
GetStack(0, system2, sNN, t2, rebinned, empirical);
1184 s1->SetTitle(canvas->GetTitle());
1185 s2->SetTitle(canvas->GetTitle());
1188 res->Draw(Form(
"nostack %s", option));
1190 TMultiGraph* other =
GetOther(system, sNN, t1);
1192 TIter next(other->GetListOfGraphs());
1194 while ((g = static_cast<TGraph*>(next()))) {
1195 g->SetFillColor(kGray);
1196 g->SetFillStyle(3001);
1197 g->Draw(Form(
"p same %s", option));
1201 Warning(
"",
"No other data for %s,%d,%s",
1202 system.Data(),sNN,trigger.Data());
1230 THStack* pp =
GetStack(0,
"pp", ppsNN, ppTrigger, rebinned, empirical);
1233 THStack* tgt =
GetStack(0, system, sNN, trigger, rebinned, empirical);
1236 TH1* ref =
static_cast<TH1*
>(pp->GetHists()
1237 ->FindObject(
"dndetaForward_all"));
1246 TMultiGraph* outRatio = (write ?
new TMultiGraph(
"fwd",
"") : 0);
1247 TMultiGraph* outPP = (write ?
new TMultiGraph(
"pp",
"") : 0);
1248 THStack* ratios =
new THStack(
"ratios", tgt->GetTitle());
1249 TIter next(tgt->GetHists());
1252 while ((h = static_cast<TH1*>(next()))) {
1257 rg->SetLineColor(h->GetLineColor());
1258 rg->SetLineStyle(h->GetLineStyle());
1259 rg->SetFillColor(kBlue-10);
1260 rg->SetFillStyle(0);
1261 outRatio->Add(rg,
"p");
1264 if (outPP) outPP->Add(g,
"p");
1271 TString tTgt(Form(
"%s %s %s", system.Data(), eTgt.Data(), trigger.Data()));
1272 TString tpp(Form(
"pp %s %s", epp.Data(), ppTrigger.Data()));
1273 TString t(Form(
"%s scaled by %s", tTgt.Data(), tpp.Data()));
1274 ratios->SetTitle(t);
1277 canvas->SetName(Form(
"%s_%04d_%s_pp_%04d_%s",
1278 system.Data(), sNN, trigger.Data(),
1279 ppsNN, ppTrigger.Data()));
1280 canvas->SetTitle(t);
1282 ratios->Draw(
"nostack");
1283 ratios->GetXaxis()->SetTitle(Form(
"#eta%s",
1284 (TMath::Abs(etaShift) < 1e-6
1285 ?
"" :
"-#eta_{MC}")));
1286 const char*
dNdeta =
"1/#it{N} d#it{N}_{ch}/d#it{#eta}";
1287 ratios->GetYaxis()->SetTitle(Form(
"#frac{%s|_{%s}}{%s|_{%s}}",
1288 dNdeta, tTgt.Data(), dNdeta, tpp.Data()));
1289 ratios->GetYaxis()->SetTitleOffset(1.5);
1291 TMultiGraph* other =
GetOther(system, sNN, trigger);
1292 TMultiGraph* ppOther =
GetOther(
"pp", ppsNN, ppTrigger);
1293 TMultiGraph* outOther = (write ?
new TMultiGraph(
"cen",
"") : 0);
1294 if (other && ppOther && ppOther->GetListOfGraphs()) {
1297 static_cast<TGraph*
>(ppOther->GetListOfGraphs()->At(0));
1301 if (otherRef->IsA()->InheritsFrom(TGraphAsymmErrors::Class()))
1302 ErrorGraphs(static_cast<TGraphAsymmErrors*>(otherRef), dlow, dup);
1303 else if (otherRef->IsA()->InheritsFrom(TGraphErrors::Class()))
1304 ErrorGraphs(static_cast<TGraphErrors*>(otherRef), dlow, dup);
1309 outPP->Add(otherRef,
"p");
1310 TIter nextG(other->GetListOfGraphs());
1312 while ((g1 = static_cast<TGraph*>(nextG()))) {
1313 TGraph* rg =
GOverG(g1, otherRef, dlow, dup, etaShift);
1314 if (rg) rg->Draw(
"p same");
1315 outOther->Add(rg,
"p");
1322 Warning(
"",
"No other data for %s,%d,%s",
1323 system.Data(),sNN,trigger.Data());
1328 TFile* out = TFile::Open(Form(
"%s/%s.root",
PlotPrefix(),
1329 canvas->GetName()),
"RECREATE");
1359 TString t1(trigger); t1.ReplaceAll(
"X",
"A");
1360 TString t2(trigger); t2.ReplaceAll(
"X",
"C");
1361 THStack* s1 =
GetStack(0, system, sNN, t1, rebinned, empirical);
1362 THStack* s2 =
GetStack(0, system2, sNN, t2, rebinned, empirical);
1364 if (!s1 || !s2)
return;
1367 rebinned, empirical));
1370 TH1* ref =
static_cast<TH1*
>(pp->GetHists()
1371 ->FindObject(
"dndetaForward_all"));
1380 THStack* ratios =
new THStack(
"ratios", tgt->GetTitle());
1381 TMultiGraph* outRatio = (write ?
new TMultiGraph(
"fwd",
"") : 0);
1382 TMultiGraph* outPP = (write ?
new TMultiGraph(
"pp",
"") : 0);
1383 TMultiGraph* outdNdeta = (write ?
new TMultiGraph(
"dNdeta",
"") : 0);
1384 TIter next(tgt->GetHists());
1386 while ((h = static_cast<TH1*>(next()))) {
1389 r->SetFillColor(kBlue-10);
1390 Info(
"",
"Adding %s to stack", r->GetName());
1391 ratios->Add(r,
"p");
1394 rg->SetLineColor(h->GetLineColor());
1395 rg->SetLineStyle(h->GetLineStyle());
1396 rg->SetFillColor(kBlue-10);
1397 rg->SetFillStyle(0);
1398 outRatio->Add(rg,
"p");
1402 hg->SetLineColor(h->GetMarkerColor());
1403 outdNdeta->Add(hg,
"p");
1407 outPP->Add(g,
"p1");
1414 TString tTgt(Form(
"%s %s %s", system.Data(), eTgt.Data(), trigger.Data()));
1415 TString tpp(Form(
"pp %s %s", epp.Data(), ppTrigger.Data()));
1416 TString t(Form(
"%s scaled by %s", tTgt.Data(), tpp.Data()));
1417 ratios->SetTitle(t);
1420 canvas->SetName(Form(
"%s_%04d_%s_pp_%04d_%s_sym",
1421 system.Data(), sNN, trigger.Data(),
1422 ppsNN, ppTrigger.Data()));
1423 canvas->SetTitle(t.Data());
1425 ratios->Draw(Form(
"nostack %s", option));
1426 ratios->GetXaxis()->SetTitle(
"#eta");
1427 const char*
dNdeta =
"1/#it{N} d#it{N}_{ch}/d#it{#eta}";
1428 ratios->GetYaxis()->SetTitle(Form(
"#frac{%s|_{%s}}{%s|_{%s}}",
1429 dNdeta, tTgt.Data(), dNdeta, tpp.Data()));
1430 ratios->GetYaxis()->SetTitleOffset(1.5);
1431 if (outRatio && outRatio->GetHistogram()) {
1432 outRatio->GetHistogram()->SetXTitle(ratios->GetXaxis()->GetTitle());
1433 outRatio->GetHistogram()->SetYTitle(ratios->GetYaxis()->GetTitle());
1436 TMultiGraph* other =
GetOther(system, sNN, t1);
1437 TMultiGraph* ppOther =
GetOther(
"pp", ppsNN, ppTrigger);
1438 TMultiGraph* outOther = (write ?
new TMultiGraph(
"cen",
"") : 0);
1439 if (other && ppOther && ppOther->GetListOfGraphs()) {
1442 static_cast<TGraph*
>(ppOther->GetListOfGraphs()->At(0));
1446 outPP->Add(otherRef,
"p1");
1449 if (otherRef->IsA()->InheritsFrom(TGraphAsymmErrors::Class()))
1450 ErrorGraphs(static_cast<TGraphAsymmErrors*>(otherRef), dlow, dup);
1451 else if (otherRef->IsA()->InheritsFrom(TGraphErrors::Class()))
1452 ErrorGraphs(static_cast<TGraphErrors*>(otherRef), dlow, dup);
1457 TIter nextG(other->GetListOfGraphs());
1459 while ((g1 = static_cast<TGraph*>(nextG()))) {
1461 rg->SetLineColor(g1->GetLineColor());
1462 rg->SetLineStyle(g1->GetLineStyle());
1463 rg->SetFillColor(kBlue-10);
1464 rg->SetFillStyle(0);
1465 if (rg) rg->Draw(Form(
"p same %s", option));
1466 if (outOther) outOther->Add(rg,
"p1");
1468 g1->SetLineColor(g1->GetMarkerColor());
1469 outdNdeta->Add(g1,
"p");
1477 Warning(
"",
"No other data for %s,%d,%s",
1478 system.Data(),sNN,trigger.Data());
1479 if (outOther && outOther->GetHistogram()) {
1480 outOther->GetHistogram()->SetXTitle(ratios->GetXaxis()->GetTitle());
1481 outOther->GetHistogram()->SetYTitle(ratios->GetYaxis()->GetTitle());
1487 TFile* out = TFile::Open(Form(
"%s/%s.root",
PlotPrefix(),
1488 canvas->GetName()),
"RECREATE");
1505 if (!out.IsNull()) out.Append(
"_");
1516 if (!out.IsNull()) out.Append(
"_");
1517 out.Append(Form(
"%04d", sNN));
1535 const char** pSys = syss;
1537 const char** pTrg = trgS;
1538 const char* exps[] = {
"ALICE",
"CMS",
"WIP", 0 };
1540 while (*pSys) { nSys++;
Add2Out(out, *pSys); pSys++; }
1541 while (*pSNN) { nSNN++;
Add2Out(out, *pSNN); pSNN++; }
1542 while (*pTrg) { nTrg++;
Add2Out(out, *pTrg); pTrg++; }
1544 ::Warning(
"DrawAll",
"No systems specified");
1548 ::Warning(
"DrawAll",
"No energies specified");
1552 ::Warning(
"DrawAll",
"No triggers specified");
1556 if (nSys != 1 && nSNN != 1 && nTrg != 1) {
1557 ::Warning(
"DrawAll",
"At least one of sys (%d), sNN (%d), " 1558 "or trg (%d) must be singular", nSys, nSNN, nTrg);
1563 if (nSys == 1) { nHoriz = nSNN; }
1564 if (nSNN == 1) { nHoriz = nSys; }
1569 Bool_t collapse = (flags & 0x1);
1570 TCanvas*
c =
new TCanvas(
"all", out, nHoriz*500, nVert*500);
1571 c->SetTopMargin(0.01);
1572 c->SetRightMargin(0.01);
1574 c->Divide(nHoriz, nVert, 0, 0);
1576 c->Divide(nHoriz, nVert);
1582 const Double_t pp8000e[] = { 0.85, 0.93, 1, 0 };
1583 Double_t lw = (nSNN == 1 ? .6 : .83);
1584 Double_t ly1 = (nSNN == 1 ? .7 : .15);
1585 Double_t ly2 = (nSNN == 1 ? .95 : .35);
1592 TVirtualPad* q = c->cd(iPad++);
1594 if (pSys == syss && pSNN == sNNs) {
1596 leg =
new TLegend(lx1,
1598 leg->SetNColumns(nTrg == 1 ? 2 : nTrg);
1599 leg->SetFillColor(0);
1600 leg->SetFillStyle(0);
1601 leg->SetBorderSize(0);
1602 leg->SetTextColor(kAliceBlue);
1603 leg->SetTextFont(42);
1605 const Double_t* effs = ((((*pSys)[0] == (*pSys)[1]) && *pSNN == 8000)
1608 TPair* p =
GetDataOther(leg, unique, *pSys, *pSNN, trgS, exps,
1609 "e5",
true,
true, effs);
1611 Warning(
"",
"No data for pad %d", iPad-1);
1616 Warning(
"",
"No data for pad %d", iPad-1);
1620 THStack*
stack =
static_cast<THStack*
>(p->Key());
1622 if (nSNN == 1) stack->SetTitle(*pSys);
1623 if (nTrg == 1) stack->SetTitle(Form(
"%s - %s", *pSys, trgS[0]));
1625 Double_t lMax = lFac*stack->GetMaximum(
"nostack");
1626 stack->SetMaximum(lMax);
1627 stack->SetMinimum(.3);
1628 stack->Draw(
"nostack");
1629 stack->GetHistogram()->SetXTitle(
"#eta");
1630 stack->GetHistogram()->SetYTitle(
"1/#it{N} d#it{N}_{ch}/d#it{#eta}");
1631 max = TMath::Max(lMax, max);
1634 p->Value()->Draw(
"p");
1636 if (leg) leg->Draw();
1647 Int_t nPad = nHoriz * nVert;
1650 TIter iStack(&stacks);
1652 while ((stack = static_cast<THStack*>(iStack())))
1653 stack->SetMaximum(max);
1654 for (iPad = 1; iPad <= nPad; iPad++) {
1655 TVirtualPad* q = c->cd(iPad);
1665 u->SetUniqueID(nSNN == 1 ? kBlack : kRed+2);
1669 ly2 = TMath::Max(ly2,0.5);
1676 TVirtualPad* q = c->cd(nPad);
1677 q->SetRightMargin(0.01);
1681 c->SaveAs(Form(
"%s/%s.root",
PlotPrefix(), out.Data()));
1691 if (t.Contains(
"CENT")) {
1692 t.ReplaceAll(
"CENT",
"by centrality (");
1695 TString txt(Form(
"%s @ %s %s",
1696 system.Data(), e.Data(), t.Data()));
1697 TLatex* ltx =
new TLatex(x, y, txt);
1698 ltx->SetTextFont(42);
1715 TLegend* uleg =
new TLegend(x1, y1, x2, y2 );
1716 uleg->SetNColumns(1 );
1717 uleg->SetFillColor(0);
1718 uleg->SetFillStyle(0);
1719 uleg->SetBorderSize(0);
1720 uleg->SetTextColor(kAliceBlue);
1721 uleg->SetTextFont(42);
1727 TIter nextU(&unique);
1728 TLegendEntry* e = 0;
1731 e = uleg->AddEntry(
"dummy", u->GetName(), nSNN == 1 ?
"p" :
"f");
1732 e->SetMarkerStyle(u->GetVal());
1733 e->SetMarkerSize(1.7);
1734 e->SetMarkerColor(u->GetUniqueID());
1735 e->SetFillColor(u->GetUniqueID());
1736 e->SetFillStyle(1001);
1737 e->SetLineColor(kBlack);
1751 case 20:
return 1.6;
1752 case 21:
return 1.5;
1753 case 22:
return 1.7;
1755 ::Warning(
"",
"Marker style %d maps to default", style);
1760 if (isMult)
return Form(
"%3d",
Int_t(v));
1761 if ((
Int_t(v*100) % 100) == 0)
return Form(
"%3d%%",
Int_t(v));
1762 if ((
Int_t(v*100) % 10) == 0)
return Form(
"%5.1f%%", v);
1763 return Form(
"%6.2f%%", v);
1795 THStack*
stack =
new THStack(
"stack", stit.Data());
1801 TLegendEntry* e = 0;
1802 const char** ptrig = trigs;
1807 points.SetOwner(
false);
1809 if (!allT.IsNull()) allT =
",";
1810 allT.Append(*ptrig);
1813 Bool_t isCent = trg.BeginsWith(
"CENT");
1814 THStack* tmp =
GetStack(0, system, sNN, *ptrig,
1815 rebinned, empirical, isCent ? 20 : marker);
1817 Warning(
"",
"No data for %s %d %s", system.Data(), sNN, *ptrig);
1823 Double_t eff = (sNN == 8000 && peff ? *peff : 1);
1824 TList* lst = tmp->GetHists();
1827 while ((o = next())) {
1829 if (n.Contains(
"mirror"))
continue;
1830 TH1* h =
static_cast<TH1*
>(o->Clone());
1832 Color_t cOld = h->GetMarkerColor();
1834 h->SetMarkerColor(
Brighten(h->GetMarkerColor()));
1835 h->SetFillColor(
Brighten(h->GetFillColor()));
1836 h->SetLineColor(
Brighten(h->GetLineColor()));
1837 Printf(
"%s: old=%d new=%d real=%d",n.Data(),
1838 cOld,cNew,h->GetMarkerColor());
1842 if (n.Contains(
"SysError")) {
1844 fill = h->GetFillColor();
1845 style = h->GetFillStyle();
1846 TH1* hc =
static_cast<TH1*
>(h->Clone(Form(
"%s_syserror_C",*ptrig)));
1848 ha->SetName(Form(
"%s_syserror_A", *ptrig));
1849 for (
Int_t j = 1; j < h->GetNbinsX(); j++) {
1850 Double_t x = h->GetXaxis()->GetBinCenter(j);
1851 TH1* z = (x < 0 ? ha : hc);
1852 z->SetBinContent(j, 0);
1853 z->SetBinError(j, 0);
1856 stack->Add(ha, errOpt);
1857 stack->Add(hc, errOpt);
1860 if (!isCent) h->SetName(*ptrig);
1861 h->SetMarkerSize(
MarkerSize(h->GetMarkerStyle()));
1869 Int_t idx = ct.Index(
"cent");
1873 TString t1 = tokens->At(0)->GetName();
1874 TString t2 = tokens->At(1)->GetName();
1875 TString s1 = t1.Strip(TString::kLeading,
'0');
1876 TString s2 = t2.Strip(TString::kLeading,
'0');
1877 s1.ReplaceAll(
"d",
".");
1878 s2.ReplaceAll(
"d",
".");
1881 nm = Form(
"%s-%s", c1.Data(), c2.Data());
1892 e = leg->AddEntry(
"dummy", nm,
"pl");
1893 e->SetMarkerStyle(h->GetMarkerStyle());
1894 e->SetMarkerSize(h->GetMarkerSize());
1896 e->SetLineColor(h->GetLineColor());
1897 e->SetMarkerColor(h->GetMarkerColor());
1907 if (points.GetEntries() <= 0) {
1908 ::Warning(
"",
"No data for %s %d %s", system.Data(), sNN, allT.Data());
1914 leg->SetTextFont(42);
1917 if (
false && seSeen && leg) {
1918 e = leg->AddEntry(
"dummy",
"7.6% sys. error",
"f");
1919 e->SetFillColor(fill);
1920 e->SetFillStyle(style);
1921 leg->SetNColumns(leg->GetNColumns()+1);
1923 TIter nextP(&points);
1925 while ((data = static_cast<TH1*>(nextP())))
1928 stack->SetMaximum(1.2*stack->GetMaximum(
"nostack"));
1929 stack->SetMinimum(.3);
1934 TMultiGraph* other =
new TMultiGraph(
"others",
"Others");
1937 const char** pexp = exps;
1939 Bool_t isCent = (trg.BeginsWith(
"CENT"));
1942 if (ptrig == trigs) {
1943 if (!allE.IsNull()) allE.Append(
",");
1946 Info(
"",
"System=%s sNN=%d Trigger=%s Exp=%s", system.Data(),
1947 sNN, *ptrig, *pexp);
1948 TMultiGraph* mg =
GetOther(system, sNN, *ptrig, *pexp, verbose);
1953 TIter nextG(mg->GetListOfGraphs());
1955 while ((g = static_cast<TGraph*>(nextG()))) {
1959 g->SetMarkerStyle(marker);
1963 Color_t cOld = g->GetMarkerColor();
1965 g->SetMarkerColor(
Brighten(g->GetMarkerColor()));
1966 g->SetFillColor(
Brighten(g->GetFillColor()));
1967 g->SetLineColor(
Brighten(g->GetLineColor()));
1968 Printf(
"%s: old=%d new=%d real=%d",g->GetName(),
1969 cOld,cNew,g->GetMarkerColor());
1972 if (ut.BeginsWith(
"PWG-UD/MULT - "))
1973 ut =
"PWG-UD/MULT - work in progress";
1975 if (unique.FindObject(ut))
continue;
1978 u->SetUniqueID(isCent ?
Int_t(kBlack) : g->GetMarkerColor());
1988 !other->GetListOfGraphs() ||
1989 other->GetListOfGraphs()->GetEntries() < 0) {
1990 ::Warning(
"",
"No data for %s %d %s %s",
1991 system.Data(), sNN, allT.Data(), allE.Data());
1992 if (other)
delete other;
1996 ret =
new TPair(stack, other);
static const char * CentLimitName(Bool_t isMult, Float_t v)
static TPair * GetDataOther(TLegend *leg, TObjArray &unique, const TString &system, UShort_t sNN, const char **trigs, const char **exps, Option_t *errOpt="e5", Bool_t rebinned=false, Bool_t empirical=true, const Double_t *effs=0)
static TString SNNString(const TString &system, UShort_t sNN)
static Double_t * FixTriggerEff(const TString &sys, UShort_t sNN, TString &trigger)
static void Export(const TString &system, UShort_t sNN, const TString &trigger, Bool_t rebinned=false, Bool_t empirical=true)
static Int_t FindCentBin(Color_t c)
Final Calculate(const_iterator &begin, const_iterator &end, unsigned short nIter=50)
static void Draw(const TString &system, UShort_t sNN, const TString &trigger, const Option_t *option="e3", Bool_t rebinned=true, Bool_t empirical=true)
static Int_t AlicePurple()
static void Add2Out(TString &out, const char *what)
static void DrawAll(const char **syss, UShort_t *sNNs, const char **trgS, UShort_t flags=0x0)
static TGraphErrors * H2G(TH1 *h, Double_t xOff, Int_t sign=1)
static TH1 * HOverG(const TH1 *h, const TGraph *g, const TGraph *l, const TGraph *u, Bool_t err=false)
static TLatex * MakeTitle(Double_t x, Double_t y, const TString &system, UShort_t sNN, const TString &trigger)
List::const_iterator const_iterator
static THStack * GetStack(TLegend *legend, const TString &system, UShort_t sNN, const TString &trigger, Bool_t rebinned=true, Bool_t empirical=true, Int_t marker=20)
static TGraph * GOverG(const TGraph *num, const TGraph *den, const TGraph *dlow, const TGraph *dup, Double_t dx=0)
static TGraphAsymmErrors * Combine(TMultiGraph *mg)
static void ErrorGraphs(const TGraph *g, TGraph *&low, TGraph *&up)
static void ErrorGraphs(const TGraphErrors *g, TGraph *&low, TGraph *&up)
static TGraphAsymmErrors * H2GA(TH1 *h, TH1 *sA, TH1 *sC)
static TH1 * ErrorHist(const TH1 *h, Bool_t aSide, Double_t factor=0.076)
static TMultiGraph * GetOther(const TString &system, UShort_t sNN, const TString &trigger, Int_t verbose=0)
static void pPbSym(const TString &trigger, const Option_t *option="e3", Bool_t rebinned=true, Bool_t empirical=true)
static TMultiGraph * GetOther(UShort_t sys, UShort_t sNN, UShort_t trg, UShort_t exps=0xf, Int_t verbose=3)
static void Add2Out(TString &out, UShort_t sNN)
static THStack * Symmetrice(THStack *s)
static Float_t MarkerSize(Int_t style)
static Color_t Brighten(Color_t origNum, Int_t nTimes=2)
static void AddSystematics(THStack *stack, Double_t sys)
static void ScaleBypp(const TString &system, UShort_t sNN, UShort_t ppsNN, const TString &trigger, const TString &ppTrigger, Double_t etaShift=0, Bool_t rebinned=true, Bool_t empirical=true, Bool_t write=false)
static TMultiGraph * GetOther(const TString &system, UShort_t sNN, const TString &trigger, const TString &exps, Int_t verbose=0)
static void PrintCanvas(TCanvas *canvas, const TString &types)
static const char * PlotPrefix()
static THStack * Symmetrice(THStack *s1, THStack *s2)
static void SymScaleBypp(UShort_t ppsNN, const TString &trigger, const TString &ppTrigger, const Option_t *option="e2", Bool_t rebinned=true, Bool_t empirical=true, Bool_t write=false)
static Int_t AliceYellow()
static TCanvas * MakeCanvas(const TString &system, UShort_t sNN, const TString &trigger, Bool_t rebinned=true, Bool_t empirical=true)
static TLegend * MakeUniqueLegend(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TObjArray &unique, Int_t nSNN)
static void ErrorGraphs(const TGraphAsymmErrors *g, TGraph *&low, TGraph *&up)
void Add(const Result &r)
static TLegend * MakeUniqueLegend(TLegend *uleg, TObjArray &unique, Int_t nSNN)