11 #ifndef ALITRACKLETDNDETA_H 12 #define ALITRACKLETDNDETA_H 21 #include <TParameter.h> 24 #include <TLegendEntry.h> 27 #include <TGraphAsymmErrors.h> 29 #include <TFitResult.h> 32 #include <TProfile2D.h> 180 const char* shortTitle=
"page",
335 const char* sub,
TH2*& scaleH,
412 const char*
ObsTitle()
const {
return "d#it{N}_{ch}/d#eta"; }
473 const char* newName);
552 Color_t
color=kBlack,
572 THStack*
stack=0, TDirectory* out=0,
588 const char* dataName =
"data.root",
589 const char* simName =
"sim.root",
590 const char* output = 0);
601 void Run(
const char* proc,
603 const char* dataName =
"data.root",
604 const char* simName =
"sim.root",
605 const char* output = 0,
636 save = gErrorIgnoreLevel;
637 gErrorIgnoreLevel = lvl;
641 gErrorIgnoreLevel = save;
652 fTop->SetFillStyle(1001);
653 fTop->SetBorderSize(0);
654 fTop->SetBorderMode(0);
658 fBody->SetFillColor(0);
659 fBody->SetFillStyle(0);
660 fBody->SetBorderSize(0);
661 fBody->SetBorderMode(0);
662 fBody->SetTopMargin(0.01);
663 fBody->SetRightMargin(0.01);
664 fBody->SetBottomMargin(0.10);
665 fBody->SetLeftMargin(0.10);
673 gStyle->SetOptStat(0);
674 gStyle->SetOptTitle(0);
677 Int_t w = h / TMath::Sqrt(2);
684 fCanvas =
new TCanvas(
"c",outputName,w,h);
691 fCanvas->Print(Form(
"%s.pdf[", outputName.Data()),
692 Form(
"pdf %s", (
fViz & kLandscape) ?
"Landscape" :
""));
695 gSystem->mkdir(outputName.Data(),1);
698 fCanvas->SetRightMargin (0.05);
700 fCanvas->SetBottomMargin(0.10);
703 fTop =
new TPad(
"top",
"Top",0,1-dy,1,1,0,0);
711 fBody =
new TPad(
"body",
"Body",0,0,1,1-dy,0,0);
722 fHeader =
new TLatex(.5, .5,
"Title");
737 Form(
"pdf %s Title:%s",
740 Printf(
"PDF %s written",
fCanvas->GetTitle());
748 const char* shortTitle,
751 static Int_t cnt = 0;
755 fHeader->DrawLatex(.5,.5,title);
763 tit.Form(
"pdf %s Title:%s", (
fViz &
kLandscape) ?
"Landscape" :
"", title);
770 fCanvas->Print(Form(
"%s/%03d_%s.png",
fCanvas->GetTitle(), shortTitle));
778 TFile*
file = TFile::Open(filename,
"READ");
780 Warning(
"OpenFile",
"Failed to open \"%s\"", filename);
794 h->SetMarkerColor(color);
795 h->SetMarkerStyle(marker);
796 h->SetMarkerSize(size);
797 h->SetFillColor(color);
798 h->SetFillStyle(fill);
799 h->SetLineColor(color);
800 h->SetLineStyle(line);
801 h->SetLineWidth(width);
802 h->GetXaxis()->SetNdivisions(210);
803 h->GetYaxis()->SetNdivisions(210);
817 TVirtualPad* p = c->cd(pad);
820 if (option.Contains(
"logx")) { p->SetLogx(); option.ReplaceAll(
"logx",
""); }
821 if (option.Contains(
"logy")) { p->SetLogy(); option.ReplaceAll(
"logy",
""); }
822 if (option.Contains(
"logz")) { p->SetLogz(); option.ReplaceAll(
"logz",
""); }
823 if (option.Contains(
"grid")) { p->SetGridx(); p->SetGridy();
824 option.ReplaceAll(
"grid",
""); }
826 if (option.Contains(
"leg2")) { leg = 2; option.ReplaceAll(
"leg2",
""); }
827 if (option.Contains(
"leg")) { leg = 1; option.ReplaceAll(
"leg",
""); }
830 l = p->BuildLegend(0.5, 0.73, .98, .98);
833 TIter next(l->GetListOfPrimitives());
834 TLegendEntry* ent = 0;
835 while ((ent = static_cast<TLegendEntry*>(next()))) {
836 if (
TString(ent->GetLabel()).EqualTo(
"frame")) frame = ent;
838 if (frame) l->GetListOfPrimitives()->Remove(frame);
851 TLatex* ln =
new TLatex(.49, y, name);
852 ln->SetTextAlign(31);
853 ln->SetTextSize(0.02/gPad->GetHNDC());
856 TLatex* lv =
new TLatex(.51, y, val);
857 lv->SetTextAlign(11);
858 lv->SetTextSize(0.02/gPad->GetHNDC());
861 y -= 0.025/gPad->GetHNDC();
891 TLatex* latex =
new TLatex(.5, y, title);
892 latex->SetTextAlign(21);
893 latex->SetTextSize(0.023/gPad->GetHNDC());
896 y -= 0.028/gPad->GetHNDC();
899 DrawParam(
"Shifted #delta#phi cut",y,
GetD(pars,
"ShiftedDPhiCut"));
905 DrawParam(
"Background method", y, comb ?
"Combinatorics" :
"Injected");
911 fBody->Divide(1,3,0,0);
914 TVirtualPad* p1 =
fBody->GetPad(1); p1->SetPad(0,1-yr,1,1);
915 TVirtualPad* p2 =
fBody->GetPad(2); p2->SetPad(0,(1-yr)/2,1,1-yr);
916 TVirtualPad* p3 =
fBody->GetPad(3); p3->SetPad(0,0,1,(1-yr)/2);
921 TLatex* latex =
new TLatex(.5, y,
"Post-processing");
922 latex->SetTextAlign(21);
923 latex->SetTextSize(0.023/p1->GetHNDC());
926 y -= 0.028/p1->GetHNDC();
933 DrawParam(
"Scaling of comb. bg.", y, scaleM);
953 l->SetX1(px1+(px2-px1)*x1);
954 l->SetX2(px1+(px2-px1)*x2);
955 l->SetY1(py1+(py2-py1)*y1);
956 l->SetY2(py1+(py2-py1)*y2);
968 THStack*
stack =
new THStack(name, title);
969 TH1* real =
CopyH1(realList, name, Form(
"real%s",name));
970 TH1* sim =
CopyH1(simList, name, Form(
"sim%s",name));
971 real->SetMarkerStyle(20);
972 sim ->SetMarkerStyle(24);
973 real->SetFillStyle(3004);
974 sim ->SetFillStyle(3005);
975 real->SetBarWidth(0.4);
976 sim ->SetBarWidth(0.4);
977 real->SetBarOffset(0.1);
978 sim ->SetBarOffset(0.5);
979 TString dtit(real->GetTitle());
980 if (dtit.Contains(
"\\")) dtit.Form(
"%s\\hbox{ - real}", real->GetTitle());
981 else dtit.Form(
"%s - real", real->GetTitle());
982 real->SetTitle(dtit);
984 if (stit.Contains(
"\\")) stit.Form(
"%s\\hbox{ - sim.}", sim->GetTitle());
985 else stit.Form(
"%s - sim.", sim->GetTitle());
987 stack->Add(real, realOpt);
988 stack->Add(sim, simOpt);
996 THStack* ipz =
Make2Stack(
"ipz",
"IP_{#it{z}}", realList,simList);
997 THStack* cent =
Make2Stack(
"cent",
"Centrality [%]", realList,simList);
998 THStack* status =
Make2Stack(
"status",
"Task status", realList,simList,
999 "B text90",
"B text90");
1000 THStack* centTr =
Make2Stack(
"centTracklets",
"#LTtracklets#GT",
1001 realList, simList,
"E",
"E");
1004 for (
Int_t i = 1; i <= 3; i++) {
1005 if (i < 3)
fBody->GetPad(i)->SetRightMargin(0.01);
1006 fBody->GetPad(i)->SetTopMargin(0.01);
1009 TVirtualPad* q =
fBody->GetPad(1);
1015 q =
fBody->GetPad(2);
1017 l =
DrawInPad(q,1,status,
"nostack hist text90 leg");
1018 ModLegend(q->GetPad(1),l,.5,.7,.99,.99);
1019 l =
DrawInPad(q,2,centTr,
"nostack leg");
1020 ModLegend(q->GetPad(2),l,.5,.7,.99,.99);
1022 TH2* real =
GetH2(realList,
"etaPhi");
1023 TH2* sim =
GetH2(simList,
"etaPhi");
1025 sim->SetMarkerColor(kBlack);
1026 sim->SetMarkerStyle(0);
1027 sim->SetMarkerSize(1);
1028 sim->SetLineColor(kBlack);
1029 sim->SetFillColor(kBlack);
1030 sim->SetFillStyle(0);
1031 sim->SetName(
"simEtaPhi");
1040 void SetCentColors(THStack* s)
1042 if (!s->GetHists())
return;
1044 const Color_t
cc[] = { kMagenta+2,
1055 TIter next(s->GetHists());
1060 while ((h = static_cast<TH1*>(next()))) {
1061 Color_t
c = cc[i % 10];
1062 h->SetMarkerColor(c);
1065 h->SetMarkerStyle(20+(i%4));
1066 min = TMath::Min(h->GetMinimum(), min);
1067 max = TMath::Max(h->GetMaximum(), max);
1070 s->SetMinimum(min*.9);
1071 s->SetMaximum(max*1.1);
1078 THStack* s =
new THStack(name,
"");
1081 while ((h = static_cast<TH1*>(n()))) s->Add(h);
1095 THStack*
ef =
new THStack(
GetP2(simList,
"etaWeight"),
"x",
"effWeights",
"");
1096 THStack* pt =
new THStack(
GetH2(w,
"centPt"),
"y",
"pt",
"");
1097 THStack* ab = GetPdgStack(w,
"abundance");
1098 THStack* st = GetPdgStack(w,
"strangeness");
1107 TVirtualPad* p3 =
fBody->GetPad(3);
1121 if (!ress)
return 0;
1125 TObjString*
dir = 0;
1126 while ((dir = static_cast<TObjString*>(next()))) {
1127 subCont =
GetC(ress, dir->GetName());
1128 if (!subCont)
break;
1131 if (subCont) ret =
GetH1(subCont, name);
1140 if (!ress)
return 0;
1143 if (!subCont)
return 0;
1145 TH1* h =
CopyH1(subCont, scaled ?
"scaledDelta" :
"delta");
1158 if (!realList || !simList)
return 0;
1161 if (!simSub)
return 0;
1163 TH3* h =
GetH3(simSub,
"etaDeltaIPz");
1166 Info(
"",
"Scaled histogram not found, making it");
1168 if (!realSub)
return 0;
1174 scale =
RatioE(realV,realE,simV,simE,scaleE);
1175 Info(
"",
"integrated scalar: %5.3f +/- %5.3f", scale, scaleE);
1177 scaleH =
CopyH2(realSub,
"etaIPzDeltaTail");
1178 scaleH->SetDirectory(0);
1179 scaleH->SetName(
"scale");
1180 scaleH->SetZTitle(
"k_{I,#eta,IP_{#it{z}}}");
1181 scaleH->SetTitle(Form(
"%5.3f#times#eta,IP_{#it{z}} scalar",scale));
1182 scaleH->Divide(
GetH2(simSub,
"etaIPzDeltaTail"));
1184 Printf(
"Scaling %s/%s by %s - %5.3f", h->GetName(), h->GetTitle(),
1185 scaleH->GetName(), scale);
1191 TH1* ret =
CopyH1(simSub,
"delta",
"scaledDelta");
1192 Scale(ret, scale, scaleE);
1194 ret->SetName(
"scaledDelta");
1195 ret->SetTitle(Form(
"%5.3f#times%s", scale, h->GetTitle()));
1203 fBody->Divide(1,3,0,0);
1204 fBody->GetPad(1)->SetRightMargin(0.01);
1205 fBody->GetPad(2)->SetRightMargin(0.01);
1206 fBody->GetPad(3)->SetRightMargin(0.01);
1216 THStack* orig =
new THStack(
"orig",
"#Delta");
1217 orig->Add(rm =
FindDelta(realList,
"measured",
false));
1218 orig->Add(sm =
FindDelta(simList,
"measured",
false));
1219 orig->Add(ri =
FindDelta(realList,
"injected",
false));
1220 orig->Add(si =
FindDelta(simList,
"injected",
false));
1221 orig->Add(sc =
FindDelta(simList,
"combinatorics",
false));
1222 orig->Add(sp =
FindDelta(simList,
"primaries",
false));
1223 orig->Add(st =
FindDelta(simList,
"secondaries",
false));
1224 if (rm) {
SetAttr(rm, kRed+2, 20, 1); }
1225 if (ri) {
SetAttr(ri, kOrange+2, 21, 1); }
1226 if (sm) {
SetAttr(sm, kRed+2, 24, 1.3); }
1227 if (si) {
SetAttr(si, kOrange+2, 25, 1.3); }
1228 if (sc) {
SetAttr(sc, kGreen+2, 26); }
1229 if (sp) {
SetAttr(sp, kMagenta+2, 30); }
1230 if (st) {
SetAttr(st, kMagenta+2, 31); }
1234 THStack*
scaled =
new THStack(
"scaled",
"#Delta (scaled)");
1235 scaled->Add(rm =
FindDelta(realList,
"measured",
false));
1236 scaled->Add(sm =
FindDelta(realList, simList,
"measured",
1237 scaleH, scale, scaleE));
1238 scaled->Add(ri =
FindDelta(realList,
"injected",
true));
1242 si3->SetTitle(Form(
"%5.3f#times%s",scale,si3->GetTitle()));
1245 scaled->Add(si =
FindDelta(simList,
"injected",
true));
1247 Scale(si, scale, scaleE);
1248 si->SetTitle(Form(
"%5.3f#times%s",scale,si->GetTitle()));
1251 scaled->Add(sc =
FindDelta(realList, simList,
"combinatorics",
1252 scaleH, scale, scaleE));
1253 scaled->Add(sp =
FindDelta(realList, simList,
"primaries",
1254 scaleH, scale, scaleE));
1255 scaled->Add(st =
FindDelta(realList, simList,
"secondaries",
1256 scaleH, scale, scaleE));
1257 if (rm) {
SetAttr(rm, kRed+2, 20, 1); }
1258 if (ri) {
SetAttr(ri, kOrange+2, 21, 1); }
1259 if (sm) {
SetAttr(sm, kRed+2, 24, 1.3); }
1260 if (si) {
SetAttr(si, kOrange+2, 25, 1.3); }
1261 if (sc) {
SetAttr(sc, kGreen+2, 26); }
1262 if (sp) {
SetAttr(sp, kMagenta+2, 30); }
1263 if (st) {
SetAttr(st, kMagenta+2, 31); }
1265 Double_t max = 1.2*orig->GetMaximum(
"nostack");
1267 TH2* frame =
new TH2D(
"frame",
"",
1269 templ->GetXaxis()->GetXmin(),
1270 templ->GetXaxis()->GetXmax(),
1272 frame->SetXTitle(templ->GetXaxis()->GetTitle());
1273 frame->SetYTitle(templ->GetYaxis()->GetTitle());
1275 frame->SetDirectory(0);
1277 cuts->SetLineColor(kGreen+1);
1278 frame->GetListOfFunctions()->Add(cuts);
1280 cutt->SetLineColor(kRed+1);
1281 frame->GetListOfFunctions()->Add(cutt);
1284 TH1* f1 =
static_cast<TH1*
>(frame->Clone());
1285 f1->SetDirectory(0);
1289 fBody->GetPad(1)->GetLeftMargin(),
1290 fBody->GetPad(1)->GetBottomMargin(),
1294 TH1* f2 =
static_cast<TH1*
>(frame->Clone());
1295 f2->SetDirectory(0);
1299 fBody->GetPad(2)->GetLeftMargin(),
1300 fBody->GetPad(2)->GetBottomMargin(),
1303 THStack* ratios =
new THStack(
"ratios",
"");
1304 TH1* jm =
static_cast<TH1*
>(sm->Clone(
"rm"));
1306 jm->SetDirectory(0);
1307 jm->SetTitle(Form(
"%s / %s", sm->GetTitle(), rm->GetTitle()));
1309 TH1* ji =
static_cast<TH1*
>(si->Clone(
"sic"));
1311 ji->SetDirectory(0);
1312 ji->SetTitle(Form(
"%s / %s", si->GetTitle(), sc->GetTitle()));
1314 TH1* ki =
static_cast<TH1*
>(ri->Clone(
"ric"));
1316 ki->SetDirectory(0);
1317 ki->SetTitle(Form(
"%s / %s", ri->GetTitle(), sc->GetTitle()));
1321 fBody->GetPad(3)->GetLeftMargin(),
1322 fBody->GetPad(3)->GetBottomMargin(),
1326 Form(
"%s_delta", realList->GetName()));
1343 TH1* realIPz =
GetH1(realList,
"ipz");
1344 TH1* simIPz =
GetH1(simList,
"ipz");
1345 TH2* real2D =
GetH2(realMeasured,
"etaDelta");
1346 TH2* sim2D =
GetH2(simMeasured,
"etaDelta");
1351 TH2* realIE =
GetH2(realMeasured,
"etaIPzDeltaTail");
1352 TH2* simIE =
GetH2(simMeasured,
"etaIPzDeltaTail");
1353 TH2* scaleIE =
static_cast<TH2*
>(realIE->Clone(
"scaleIE"));
1354 scaleIE->Divide(simIE);
1355 scaleIE->SetDirectory(0);
1357 realD = realIE ->ProjectionX(
"realD");
1358 simD = simIE ->ProjectionX(
"simD");
1359 realD->SetDirectory(0);
1360 simD ->SetDirectory(0);
1365 realD =
GetH1(realMeasured,
"etaDeltaTail");
1366 simD =
GetH1(simMeasured,
"etaDeltaTail");
1369 realD =
GetH1(realInjected,
"etaDeltaTailRatio");
1370 simD =
GetH1(simInjected,
"etaDeltaTailRatio");
1374 Double_t realV = 1, realE = 0, simV = 1, simE = 0;
1377 realV =
GetD(realMeasured,
"deltaTail");
1378 realE =
GetD(realMeasured,
"deltaTailError");
1379 simV =
GetD(simMeasured,
"deltaTail");
1380 simE =
GetD(simMeasured,
"deltaTailError");
1383 realV =
GetD(realInjected,
"deltaTailRatio");
1384 realE =
GetD(realInjected,
"deltaTailRatioError");
1385 simV =
GetD(simInjected,
"deltaTailRatio");
1386 simE =
GetD(simInjected,
"deltaTailRatioError");
1392 realD =
Make1D(0,
"realD",
"Integral of tail", kBlack, 23,
1393 *real2D->GetXaxis());
1394 simD =
Make1D(0,
"simD",
"Integral of tail", kBlack, 23,
1395 *sim2D->GetXaxis());
1396 for (
Int_t i = 1; i <= realD->GetNbinsX(); i++) {
1397 realD->SetBinContent(i, realV);
1398 realD->SetBinError (i, realE);
1399 simD ->SetBinContent(i, simV);
1400 simD ->SetBinError (i, simE);
1403 scale =
static_cast<TH1*
>(realD->Clone(
"scale"));
1404 scale->Divide(simD);
1405 scale->SetFillStyle(0);
1407 if (!realD || !simD) {
1408 Warning(
"DrawScalars",
1409 "Real (%p) or simulated (%p) distribution not found",
1415 TVirtualPad* top =
fBody->GetPad(1);
1416 top->SetRightMargin(0.01);
1417 top->SetTopMargin(0.01);
1418 top->Divide(2,1,0,0);
1419 DrawInPad(top, 1, real2D,
"logy logz colz");
1420 DrawInPad(top, 2, sim2D,
"logy logz colz");
1422 TVirtualPad* bot =
fBody->GetPad(2);
1423 bot->SetRightMargin(0.01);
1424 bot->SetTopMargin(0.01);
1425 bot->Divide(1,2,0,0);
1426 bot->GetPad(1)->SetRightMargin(0.01);
1427 bot->GetPad(2)->SetRightMargin(0.01);
1428 THStack* ints =
new THStack(
"ints",
"");
1431 realD->SetMarkerStyle(20);
1432 simD ->SetMarkerStyle(24);
1433 realD->SetMarkerSize(1.5);
1434 simD ->SetMarkerSize(1.8);
1435 realD->SetMarkerColor(kRed+2);
1436 simD ->SetMarkerColor(kGreen+2);
1437 realD->SetLineColor(kRed+2);
1438 simD ->SetLineColor(kGreen+2);
1439 realD->SetFillStyle(0);
1440 simD ->SetFillStyle(0);
1443 TLegend* l =
DrawInPad(bot, 1, ints,
"nostack grid leg");
1445 TF1* ff =
new TF1(
"ff",
"pol0");
1446 ff->SetLineColor(kBlue+2);
1447 ff->SetLineStyle(2);
1448 scale->Fit(ff,
"Q0");
1449 scale->SetTitle(Form(
"#LTk#GT = %5.2f #pm %5.2f",
1450 ff->GetParameter(0), ff->GetParError(0)));
1454 ModLegend(bot->GetPad(1),l,.4,.1,.75,.4);
1457 Form(
"%s_scalar", realList->GetName()));
1472 const char** ptr = what;
1477 hists->AddAt(h, nHists);
1480 if (nme.EqualTo(
"beta")) h->SetMaximum(.7);
1481 if (nme.EqualTo(
"etaIPz") || nme.EqualTo(
"signal")) {
1482 max = TMath::Max(h->GetMaximum(), max);
1488 TVirtualPad* q = c->cd(pad);
1489 q->SetRightMargin(0.10);
1490 q->Divide(nHists,1,0,0);
1491 for (
Int_t i = 0; i < nHists; i++) {
1492 TH1* h =
static_cast<TH1*
>(hists->At(i));
1495 if (!nme.EqualTo(
"beta") && !nme.EqualTo(
"etaIPzScale"))
1499 TVirtualPad* r = q->GetPad(nHists);
1500 r->SetRightMargin(0.12);
1501 r->SetPad(r->GetXlowNDC(), r->GetYlowNDC(),
1502 .99, r->GetYlowNDC()+r->GetHNDC());
1504 TLatex* ltx =
new TLatex(.01,.5, pretty);
1506 ltx->SetTextFont(62);
1507 ltx->SetTextAngle(90);
1508 ltx->SetTextAlign(23);
1509 ltx->SetTextSize(0.07);
1520 const char* what[] = {
"etaIPz",
1527 fBody->SetLeftMargin(0.2);
1528 fBody->SetTopMargin(0.10);
1529 fBody->Divide(1,3,0,0);
1532 "injected", what,
"Injected - Real"));
1534 "injected", what,
"Injected - Sim."));
1536 "combinatorics", what,
"MC Labels"));
1538 for (i = 1; i <= 4; i++) {
1539 TVirtualPad* p =
fBody->GetPad(i);
1541 for (
Int_t j = 1; j <= 4; j++) {
1542 TVirtualPad* q = p->GetPad(j);
1543 TH1* h =
static_cast<TH1*
>(q->FindObject(
"raw"));
1548 h =
static_cast<TH1*
>(q->FindObject(
"bg"));
1549 if (h) h->SetMaximum(max/5);
1550 h =
static_cast<TH1*
>(q->FindObject(
"bgEta"));
1551 if (h) h->SetMaximum(max/5);
1555 const char* headings[] = {
"#it{I}, #it{I}', #it{C}'",
1556 "#scale[0.7]{#int}#Delta",
1562 const char** ptr = headings;
1565 TLatex* head =
new TLatex(
fBody->GetRightMargin()+
1566 (1-
fBody->GetRightMargin())/nCol*(i+.5),
1569 head->SetTextAlign(23);
1570 head->SetTextFont(62);
1571 head->SetTextSize(0.02);
1577 Form(
"%s_background", realList->GetName()));
1582 Printf(
"Content of %s - %s", h->GetName(), h->GetTitle());
1583 for (
Int_t i = 1; i <= h->GetNbinsX(); i++) {
1585 for (
Int_t j = 1; j <= h->GetNbinsY(); j++) {
1588 if (TMath::IsNaN(c) || TMath::IsNaN(e))
1589 printf(
"*** NAN ***");
1591 printf(
"%.*f+/-%.*f ", prec, c, prec, e);
1599 TH2* r =
static_cast<TH2*
>(h->Clone(
"fiducial"));
1602 r->SetTitle(
"Fiducial cut");
1603 for (
Int_t i = 1; i <= r->GetNbinsX(); i++) {
1604 for (
Int_t j = 1; j <= r->GetNbinsY(); j++) {
1606 if (c <= fAlphaMin || c >
fAlphaMax)
continue;
1607 r->SetBinContent(i,j,1);
1608 r->SetBinError (i,j,0);
1621 fBody->SetLeftMargin(0.2);
1622 fBody->SetRightMargin(0.01);
1623 fBody->SetTopMargin(0.01);
1624 fBody->Divide(1,2,0,0);
1626 TH2* alphaComb =
CopyH2(
GetC(simList,
"combinatorics"),
"alpha");
1635 fBody->GetPad(1)->SetRightMargin(0.15);
1636 fBody->GetPad(2)->SetRightMargin(0.15);
1640 TLatex* ltx =
new TLatex(.01,.5,
"Injection");
1642 ltx->SetTextFont(62);
1643 ltx->SetTextAngle(90);
1644 ltx->SetTextAlign(23);
1645 ltx->SetTextSize(0.07);
1648 ltx =
new TLatex(.01,.5,
"Combinatorics");
1650 ltx->SetTextFont(62);
1651 ltx->SetTextAngle(90);
1652 ltx->SetTextAlign(23);
1653 ltx->SetTextSize(0.07);
1657 Form(
"%s_alpha", realList->GetName()));
1664 case 0:
return (sim ? 24 : 20);
1665 case 1:
return (sim ? 24 : 20);
1666 case 2:
return (sim ? 25 : 21);
1667 case 3:
return (sim ? 26 : 22);
1668 default:
return (sim ? 5 : 2);
1672 case 0:
return (sim ? 25 : 21);
1673 case 1:
return (sim ? 28 : 34);
1674 case 2:
return (sim ? 27 : 33);
1675 case 3:
return (sim ? 30 : 29);
1677 return (sim ? 5 : 2);
1696 realD =
GetH2(realMeasured,
"etaIPzDeltaTail");
1697 simD =
GetH2(simMeasured,
"etaIPzDeltaTail");
1701 if (!realD || !simD) {
1702 Warning(
"GetCombiScale",
1703 "Real (%p) or simulated (%p) distribution not found",
1707 TH2* tmp2 =
static_cast<TH2*
>(realD->Clone(
"scale"));
1711 TF1* ff =
new TF1(
"ff",
"pol0");
1712 tmp->Fit(ff,
"QN0");
1713 scale->SetTitle(Form(
"#LTk#GT = %5.2f #pm %5.2f",
1714 ff->GetParameter(0), ff->GetParError(0)));
1722 realD =
GetH1(realMeasured,
"etaDeltaTail");
1723 simD =
GetH1(simMeasured,
"etaDeltaTail");
1726 realD =
GetH1(realInjected,
"etaDeltaTailRatio");
1727 simD =
GetH1(simInjected,
"etaDeltaTailRatio");
1729 if (!realD || !simD) {
1730 Warning(
"GetCombiScale",
1731 "Real (%p) or simulated (%p) distribution not found",
1735 scale =
static_cast<TH1*
>(realD->Clone(
"scale"));
1736 scale->Divide(simD);
1737 scale->SetFillStyle(0);
1738 TF1* ff =
new TF1(
"ff",
"pol0");
1739 scale->Fit(ff,
"QN0");
1740 scale->SetTitle(Form(
"#LTk#GT = %5.2f #pm %5.2f",
1741 ff->GetParameter(0), ff->GetParError(0)));
1750 realV =
GetD(realMeasured,
"deltaTail");
1751 realE =
GetD(realMeasured,
"deltaTailError");
1752 simV =
GetD(simMeasured,
"deltaTail");
1753 simE =
GetD(simMeasured,
"deltaTailError");
1756 realV =
GetD(realInjected,
"deltaTailRatio");
1757 realE =
GetD(realInjected,
"deltaTailRatioError");
1758 simV =
GetD(simInjected,
"deltaTailRatio");
1759 simE =
GetD(simInjected,
"deltaTailRatioError");
1761 s =
RatioE(realV,realE,simV,simE,sE);
1771 scale =
Make1D(0,
"scale",
1772 Form(
"k = %5.2f #pm %5.2f", s, sE),
1773 kBlack, 23, *h->GetXaxis());
1774 for (
Int_t i = 1; i <= scale->GetNbinsX(); i++) {
1775 scale->SetBinContent(i, s);
1776 scale->SetBinError (i, sE);
1779 scale->SetDirectory(0);
1781 Info(
"GetScaledCombi",
1782 "Scaling combinatorial background %s with %dD k %s",
1783 h->GetTitle(), scale->GetDimension(), scale->GetTitle());
1784 if (scale->GetDimension() == 2)
1801 return CopyH2(realInjected,
1803 "background" :
"backgroundEta",
1806 TH2* ret =
CopyH2(
GetC(simList,
"combinatorics"),
"background",
"realBg");
1820 return CopyH2(realInjected,
1828 TH2* one =
CopyH2(simComb,
"beta",
"one");
1830 for (
Int_t i = 1; i <= one->GetNbinsX(); i++)
1831 for (
Int_t j = 1; j <= one->GetNbinsY(); j++)
1832 one->SetBinContent(i,j,1);
1836 TH2* realSig =
CopyH2(
GetC(realList,
"measured"),
"etaIPz",
"realSig");
1837 realSig->SetMarkerStyle(beta->GetMarkerStyle());
1838 realSig->Multiply(one);
1844 const char* newName)
1848 (simComb ?
"combinatorics" :
"injected"));
1853 find.Format(
"%sEta", name);
1854 return CopyH2(cont, find, newName);
1870 Container* simBgC = simComb ? simCombC :
GetC(simList,
"injected");
1871 Container* realBgC = realComb ? simCombC :
GetC(realList,
"injected");
1875 TH2* realMeas =
CopyH2(realData,
"etaIPz",
"realMeas");
1876 TH1* realIPz =
CopyH1(realList,
"ipz",
"realIPz");
1879 if (!realMeas || !realSig || !realBg || !realIPz) {
1880 Warning(
"DrawdNdeta",
"One or more real data histograms missing: " 1881 "meas=%p sig=%p bg=%p ipz=%p", realMeas, realSig, realBg, realIPz);
1884 if (realBg ->GetMarkerStyle() == 30) realBg ->SetMarkerStyle(29);
1885 if (realBg ->GetMarkerStyle() == 27) realBg ->SetMarkerStyle(33);
1886 if (realSig->GetMarkerStyle() == 30) realSig->SetMarkerStyle(29);
1887 if (realSig->GetMarkerStyle() == 27) realSig->SetMarkerStyle(33);
1889 TH2* simMeas =
CopyH2(simData,
"etaIPz",
"simMeas");
1890 TH1* simIPz =
CopyH1(simList,
"ipz",
"simIPz");
1891 TH2* simBg =
GetSim(simList,
"background",
"simBg");
1892 TH2* simSig =
GetSim(simList,
"signal",
"simSig");
1893 TH2* alpha =
GetSim(simList,
"alpha",
"alpha");
1895 if (!simMeas || !simSig || !simBg || !simIPz || !alpha) {
1896 Warning(
"DrawdNdeta",
"One or more simuluated data histograms missing: " 1897 "meas=%p sig=%p bg=%p ipz=%p alpha=%p",
1898 simMeas, simSig, simBg, simIPz, alpha);
1901 alpha->Multiply(fiducial);
1902 TH2* trueGen =
CopyH2(
GetC(simList,
"generated"),
"etaIPz",
"trueGen");
1903 TH1* trueIPz =
CopyH1(simList,
"ipz",
"trueIPz");
1904 if (!trueGen || !trueIPz) {
1905 Warning(
"DrawdNdeta",
"One or more generator data histograms missing: " 1906 "gen=%p ipz=%p", trueGen, trueIPz);
1910 realMeas->SetTitle(
"Measured (real)");
1911 realBg ->SetTitle(
"Background (real)");
1912 realSig ->SetTitle(
"Signal (real)");
1913 realIPz ->SetTitle(
"IP_{z} (real)");
1914 simMeas ->SetTitle(
"Measured (simulated)");
1915 simBg ->SetTitle(
"Background (simulated)");
1916 simSig ->SetTitle(
"Signal (simulated)");
1917 simIPz ->SetTitle(
"IP_{z} (simulated)");
1918 trueGen ->SetTitle(
"Generated");
1919 trueIPz ->SetTitle(
"IP_{z} (generated)");
1922 TH2* result =
static_cast<TH2*
>(realSig->Clone(
"result"));
1923 result->SetTitle(
"Result");
1924 result->SetDirectory(0);
1925 result->Multiply(alpha);
1931 SetAttr(truth, color,
MS(0,
true,alt), 1.5, 0, 7, 1);
1936 SetAttr(dndeta, color,
MS(0,
false,alt), 1.2, 0, 1, 1);
1939 realMeas->Multiply(fiducial);
1940 simMeas ->Multiply(fiducial);
1941 realSig ->Multiply(fiducial);
1942 simSig ->Multiply(fiducial);
1943 realBg ->Multiply(fiducial);
1944 simBg ->Multiply(fiducial);
1945 realSig ->Multiply(fiducial);
1946 simSig ->Multiply(fiducial);
1955 SetAttr(realAvgMeas,realAvgMeas->GetMarkerColor(),
MS(1,
false,alt));
1956 SetAttr(realAvgSig, realAvgSig ->GetMarkerColor(),
MS(2,
false,alt));
1957 SetAttr(realAvgBg, realAvgSig ->GetMarkerColor(),
MS(3,
false,alt));
1958 SetAttr(simAvgMeas, simAvgSig ->GetMarkerColor(),
MS(1,
true, alt));
1959 SetAttr(simAvgSig, simAvgSig ->GetMarkerColor(),
MS(2,
true, alt));
1960 SetAttr(simAvgBg, simAvgBg ->GetMarkerColor(),
MS(3,
true, alt));
1961 realAvgMeas->SetYTitle(
"#LT M#GT");
1962 realAvgSig ->SetYTitle(
"#LT S#GT");
1963 realAvgBg ->SetYTitle(
"#LT B#GT");
1964 simAvgMeas ->SetYTitle(
"#LT M'#GT");
1965 simAvgSig ->SetYTitle(
"#LT S'#GT");
1966 simAvgBg ->SetYTitle(
"#LT B'#GT");
1969 THStack* summary =
new THStack(
"summary", dndeta->GetYaxis()->GetTitle());
1970 summary->Add(dndeta,
"e2");
1971 summary->Add(truth,
"e");
1972 summary->Add(realAvgMeas);
1973 summary->Add(simAvgMeas);
1974 summary->Add(realAvgSig);
1975 summary->Add(simAvgSig);
1976 summary->Add(realAvgBg);
1977 summary->Add(simAvgBg);
1979 if (scale->GetDimension() == 1) summary->Add(scale);
1988 fBody->SetLeftMargin(0.15);
1990 summary->GetHistogram()->SetXTitle(
"#eta");
1991 summary->GetHistogram()->SetYTitle(
ObsTitle());
1992 summary->GetHistogram()->GetYaxis()->SetTitleOffset(1.7);
1996 l->SetName(
"legend");
1998 l->SetBorderSize(0);
2001 TF1* f =
new TF1(
"ff",
"pol0", -lim, lim);
2002 TFitResultPtr r = dndeta->Fit(f,
"N0QSR",
"", -lim, lim);
2004 TLatex* ltx =
new TLatex(
fBody->GetLeftMargin()+
2005 (1-
fBody->GetLeftMargin()-
fBody->GetRightMargin())/2,
2007 Form(
"%s|_{|#eta|<%3.1f}" 2008 "=%6.1f#pm%6.1f (#chi^{2}/#nu=%5.2f)",
2010 r->ParError(0), r->Chi2()/r->Ndf()));
2011 ltx->SetTextAlign(22);
2013 ltx->SetTextFont(42);
2014 ltx->SetTextSize(0.035);
2016 printf(
"%6.1f +/- %6.1f (%5.2f)",
2017 r->Parameter(0), r->ParError(0), r->Chi2()/r->Ndf());
2018 summary->GetHistogram()->GetListOfFunctions()->Add(l);
2019 summary->GetHistogram()->GetListOfFunctions()->Add(ltx);
2022 if (summary->GetHistogram()->GetMinimum() < 1)
2023 summary->SetMinimum(1);
2024 summary->SetMaximum(1.5*summary->GetMaximum(
"nostack"));
2028 stack->Add(dndeta,
"e2");
2029 stack->Add(truth,
"e");
2038 if (scale) scale->Write();
2040 TDirectory* details = out->mkdir(
"details");
2051 GetH1(realData,
"delta") ->Write(
"realDataDelta");
2052 GetH1(
GetC(realList,
"injected"),
"delta")->Write(
"realInjDelta");
2053 GetH1(simData,
"delta") ->Write(
"simDataDelta");
2054 GetH1(
GetC(simList,
"injected"),
"delta") ->Write(
"simInjDelta");
2056 TDirectory* averages = out->mkdir(
"averages");
2058 realAvgMeas ->Write();
2059 realAvgSig ->Write();
2060 realAvgBg ->Write();
2061 simAvgMeas ->Write();
2062 simAvgSig ->Write();
2070 Form(
"%s_summary", realList->GetName()));
2078 THStack*
stack, TDirectory* out,
2081 fLastBin.Form(
"%5.1f%% - %5.1f%%", c1, c2);
2082 printf(
"Centrality bin %5.1f%% - %5.1f%%: ", c1, c2);
2084 name.Form(
"cent%03dd%02d_%03dd%02d",
2089 if (!realListBin || !simListBin) {
2090 Warning(
"PostBin",
"Missing bin for %5.1f%% - %5.1f%% (%s): %p %p",
2091 c1, c2, name.Data(), realListBin, simListBin);
2094 const Color_t
cc[] = { kMagenta+2,
2105 Color_t
color = (bin <= 0 ? cc[10] : cc[(bin-1)%11]);
2106 TDirectory* binOut = 0;
2108 if (out) binOut = out->mkdir(name);
2115 color, stack, binOut, alt);
2116 if (f && mid && bin > 0) {
2117 mid->SetBinContent(bin, f->GetParameter(0));
2118 mid->SetBinError (bin, f->GetParError (0));
2125 const char* dataName,
2126 const char* simName,
2127 const char* outName,
2135 if (v.Contains(
"pdf")) viz |=
kPDF;
2136 if (v.Contains(
"pau")) viz |=
kPause;
2137 if (v.Contains(
"gen")) viz |=
kGeneral;
2138 if (v.Contains(
"v.i")) viz |=
kWeights;
2141 if (v.Contains(
"del")) viz |=
kDeltas;
2143 if (v.Contains(
"alp")) viz |=
kAlphas;
2144 if (v.Contains(
"dnd")) viz |=
kdNdetas;
2147 if (p.Contains(
"fix")) proc |=
kScaleFix;
2151 if (p.Contains(
"clo")) proc |=
kClosure;
2154 Run(proc, viz, maxBins, dataName, simName, outName);
2159 const char* dataName,
2160 const char* simName,
2161 const char* outName)
2165 TFile* dataFile = 0;
2167 Printf(
"***************************************************\n" 2169 " Simulation file: %s\n" 2170 " Output file: %s\n",
2171 dataName, simName, outName);
2173 if (!(dataFile =
OpenFile(dataName)))
return;
2174 if (!(simFile =
OpenFile(simName)))
return;
2176 const char* base =
"MidRapidity";
2178 Container* realRess =
GetC(dataFile, Form(
"%sResults", base));
2180 Container* simRess =
GetC(simFile, Form(
"%sMCResults", base));
2181 if (!realSums || !realRess) {
2182 realSums =
GetC(dataFile, Form(
"%sMCSums", base));
2183 realRess =
GetC(dataFile, Form(
"%sMCResults", base));
2184 if (realSums && realRess)
2186 "*********************************************\n" 2187 "* Testing MC vs. MC: *\n" 2188 "* 'Data' file: %23s *\n" 2189 "* Simulation file: %23s *\n" 2190 "*********************************************\n",
2193 if (!realSums || !realRess || !simSums || !simRess)
return;
2201 if (outBase.IsNull()) outBase.Form(
"MiddNdeta_0x%04x",
fProc);
2202 if (outBase.EndsWith(
".root")) outBase.ReplaceAll(
".root",
"");
2209 TH1* realCent =
CopyH1(realSums,
"cent",
"realCent");
2210 TH1* simCent =
CopyH1(simSums,
"cent",
"simCent");
2211 TH1* realIPz =
GetH1(realSums,
"ipz");
2212 TH1* simIPz =
GetH1(simSums,
"ipz");
2215 Warning(
"Post",
"Centrality bins are incompatible, giving up");
2219 Warning(
"Post",
"Centrality bins are incompatible, giving up");
2226 ProcessBin(0, 0, 100, realRess, simRess, stack);
2228 TFile* out = TFile::Open(Form(
"%s.root", outBase.Data()),
"RECREATE");
2230 kBlack, 20, *(realCent->GetXaxis()));
2231 mid->SetDirectory(out);
2232 mid->SetXTitle(
"Centrality [%]");
2233 mid->SetYTitle(mid->GetTitle());
2236 for (
Int_t i = 1; i <= realCent->GetNbinsX() && i <= maxBins ; i++) {
2237 Double_t c1 = realCent->GetXaxis()->GetBinLowEdge(i);
2238 Double_t c2 = realCent->GetXaxis()->GetBinUpEdge (i);
2240 ProcessBin(i, c1, c2, realRess, simRess, stack, out, mid);
2246 if (stack->GetHists() && stack->GetHists()->GetEntries() > 0) {
2249 if (stack->GetHistogram()->GetMinimum() < 1)
2250 stack->SetMinimum(1);
2256 res = TFile::Open(
"result.root",
"READ");
2259 THStack* other =
GetHS(res,
"result");
2267 Printf(
"Results stored in %s", out->GetName());
Int_t color[]
print message on plot with ok/not ok
void DrawGeneral(Container *realList, Container *simList)
TLegend * DrawInPad(TVirtualPad *c, Int_t pad, TObject *o, Option_t *opt)
Style_t MS(Int_t what, Bool_t sim, Bool_t alt) const
TH2 * CutAlpha(TH2 *alpha)
void DrawAlpha(Container *realList, Container *simList)
void DrawParams(Container *pars, const char *title, Bool_t comb)
static TH1 * GetH1(Container *parent, const char *name, Bool_t verb=true)
static TH3 * ScaleDelta(TH3 *h, TH2 *scale)
Double_t fCombinatoricsScale
void PrintCanvas(const char *title, const char *shortTitle="page", Float_t size=.7)
static TH2 * ProjectEtaDelta(TH3 *h)
static TH1 * ProjectDelta(TH2 *h)
TH2 * GetRealSignal(Container *realList, Container *simList, TH1 *&scale)
static Double_t GetD(Container *parent, const char *name, Double_t def=-1, Bool_t verb=true)
static Bool_t CheckConsistency(const TH1 *h1, const TH1 *h2)
Double_t DrawBackground(TVirtualPad *c, Int_t pad, Container *ress, const char *name, const char **which, const char *pretty)
static TH1 * Scale(TH1 *h, Double_t x, Double_t xe)
void PrintH(TH2 *h, Int_t prec=2)
Utilities for midrapidity analysis.
TH1 * FindSub(Container *ress, const char *sub, const char *name)
TH1 * FindDelta(Container *ress, const char *sub, Bool_t scaled=false)
static TProfile2D * GetP2(Container *parent, const char *name, Bool_t verb=true)
void ModLegend(TVirtualPad *p, TLegend *l, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
TFile * OpenFile(const char *filename)
void DrawParam(const char *name, Double_t &y, const char *val)
const char * ObsTitle() const
TH2 * GetRealBackground(Container *realList, Container *simList, TH1 *&scale)
static TH2 * CopyH2(Container *parent, const char *name, const char *newName=0, Bool_t verb=true)
static TH1 * CopyH1(Container *parent, const char *name, const char *newName=0, Bool_t verb=true)
static TH1 * AverageOverIPz(TH2 *h, const char *name, UShort_t mode, TH1 *ipz, Double_t ipEff=0, TH2 *mask=0, Bool_t verb=false)
static TH3 * GetH3(Container *parent, const char *name, Bool_t verb=true)
static Double_t RatioE(Double_t n, Double_t en, Double_t d, Double_t ed, Double_t &er)
static TH2 * GetH2(Container *parent, const char *name, Bool_t verb=true)
void Run(UInt_t proc=kDefaultProc, UInt_t viz=kDefaultViz, UShort_t maxBins=9, const char *dataName="data.root", const char *simName="sim.root", const char *output=0)
TH2 * GetScaledCombi(TH2 *h, Container *realList, Container *simList, TH1 *&scale)
TF1 * DrawdNdeta(Container *realList, Container *simList, Color_t color=kBlack, THStack *stack=0, TDirectory *out=0, Bool_t alt=false)
static THStack * GetHS(Container *parent, const char *name, Bool_t verb=true)
void DrawWeights(Container *simList)
TFile * file
TList with histograms for a given trigger.
static Container * GetC(Container *parent, const char *name, Bool_t verb=true)
TH1 * SetAttr(TH1 *h, Color_t color, Style_t marker=20, Double_t size=1., Style_t fill=0, Style_t line=1, Width_t width=1)
TH2 * GetSim(Container *simList, const char *name, const char *newName)
void DrawScalars(Container *realList, Container *simList)
THStack * Make2Stack(const char *name, const char *title, Container *realList, Container *simList, Option_t *dataOpt="", Option_t *simOpt="")
static TH1 * Make1D(Container *c, const TString &name, const TString &title, Color_t color, Style_t style, const TAxis &xAxis)
void CreateCanvas(const TString &outputName)
void DrawDeltas(Container *realList, Container *simList)
void ProcessBin(Int_t bin, Double_t c1, Double_t c2, Container *realList, Container *simList, THStack *stack=0, TDirectory *out=0, TH1 *mid=0)