1188 int iMarkerStyle = 20;
1189 gStyle->SetFrameBorderMode(0);
1190 gStyle->SetFrameFillColor(0);
1191 gStyle->SetCanvasBorderMode(0);
1192 gStyle->SetPadBorderMode(0);
1193 gStyle->SetPadColor(0);
1194 gStyle->SetCanvasColor(0);
1195 gStyle->SetTitleColor(0);
1196 gStyle->SetStatColor(0);
1197 gStyle->SetFillColor(1);
1198 gStyle->SetPalette(1, 0);
1199 gStyle->SetTitleFontSize(0.06);
1200 gStyle->SetTitleH(0.06);
1201 gStyle->SetMarkerStyle(iMarkerStyle);
1202 gStyle->SetOptStat(111100);
1203 gStyle->SetStatBorderSize(0);
1204 gStyle->SetStatX(0.99);
1205 gStyle->SetStatY(0.99);
1206 gStyle->SetStatW(0.2);
1207 gStyle->SetStatH(0.1);
1213 TImage* img =
nullptr;
1217 std::string pathname(groupDir->GetPath());
1219 bool WasCollectionReference =
false;
1221 bool LookForDisplay;
1222 if (file_version == 1) {
1223 LookForDisplay =
containsDir(
"Config/annotations/display", (pathname +
"/" + nameHis +
"_"));
1224 if (LookForDisplay) {
1225 display =
getStringName(pathname +
"/" + nameHis +
"_/Config/annotations/display", file_version);
1227 }
else if (file_version == 2) {
1228 std::optional<std::string> JSON_content;
1229 LookForDisplay =
containsDir((nameHis +
"_"), pathname);
1230 if (LookForDisplay) {
1231 JSON_content =
containsKeyInJSON(
"/annotations/display",
"Config", (pathname +
"/" + nameHis +
"_"));
1233 LookForDisplay =
true;
1235 LookForDisplay =
false;
1238 if (LookForDisplay) {
1239 display = JSON_content.value();
1243 bool PlotOverflows = (
display.find(
"PlotUnderOverflow") != std::string::npos);
1246 std::string drawopt =
"";
1247 while (
found != std::string::npos) {
1248 std::size_t found1 =
display.find_first_of(
',',
found + 1);
1256 std::string drawrefopt =
"";
1257 while (
found != std::string::npos) {
1258 std::size_t found1 =
display.find_first_of(
',',
found + 1);
1264 if (drawrefopt ==
"") {
1265 drawrefopt = drawopt;
1269 std::string drawrefopt2D =
"";
1270 while (
found != std::string::npos) {
1271 std::size_t found1 =
display.find_first_of(
',',
found + 1);
1274 drawrefopt2D += temp;
1280 std::string datatitle;
1281 if (
found == std::string::npos) {
1284 while (
found != std::string::npos) {
1285 std::size_t found1 =
display.find_first_of(
',',
found + 1);
1286 if (found1 != std::string::npos) {
1294 TKey* hkey = groupDir->FindKey(nameHis.c_str());
1296 std::cerr <<
"Did not find TKey for \"" << nameHis <<
"\", will not save this histogram.\n";
1297 return std::pair<std::string, std::string>{
1302 TObject* hobj = hkey->ReadObj();
1305 TEfficiency* eRef(0);
1307 std::vector<TH1*> hRefs;
1308 std::vector<TEfficiency*> eRefs;
1309 bool hasPlotted(
false);
1310 TH1*
h =
dynamic_cast<TH1*
>(hobj);
1311 TH2* h2 =
dynamic_cast<TH2*
>(
h);
1312 TGraph*
g =
dynamic_cast<TGraph*
>(hobj);
1313 TEfficiency*
e =
dynamic_cast<TEfficiency*
>(hobj);
1315 std::string
name = nameHis;
1322 std::string AlgoName(
"");
1323 AlgoName =
getStringName(pathname +
"/" + nameHis +
"_/Config/name", file_version);
1327 if (
found != std::string::npos) {
1328 std::size_t found1 =
display.find_first_of(
',',
found + 1);
1334 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww,
wh);
1342 gPad->SetGridx(
display.find(
"SetGridx") != std::string::npos);
1343 gPad->SetGridy(
display.find(
"SetGridy") != std::string::npos);
1345 if (
found != std::string::npos) {
1346 std::size_t found1 =
display.find_first_of(
'(',
found + 1);
1347 std::size_t found2 =
display.find_first_of(
",)",
found + 1);
1348 std::string cn =
display.substr(found1 + 1, found2 - found1 - 1);
1349 int n1 = std::strtol(cn.c_str(), NULL, 0);
1350 gStyle->SetPalette((Int_t)
n1);
1353 if (
found != std::string::npos) {
1354 std::size_t found1 =
display.find_first_of(
'(',
found + 1);
1355 std::size_t found2 =
display.find_first_of(
",)",
found + 1);
1356 std::string cn =
display.substr(found1 + 1, found2 - found1 - 1);
1357 int n1 = std::strtol(cn.c_str(), NULL, 0);
1358 gStyle->SetGridStyle((Style_t)
n1);
1363 if (
found != std::string::npos) {
1364 Double_t minstat = 0.;
1365 std::size_t fpos1, fpos2, fpos;
1366 fpos =
display.find(
"MinStat");
1367 if (fpos != std::string::npos) {
1368 fpos1 =
display.find(
'(', fpos + 1);
1369 if (fpos1 != std::string::npos) {
1370 fpos2 =
display.find(
')', fpos1 + 1);
1371 if (fpos2 != std::string::npos) {
1372 std::string s_minstat =
display.substr(fpos1 + 1, fpos2 - fpos1 - 1);
1373 minstat = std::strtod(s_minstat.c_str(), NULL);
1377 std::string fitopt(
"");
1378 fpos =
display.find(
"FitOption");
1379 if (fpos != std::string::npos) {
1380 fpos1 =
display.find(
'(', fpos + 1);
1381 if (fpos1 != std::string::npos) {
1382 fpos2 =
display.find(
')', fpos1 + 1);
1383 if (fpos2 != std::string::npos) {
1384 fitopt =
display.substr(fpos1 + 1, fpos2 - fpos1 - 1);
1389 std::size_t found1 =
display.find(
"doublegaus");
1390 if (found1 != std::string::npos) {
1391 std::size_t found2 =
display.find(
'(', found1 + 1);
1392 if (found2 != std::string::npos) {
1393 std::size_t found3 =
display.find(
')', found2 + 1);
1394 if (found3 != std::string::npos) {
1395 std::string
range =
display.substr(found2 + 1, found3 - found2 - 1);
1396 Double_t
xmin = std::strtod(
range.c_str(), NULL);
1397 std::size_t found4 =
display.find(
',', found2 + 1);
1398 if (found4 != std::string::npos) {
1399 range =
display.substr(found4 + 1, found3 - found4 - 1);
1400 Double_t
xmax = std::strtod(
range.c_str(), NULL);
1404 f1->GetParameters(
par);
1405 TF1* func =
new TF1(
"func",
"gaus(0)+gaus(3)",
xmin,
xmax);
1406 func->SetParameters(
par);
1407 func->SetParameter(3,
h->GetBinContent(
h->GetMaximumBin()));
1408 func->SetParameter(4,
h->GetMean());
1409 func->SetParameter(5,
par[2]);
1410 func->SetLineColor(kRed);
1411 func->SetLineWidth(2);
1412 if (
h->GetEffectiveEntries() > minstat) {
1413 h->Fit(func, (
"rq" + fitopt).c_str());
1422 std::size_t found1 =
display.find(
"gauspluspol1");
1423 if (found1 != std::string::npos) {
1424 std::size_t found2 =
display.find(
'(', found1 + 1);
1425 if (found2 != std::string::npos) {
1426 std::size_t found3 =
display.find(
')', found2 + 1);
1427 if (found3 != std::string::npos) {
1428 std::string
range =
display.substr(found2 + 1, found3 - found2 - 1);
1429 Double_t
xmin = std::strtod(
range.c_str(), NULL);
1430 std::size_t found4 =
display.find(
',', found2 + 1);
1431 if (found4 != std::string::npos) {
1432 range =
display.substr(found4 + 1, found3 - found4 - 1);
1433 Double_t
xmax = std::strtod(
range.c_str(), NULL);
1434 TF1* func =
new TF1(
"func",
"gaus(0)+pol1(3)",
xmin,
xmax);
1435 func->SetLineColor(kRed);
1436 func->SetLineWidth(2);
1437 func->SetParameters(
h->GetBinContent(
h->GetMaximumBin()),
h->GetMean(),
h->GetRMS());
1438 if (
h->GetEffectiveEntries() > minstat) {
1439 h->Fit(func, (
"rq" + fitopt).c_str());
1447 found1 =
display.find(
"gausplusexpo");
1448 if (found1 != std::string::npos) {
1449 std::size_t found2 =
display.find(
'(', found1 + 1);
1450 if (found2 != std::string::npos) {
1451 std::size_t found3 =
display.find(
')', found2 + 1);
1452 if (found3 != std::string::npos) {
1453 std::string
range =
display.substr(found2 + 1, found3 - found2 - 1);
1454 Double_t
xmin = std::strtod(
range.c_str(), NULL);
1455 std::size_t found4 =
display.find(
',', found2 + 1);
1456 if (found4 != std::string::npos) {
1457 range =
display.substr(found4 + 1, found3 - found4 - 1);
1458 Double_t
xmax = std::strtod(
range.c_str(), NULL);
1460 TF1* func =
new TF1(
"func",
"gaus(0)+expo(3)",
xmin,
xmax);
1461 func->SetLineColor(kRed);
1462 func->SetLineWidth(2);
1463 func->SetParameters(
h->GetBinContent(
h->GetMaximumBin()),
h->GetMean(),
h->GetRMS());
1464 if (
h->GetEffectiveEntries() > minstat) {
1465 h->Fit(func, (
"rq" + fitopt).c_str());
1474 if (found2 != std::string::npos) {
1475 std::size_t found3 =
display.find(
')', found2 + 1);
1476 if (found3 != std::string::npos) {
1477 std::string
range =
display.substr(found2 + 1, found3 - found2 - 1);
1478 Double_t
xmin = std::strtod(
range.c_str(), NULL);
1479 std::size_t found4 =
display.find(
',', found2 + 1);
1480 if (found4 != std::string::npos) {
1481 range =
display.substr(found4 + 1, found3 - found4 - 1);
1482 Double_t
xmax = std::strtod(
range.c_str(), NULL);
1483 TF1* func =
new TF1(
"func",
"gaus",
xmin,
xmax);
1484 func->SetLineColor(kRed);
1485 func->SetLineWidth(2);
1486 if (
h->GetEffectiveEntries() > minstat) {
1487 h->Fit(func, (
"rq" + fitopt).c_str());
1500 if (h2->GetMinimum() >= 0 && h2->GetMaximum() > 0.) {
1501 gPad->SetLogy(
display.find(
"LogY") != std::string::npos);
1502 gPad->SetLogz(
display.find(
"LogZ") != std::string::npos);
1505 gPad->SetLogx(
display.find(
"LogX") != std::string::npos);
1507 if (
h->GetXaxis()->GetXmin() >=
h->GetXaxis()->GetXmax()) {
1508 std::cerr <<
"HanOutputFile::saveHistogramToFile(): "
1509 <<
"Inconsistent x-axis settings: min=" <<
h->GetXaxis()->GetXmin() <<
", "
1510 <<
"max=" <<
h->GetXaxis()->GetXmax() <<
", "
1511 <<
"Will not save this histogram.\n";
1512 return std::pair<std::string, std::string>{
1516 if (
h->GetYaxis()->GetXmin() >=
h->GetYaxis()->GetXmax()) {
1517 std::cerr <<
"HanOutputFile::saveHistogramToFile(): "
1518 <<
"Inconsistent y-axis settings: min=" <<
h->GetYaxis()->GetXmin() <<
", "
1519 <<
"max=" <<
h->GetYaxis()->GetXmax() <<
", "
1520 <<
"Will not save this histogram.\n";
1521 return std::pair<std::string, std::string>{
1526 if (drawopt ==
"") {
1530 if (file_version == 1) {
1531 groupDir->cd((nameHis +
"_/Results").c_str());
1533 }
else if (file_version == 2) {
1534 if (groupDir->GetDirectory((nameHis +
"_").c_str()) != 0) {
1535 groupDir->cd((nameHis +
"_").c_str());
1539 h2Ref =
dynamic_cast<TH2*
>(
ref);
1540 TCollection* colln =
dynamic_cast<TCollection*
>(
ref);
1542 h2Ref =
dynamic_cast<TH2*
>(colln->MakeIterator()->Next());
1544 if (h2Ref && (drawrefopt2D !=
"")) {
1546 h2Ref->Draw(drawrefopt2D.c_str());
1549 h2->Draw((
"SAME" + drawopt).c_str());
1551 if (drawopt.find(
"lego") == std::string::npos) {
1559 t.SetTextSize(0.03);
1560 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
1563 tt.SetTextSize(0.03);
1566 }
else if (
h != 0) {
1568 if (
display.find(
"StatBox") != std::string::npos) {
1571 if (
h->GetXaxis()->GetXmin() >=
h->GetXaxis()->GetXmax()) {
1572 std::cerr <<
"HanOutputFile::saveHistogramToFile(): "
1573 <<
"Inconsistent x-axis settings: min=" <<
h->GetXaxis()->GetXmin() <<
", "
1574 <<
"max=" <<
h->GetXaxis()->GetXmax() <<
", "
1575 <<
"Will not save this histogram.\n";
1576 return std::pair<std::string, std::string>{
1580 h->SetLineColor(kBlack);
1581 h->SetMarkerColor(1);
1588 if (file_version == 1) {
1589 groupDir->cd((nameHis +
"_/Results").c_str());
1591 }
else if (file_version == 2) {
1592 if (groupDir->GetDirectory((nameHis +
"_").c_str()) != 0) {
1593 groupDir->cd((nameHis +
"_").c_str());
1597 hRef =
dynamic_cast<TH1*
>(
ref);
1599 hRefs.push_back(hRef);
1601 TCollection* colln =
dynamic_cast<TCollection*
>(
ref);
1603 WasCollectionReference =
true;
1604 std::unique_ptr<TIterator> icolln(colln->MakeIterator());
1606 while ((ref2 = icolln->Next())) {
1607 hRef =
dynamic_cast<TH1*
>(ref2);
1609 if (hRef->GetDimension() ==
h->GetDimension()) {
1610 hRefs.push_back(hRef);
1612 }
else std::cout <<
"hRef cast failed!!!" << std::endl;
1619 if (hRefs.size() > 0) {
1620 legend =
new TLegend(0.55, 0.77, 0.87, 0.87);
1624 legend->SetBorderSize(0);
1625 legend->AddEntry(
h, datatitle.c_str());
1627 for (
auto hRef : hRefs) {
1633 hRef->SetMarkerColor(local_color);
1636 hRef->SetLineColor(local_color);
1637 hRef->SetLineWidth(2);
1638 double ymin = (hRef->GetMinimum() <
h->GetMinimum()) ? hRef->GetMinimum() :
h->GetMinimum();
1639 double ymax = (hRef->GetMaximum() >
h->GetMaximum()) ? hRef->GetMaximum() :
h->GetMaximum();
1641 if (PlotOverflows) {
1656 bool isLogY = (
display.find(
"LogY") != std::string::npos);
1662 h->SetAxisRange(
exp(lymin - (lymax - lymin) * 0.05),
exp(lymax + (lymax - lymin) * 0.05),
1665 std::cerr <<
"ymin is <0. and LogY requested for histogram \"" << pathname +
"/" + nameHis
1666 <<
"\", ymin=" <<
ymin << std::endl;
1669 double yMargin = (
ymax -
ymin) * 0.05;
1670 h->SetAxisRange(
ymin - yMargin,
ymax + yMargin,
"Y");
1672 h->GetXaxis()->SetRangeUser(
xmin,
xmax);
1673 hRef->GetXaxis()->SetRangeUser(
xmin,
xmax);
1675 if (
h->GetMinimum() >= 0. && hRef->GetMinimum() >= 0. &&
h->GetMaximum() > 0. &&
1676 hRef->GetMaximum() > 0.) {
1677 gPad->SetLogy(
display.find(
"LogY") != std::string::npos);
1680 gPad->SetLogx(
display.find(
"LogX") != std::string::npos);
1683 h->Draw(drawopt.c_str());
1686 hRef->Draw((
"SAME" + drawrefopt).c_str());
1689 if (
display.find(
"ScaleRef") != std::string::npos) {
1691 }
else if (
h->Integral(
"width") > 0.0 && hRef->Integral(
"width") > 0.0 &&
1692 (AlgoName.find(
"BinContentComp") == std::string::npos) &&
1693 (
display.find(
"NoNorm") == std::string::npos)) {
1694 scale =
h->Integral(
"width") / hRef->Integral(
"width");
1699 hRef->SetMarkerColor(local_color);
1701 hRef->SetLineColor(local_color);
1702 double ymin = (hRef->GetMinimum() <
h->GetMinimum()) ? hRef->GetMinimum() :
h->GetMinimum();
1703 double ymax = (hRef->GetMaximum() >
h->GetMaximum()) ? hRef->GetMaximum() :
h->GetMaximum();
1705 if (PlotOverflows) {
1722 bool isLogY = (
display.find(
"LogY") != std::string::npos);
1730 h->SetAxisRange(
exp(lymin - (lymax - lymin) * 0.05),
exp(lymax + (lymax - lymin) * 0.05),
"Y");
1733 std::cerr <<
"ymin is <=0. and LogY requested for histogram \"" << pathname +
"/" + nameHis
1734 <<
"\", ymin=" <<
ymin << std::endl;
1738 h->SetAxisRange(
ymin - yDiff * 0.05,
ymax + yDiff * 0.05,
"Y");
1741 h->GetXaxis()->SetRangeUser(
xmin,
xmax);
1742 hRef->GetXaxis()->SetRangeUser(
xmin,
xmax);
1744 if (
h->GetMinimum() >= 0 && hRef->GetMinimum() >= 0 &&
h->GetMaximum() > 0. && hRef->GetMaximum() > 0.) {
1745 gPad->SetLogy(
display.find(
"LogY") != std::string::npos);
1748 gPad->SetLogx(
display.find(
"LogX") != std::string::npos);
1752 h->Draw(drawopt.c_str());
1755 hRef->Draw((
"SAME" + drawrefopt).c_str());
1757 if (WasCollectionReference) {
1758 legend->AddEntry(hRef, hRef->GetName());
1760 std::string refInfo(
"");
1761 refInfo =
getStringName(pathname +
"/" + nameHis +
"_/Config/annotations/refInfo", file_version);
1762 legend->AddEntry(hRef, refInfo !=
"Undefined" ? refInfo.c_str() :
"Reference");
1765 h->Draw((
"SAME" + drawopt).c_str());
1769 if (
h->GetMinimum() >= 0) {
1770 gPad->SetLogy(
display.find(
"LogY") != std::string::npos);
1773 gPad->SetLogx(
display.find(
"LogX") != std::string::npos);
1776 h->Draw(drawopt.c_str());
1790 t.SetTextSize(0.03);
1791 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
1794 tt.SetTextSize(0.03);
1803 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww,
wh);
1805 if (
g->GetMinimum() >= 0. &&
g->GetMaximum() > 0.) {
1806 gPad->SetLogy(
display.find(
"LogY") != std::string::npos);
1814 g->Draw((std::string(
"AP") + drawopt).c_str());
1818 t.SetTextSize(0.03);
1819 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
1822 tt.SetTextSize(0.03);
1832 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww,
wh);
1834 if (drawopt ==
"") {
1835 if (
e->GetDimension() == 1) {
1842 if (file_version == 1) {
1843 groupDir->cd((nameHis +
"_/Results").c_str());
1845 }
else if (file_version == 2) {
1846 if (groupDir->cd((nameHis +
"_").c_str())) {
1850 eRef =
dynamic_cast<TEfficiency*
>(
ref);
1852 eRefs.push_back(eRef);
1854 TCollection* colln =
dynamic_cast<TCollection*
>(
ref);
1856 WasCollectionReference =
true;
1857 TIterator* icolln = colln->MakeIterator();
1859 while ((ref2 = icolln->Next())) {
1860 eRef =
dynamic_cast<TEfficiency*
>(ref2);
1862 if (eRef->GetDimension() ==
e->GetDimension()) {
1863 eRefs.push_back(eRef);
1865 }
else std::cout <<
"eRef cast failed!!!" << std::endl;
1871 if (eRefs.size() > 0) {
1872 legend =
new TLegend(0.55, 0.77, 0.87, 0.87);
1876 legend->SetBorderSize(0);
1877 legend->AddEntry(
e, datatitle.c_str());
1879 for (
auto eRef : eRefs) {
1889 eRef->SetMarkerColor(local_color);
1890 eRef->SetLineColor(local_color);
1893 e->Draw(drawopt.c_str());
1899 if (WasCollectionReference) {
1900 legend->AddEntry(eRef, eRef->GetName());
1902 std::string refInfo(
"");
1903 refInfo =
getStringName(pathname +
"/" + nameHis +
"_/Config/annotations/refInfo", file_version);
1904 legend->AddEntry(eRef, refInfo !=
"Undefined" ? refInfo.c_str() :
"Reference");
1910 e->Draw(drawopt.c_str());
1915 e->GetPaintedGraph()->GetXaxis()->SetTitleColor();
1921 t.SetTextSize(0.03);
1922 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
1925 tt.SetTextSize(0.03);
1932 if (
x)
rv.assign(
x,
y);
1935 std::pair<std::string, std::string> rvPair {