1183 bool drawRefs,
const std::string& run_min_LB,
1184 const std::string& pathName,
int cnvsType) {
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());
1218 std::string display =
"";
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);
1245 std::size_t found = display.find(
"Draw=");
1246 std::string drawopt =
"";
1247 while (found != std::string::npos) {
1248 std::size_t found1 = display.find_first_of(
',', found + 1);
1249 auto temp = display.substr(found + 5, found1 != std::string::npos ? found1 - found - 5 : display.size());
1250 std::ranges::transform(temp, temp.begin(), [](
unsigned char c) { return std::tolower(c); });
1252 found = display.find(
"Draw=", found + 1);
1255 found = display.find(
"DrawRef=");
1256 std::string drawrefopt =
"";
1257 while (found != std::string::npos) {
1258 std::size_t found1 = display.find_first_of(
',', found + 1);
1259 auto temp = display.substr(found + 8, found1 != std::string::npos ? found1 - found - 8 : display.size());
1260 std::ranges::transform(temp, temp.begin(), [](
unsigned char c) { return std::tolower(c); });
1262 found = display.find(
"DrawRef=", found + 1);
1264 if (drawrefopt ==
"") {
1265 drawrefopt = drawopt;
1268 found = display.find(
"DrawRef2D=");
1269 std::string drawrefopt2D =
"";
1270 while (found != std::string::npos) {
1271 std::size_t found1 = display.find_first_of(
',', found + 1);
1272 auto temp = display.substr(found + 10, found1 != std::string::npos ? found1 - found - 10 : display.size());
1273 std::ranges::transform(temp, temp.begin(), [](
unsigned char c) { return std::tolower(c); });
1274 drawrefopt2D += temp;
1275 found = display.find(
"DrawRef2D=", found + 1);
1279 found = display.find(
"DataName");
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) {
1287 datatitle += display.substr(found + 9, found1 - found - 9);
1289 datatitle += display.substr(found + 9, display.size());
1291 found = display.find(
"DataName", found + 1);
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);
1326 found = display.find(
"TCanvas", found + 1);
1327 if (found != std::string::npos) {
1328 std::size_t found1 = display.find_first_of(
',', found + 1);
1329 ww = std::atoi((display.substr(found + 8, found1 - found - 8)).c_str());
1330 found = display.find_first_of(
')', found1 + 1);
1331 wh = std::atoi((display.substr(found1 + 1, found - found1 - 1)).c_str());
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);
1344 std::size_t found = display.find(
"SetPalette");
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);
1352 found = display.find(
"SetGridStyle");
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);
1362 found = display.find(
"gaus");
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);
1401 TF1* f1 =
new TF1(
"f1",
"gaus",
xmin,
xmax);
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());
1473 std::size_t found2 = display.find(
'(', found + 1);
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());
1532 gDirectory->GetObject(
"Reference;1",
ref);
1533 }
else if (file_version == 2) {
1534 if (groupDir->GetDirectory((nameHis +
"_").c_str()) != 0) {
1535 groupDir->cd((nameHis +
"_").c_str());
1536 gDirectory->GetObject(
"Reference;1",
ref);
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) {
1554 if (h2Ref)
ratioplot2D(myC.get(), h2, h2Ref, display);
1559 t.SetTextSize(0.03);
1560 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
1563 tt.SetTextSize(0.03);
1564 tt.DrawLatex(0.02, 0.01, pathName.c_str());
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());
1590 gDirectory->GetObject(
"Reference;1",
ref);
1591 }
else if (file_version == 2) {
1592 if (groupDir->GetDirectory((nameHis +
"_").c_str()) != 0) {
1593 groupDir->cd((nameHis +
"_").c_str());
1594 gDirectory->GetObject(
"Reference;1",
ref);
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);
1621 legend->SetTextFont(62);
1622 legend->SetMargin(0.15);
1623 legend->SetFillStyle(0);
1624 legend->SetBorderSize(0);
1625 legend->AddEntry(
h, datatitle.c_str());
1627 for (
auto hRef : hRefs) {
1631 TProfile* pRef =
dynamic_cast<TProfile*
>(hRef);
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);
1660 double lymax = log(
ymax);
1661 double lymin = log(
ymin);
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) {
1690 scale = getScaleVal(display);
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);
1728 double lymax = log(
ymax);
1729 double lymin = log(
ymin);
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);
1795 tt.DrawLatex(0.02, 0.01, pathName.c_str());
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);
1823 tt.DrawLatex(0.02, 0.01, pathName.c_str());
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());
1844 gDirectory->GetObject(
"Reference;1",
ref);
1845 }
else if (file_version == 2) {
1846 if (groupDir->cd((nameHis +
"_").c_str())) {
1847 gDirectory->GetObject(
"Reference;1",
ref);
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);
1873 legend->SetTextFont(62);
1874 legend->SetMargin(0.15);
1875 legend->SetFillStyle(0);
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);
1926 tt.DrawLatex(0.02, 0.01, pathName.c_str());
1932 if (
x) rv.assign(
x,
y);
1935 std::pair<std::string, std::string> rvPair {
1947 TDirectory* groupDir1,
1948 TDirectory* groupDir2,
bool drawRefs,
1949 const std::string& run_min_LB,
const std::string& pathName,
1953 gStyle->SetFrameBorderMode(0);
1954 gStyle->SetFrameFillColor(0);
1955 gStyle->SetCanvasBorderMode(0);
1956 gStyle->SetPadBorderMode(0);
1957 gStyle->SetPadColor(0);
1958 gStyle->SetCanvasColor(0);
1959 gStyle->SetTitleColor(0);
1960 gStyle->SetStatColor(0);
1961 gStyle->SetFillColor(1);
1962 gStyle->SetPalette(1, 0);
1963 gStyle->SetTitleFontSize(0.06);
1964 gStyle->SetTitleH(0.06);
1965 gStyle->SetMarkerStyle(20);
1966 gStyle->SetOptStat(111100);
1967 gStyle->SetStatBorderSize(0);
1968 gStyle->SetStatX(0.99);
1969 gStyle->SetStatY(0.99);
1970 gStyle->SetStatW(0.2);
1971 gStyle->SetStatH(0.1);
1974 std::string pathname(groupDir1->GetPath());
1975 std::string display =
"";
1977 bool LookForDisplay;
1978 if (file_version == 1) {
1979 LookForDisplay =
containsDir(
"Config/annotations/display", (pathname +
"/" + nameHis +
"_"));
1980 if (LookForDisplay) {
1981 display =
getStringName(pathname +
"/" + nameHis +
"_/Config/annotations/display", file_version);
1983 }
else if (file_version == 2) {
1984 std::optional<std::string> JSON_content;
1985 LookForDisplay =
containsDir((nameHis +
"_"), pathname);
1986 if (LookForDisplay) {
1987 JSON_content =
containsKeyInJSON(
"/annotations/display",
"Config", (pathname +
"/" + nameHis +
"_"));
1989 LookForDisplay =
true;
1991 LookForDisplay =
false;
1994 if (LookForDisplay) {
1995 display = JSON_content.value();
2000 std::size_t found = display.find(
"Draw");
2001 std::string drawopt =
"";
2002 while (found != std::string::npos) {
2003 std::size_t found1 = display.find_first_of(
',', found + 1);
2004 auto temp = display.substr(found + 5, found1 != std::string::npos ? found1 - found - 5 : display.size() );
2005 std::ranges::transform(temp, temp.begin(), [](
unsigned char c) { return std::tolower(c); });
2007 found = display.find(
"Draw", found + 1);
2011 TKey* hkey = groupDir1->FindKey(nameHis.c_str());
2013 TKey* hkey2 = groupDir2->FindKey(nameHis.c_str());
2014 if (hkey == 0 || hkey2 == 0) {
2015 std::cerr <<
"Did not find TKey for \"" << nameHis <<
"\", will not save this histogram.\n";
2020 TObject* hobj = hkey->ReadObj();
2021 TObject* hobj2 = hkey2->ReadObj();
2023 TH1*
h(0), *hist2(0);
2024 TH2* h2(0), *h2_2(0), *h2Diff(0);
2025 TGraph* g(0), *g2(0);
2026 TEfficiency* e(0), *e2(0);
2029 std::string nameJSON = nameHis;
2030 std::string namePNG = nameHis;
2032 nameJSON +=
".json";
2033 std::string::size_type i = location.find_last_of(
'/');
2034 if (i != (location.size() - 1)) {
2037 namePNG = location + namePNG;
2038 nameJSON = location + nameJSON;
2039 std::string AlgoName =
getStringName(pathname +
"/" + nameHis +
"_/Config/name", file_version);
2042 found = display.find(
"TCanvas");
2043 if (found != std::string::npos) {
2044 std::size_t found1 = display.find_first_of(
',', found + 1);
2045 ww = std::atoi((display.substr(found + 8, found1 - found - 8)).c_str());
2046 found = display.find_first_of(
')', found1 + 1);
2047 wh = std::atoi((display.substr(found1 + 1, found - found1 - 1)).c_str());
2050 if ((
h =
dynamic_cast<TH1*
>(hobj)) != 0 && (hist2 =
dynamic_cast<TH1*
>(hobj2)) != 0) {
2051 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww, wh);
2057 std::string tmpdraw(drawopt);
2058 if ((h2 =
dynamic_cast<TH2*
>(
h)) != 0 && ((h2_2 =
dynamic_cast<TH2*
>(hist2)) != 0)) {
2060 h2Diff = (TH2*) h2->Clone(
"difference");
2071 h2Diff->Add(h2, h2_2, 1.0, -1.0);
2072 h2Diff->SetLineColor(2);
2073 h2Diff->SetMarkerColor(2);
2074 if (!
drawH2(myC.get(), h2Diff, tmpdraw, display))
return false;
2078 t.SetTextSize(0.03);
2079 t.DrawLatex(0.02, 0.04, (run_min_LB +
" difference").c_str());
2082 tt.SetTextSize(0.03);
2083 tt.DrawLatex(0.02, 0.01, pathName.c_str());
2086 }
else if (
h != 0 && hist2 != 0) {
2089 if (display.find(
"ScaleRef") != std::string::npos) {
2090 scale = getScaleVal(display);
2091 }
else if (
h->Integral(
"width") > 0.0 && hist2->Integral(
"width") > 0.0 &&
2092 (AlgoName.find(
"BinContentComp") == std::string::npos) &&
2093 (display.find(
"NoNorm") == std::string::npos)) {
2094 scale =
h->Integral(
"width") / hist2->Integral(
"width");
2096 hist2->Scale(scale);
2097 double ymin = (hist2->GetMinimum() <
h->GetMinimum()) ? hist2->GetMinimum() :
h->GetMinimum();
2098 double ymax = (hist2->GetMaximum() >
h->GetMaximum()) ? hist2->GetMaximum() :
h->GetMaximum();
2099 double yMargin = (
ymax -
ymin) * 0.05;
2100 h->SetAxisRange(
ymin - yMargin,
ymax + yMargin,
"Y");
2102 h->SetMarkerColor(1);
2105 hist2->SetMarkerColor(4);
2106 hist2->SetLineColor(4);
2107 hist2->SetFillStyle(0);
2108 hist2->SetLineWidth(2);
2110 if (file_version == 1) {
2111 groupDir1->cd((nameHis +
"_/Results").c_str());
2113 groupDir1->cd((nameHis +
"_").c_str());
2115 gDirectory->GetObject(
"Reference;1", hRef);
2118 if (!
drawH1(myC.get(),
h, hRef, tmpdraw, display, AlgoName))
return false;
2121 if (!
drawH1(myC.get(), hist2, 0, tmpdraw, display, AlgoName))
return false;
2123 legend =
new TLegend(0.55, 0.77, 0.87, 0.87);
2124 legend->SetTextFont(62);
2125 legend->SetMargin(0.15);
2126 legend->SetFillStyle(0);
2127 legend->SetBorderSize(0);
2129 std::size_t foundN1 = run_min_LB.find_first_of(
"-");
2130 std::size_t foundN2 = run_min_LB.find_first_of(
',');
2132 legend->AddEntry(
h, (
"Run " + run_min_LB.substr(5, foundN1 - 5)).c_str());
2133 legend->AddEntry(hist2, (
"Run " + run_min_LB.substr(foundN1 + 1, foundN2 - foundN1 - 1)).c_str());
2135 legend->AddEntry(hRef,
"Reference");
2141 t.SetTextSize(0.03);
2142 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
2145 tt.SetTextSize(0.03);
2146 tt.DrawLatex(0.02, 0.01, pathName.c_str());
2155 if (((g =
dynamic_cast<TGraph*
>(hobj)) != 0) && ((g2 =
dynamic_cast<TGraph*
>(hobj2)) != 0)) {
2156 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww, wh);
2158 if (g->GetMinimum() >= 0. && g2->GetMinimum() >= 0. && g->GetMaximum() > 0. && g2->GetMaximum() > 0.) {
2159 gPad->SetLogy(display.find(
"LogY") != std::string::npos);
2163 g->Draw((std::string(
"AP") + drawopt).c_str());
2165 g2->SetMarkerColor(2);
2166 g2->SetLineColor(2);
2167 g2->Draw((std::string(
"P") + drawopt +
" same").c_str());
2170 t.SetTextSize(0.03);
2171 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
2174 tt.SetTextSize(0.03);
2175 tt.DrawLatex(0.02, 0.01, pathName.c_str());
2182 if (((e =
dynamic_cast<TEfficiency*
>(hobj)) != 0) && ((e2 =
dynamic_cast<TEfficiency*
>(hobj2)) != 0)) {
2183 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww, wh);
2188 e->Draw((std::string(
"AP") + drawopt).c_str());
2192 e->GetPaintedGraph()->GetXaxis()->SetTitleColor();
2195 e2->SetMarkerColor(2);
2196 e2->SetLineColor(2);
2197 e2->Draw((std::string(
"P") + drawopt +
" same").c_str());
2200 t.SetTextSize(0.03);
2201 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
2204 tt.SetTextSize(0.03);
2205 tt.DrawLatex(0.02, 0.01, pathName.c_str());
2286 size_t found = display.find(
"gaus");
2288 if (found != std::string::npos) {
2289 Double_t minstat = 0.;
2290 std::size_t fpos1, fpos2, fpos;
2291 fpos = display.find(
"MinStat");
2292 if (fpos != std::string::npos) {
2293 fpos1 = display.find(
'(', fpos + 1);
2294 if (fpos1 != std::string::npos) {
2295 fpos2 = display.find(
')', fpos1 + 1);
2296 if (fpos2 != std::string::npos) {
2297 std::string s_minstat = display.substr(fpos1 + 1, fpos2 - fpos1 - 1);
2298 minstat = std::strtod(s_minstat.c_str(), NULL);
2302 std::string fitopt(
"");
2303 fpos = display.find(
"FitOption");
2304 if (fpos != std::string::npos) {
2305 fpos1 = display.find(
'(', fpos + 1);
2306 if (fpos1 != std::string::npos) {
2307 fpos2 = display.find(
')', fpos1 + 1);
2308 if (fpos2 != std::string::npos) {
2309 fitopt = display.substr(fpos1 + 1, fpos2 - fpos1 - 1);
2314 std::size_t found1 = display.find(
"doublegaus");
2315 if (found1 != std::string::npos) {
2316 std::size_t found2 = display.find(
'(', found1 + 1);
2317 if (found2 != std::string::npos) {
2318 std::size_t found3 = display.find(
')', found2 + 1);
2319 if (found3 != std::string::npos) {
2320 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
2321 Double_t
xmin = std::strtod(range.c_str(), NULL);
2322 std::size_t found4 = display.find(
',', found2 + 1);
2323 if (found4 != std::string::npos) {
2324 range = display.substr(found4 + 1, found3 - found4 - 1);
2325 Double_t
xmax = std::strtod(range.c_str(), NULL);
2326 TF1* f1 =
new TF1(
"f1",
"gaus",
xmin,
xmax);
2329 f1->GetParameters(par);
2330 TF1* func =
new TF1(
"func",
"gaus(0)+gaus(3)",
xmin,
xmax);
2331 func->SetParameters(par);
2332 func->SetParameter(3,
h->GetBinContent(
h->GetMaximumBin()));
2333 func->SetParameter(4,
h->GetMean());
2334 func->SetParameter(5, par[2]);
2335 func->SetLineColor(kRed);
2336 func->SetLineWidth(2);
2337 if (
h->GetEffectiveEntries() > minstat) {
2338 h->Fit(func, (
"rq" + fitopt).c_str());
2347 std::size_t found1 = display.find(
"gauspluspol1");
2348 if (found1 != std::string::npos) {
2349 std::size_t found2 = display.find(
'(', found1 + 1);
2350 if (found2 != std::string::npos) {
2351 std::size_t found3 = display.find(
')', found2 + 1);
2352 if (found3 != std::string::npos) {
2353 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
2354 Double_t
xmin = std::strtod(range.c_str(), NULL);
2355 std::size_t found4 = display.find(
',', found2 + 1);
2356 if (found4 != std::string::npos) {
2357 range = display.substr(found4 + 1, found3 - found4 - 1);
2358 Double_t
xmax = std::strtod(range.c_str(), NULL);
2359 TF1* func =
new TF1(
"func",
"gaus(0)+pol1(3)",
xmin,
xmax);
2360 func->SetLineColor(kRed);
2361 func->SetLineWidth(2);
2362 func->SetParameters(
h->GetBinContent(
h->GetMaximumBin()),
h->GetMean(),
h->GetRMS());
2363 if (
h->GetEffectiveEntries() > minstat) {
2364 h->Fit(func, (
"rq" + fitopt).c_str());
2372 found1 = display.find(
"gausplusexpo");
2373 if (found1 != std::string::npos) {
2374 std::size_t found2 = display.find(
'(', found1 + 1);
2375 if (found2 != std::string::npos) {
2376 std::size_t found3 = display.find(
')', found2 + 1);
2377 if (found3 != std::string::npos) {
2378 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
2379 Double_t
xmin = std::strtod(range.c_str(), NULL);
2380 std::size_t found4 = display.find(
',', found2 + 1);
2381 if (found4 != std::string::npos) {
2382 range = display.substr(found4 + 1, found3 - found4 - 1);
2383 Double_t
xmax = std::strtod(range.c_str(), NULL);
2385 TF1* func =
new TF1(
"func",
"gaus(0)+expo(3)",
xmin,
xmax);
2386 func->SetLineColor(kRed);
2387 func->SetLineWidth(2);
2388 func->SetParameters(
h->GetBinContent(
h->GetMaximumBin()),
h->GetMean(),
h->GetRMS());
2389 if (
h->GetEffectiveEntries() > minstat) {
2390 h->Fit(func, (
"rq" + fitopt).c_str());
2398 std::size_t found2 = display.find(
'(', found + 1);
2399 if (found2 != std::string::npos) {
2400 std::size_t found3 = display.find(
')', found2 + 1);
2401 if (found3 != std::string::npos) {
2402 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
2403 Double_t
xmin = std::strtod(range.c_str(), NULL);
2404 std::size_t found4 = display.find(
',', found2 + 1);
2405 if (found4 != std::string::npos) {
2406 range = display.substr(found4 + 1, found3 - found4 - 1);
2407 Double_t
xmax = std::strtod(range.c_str(), NULL);
2408 TF1* func =
new TF1(
"func",
"gaus",
xmin,
xmax);
2409 func->SetLineColor(kRed);
2410 func->SetLineWidth(2);
2411 if (
h->GetEffectiveEntries() > minstat) {
2412 h->Fit(func, (
"rq" + fitopt).c_str());
2422 if (!drawopt.empty()) {
2681 if (display.find(
"RatioPad") == std::string::npos)
return;
2683 unsigned int ww = myC_upperpad->GetWw();
2684 unsigned int wh = myC_upperpad->GetWh();
2685 std::string padname =
"PAD";
2686 std::string padname_ratio =
"PAD_main";
2687 auto myC_ratiopad = std::make_unique<TCanvas>(padname_ratio.c_str(),
"myC_ratiopad", ww, wh);
2688 auto myC_main = std::make_unique<TCanvas>(padname.c_str(),
"myC_main", ww, wh);
2692 myC_ratiopad->SetTopMargin(0);
2693 myC_ratiopad->SetLogx(display.find(
"LogX") != std::string::npos);
2700 TProfile* phRef =
dynamic_cast<TProfile*
>(hRef);
2701 TProfile* ph =
dynamic_cast<TProfile*
>(
h);
2702 std::unique_ptr<TH1F> clonehist;
2703 std::unique_ptr<TH1F> clonehistref;
2706 clonehist.reset((TH1F*) ph->ProjectionX());
2708 clonehist.reset((TH1F*)
h->Clone());
2709 if (!clonehist->GetSumw2()) {
2714 clonehistref.reset((TH1F*) phRef->ProjectionX());
2716 clonehistref.reset((TH1F*) hRef->Clone());
2717 if (!clonehistref->GetSumw2()) {
2718 clonehistref->Sumw2();
2721 if (!clonehist or !clonehistref) {
2724 clonehist->SetBit(kCanDelete);
2725 clonehist->Divide(clonehistref.get());
2729 formatTH1(myC_ratiopad.get(), clonehist.get());
2730 clonehist->SetTitle(
"");
2733 double delta = 0.75;
2734 if (display.find(
"delta(") != std::string::npos) {
2735 delta = std::stod(display.substr(display.find(
"delta(") + 6));
2737 clonehist->SetAxisRange(1. - delta, 1. + delta,
"Y");
2739 clonehist->GetYaxis()->SetNdivisions(3,
true);
2740 clonehist->SetMarkerStyle(1);
2741 clonehist->Draw(
"E");
2742 clonehist->GetXaxis()->SetTitleSize(0.11);
2743 clonehist->GetXaxis()->SetLabelSize(0.11);
2744 clonehist->GetYaxis()->SetTitleSize(0.11);
2745 clonehist->GetYaxis()->SetLabelSize(0.11);
2747 TPad* lowerPad =
new TPad(
"lowerPad",
"lowerPad", .005, .060, .995, .250);
2748 lowerPad->SetTopMargin(0);
2749 lowerPad->SetFillStyle(0);
2751 TPad* upperPad =
new TPad(
"upperPad",
"upperPad", .005, .250, .995, .995);
2752 upperPad->SetBottomMargin(0);
2753 upperPad->SetFillStyle(0);
2757 myC_ratiopad->DrawClonePad();
2760 line.SetLineColor(kRed);
2761 line.SetLineWidth(1);
2763 double xmin = clonehist->GetXaxis()->GetXmin();
2764 double xmax = clonehist->GetXaxis()->GetXmax();
2769 myC_upperpad->SetBottomMargin(0);
2770 myC_upperpad->SetFillStyle(0);
2771 h->GetXaxis()->SetLabelSize(0.);
2772 h->GetXaxis()->SetTitleSize(0.);
2773 myC_upperpad->DrawClonePad();
2775 myC_upperpad->Clear();
2776 myC_main->DrawClonePad();
2778 std::ignore = clonehist.release();
2782 for (TObject* o : *(myC_main->GetListOfPrimitives())) {
2783 o->SetBit(kCanDelete);
2784 if (
auto* o2 =
dynamic_cast<TPad*
>(o)) {
2785 for (
auto* o3: *(o2->GetListOfPrimitives())) {
2786 if (!
dynamic_cast<TFrame*
>(o3)) {
2787 o3->SetBit(kCanDelete);
2796 for (TObject* o : *(myC_upperpad->GetListOfPrimitives())) {
2797 o->SetBit(kCanDelete);
2798 if (
auto* o2 =
dynamic_cast<TPad*
>(o)) {
2799 for (
auto* o3: *(o2->GetListOfPrimitives())) {
2800 if (!
dynamic_cast<TFrame*
>(o3)) {
2801 o3->SetBit(kCanDelete);
2809 if (display.find(
"Ref2DRatio") == std::string::npos && display.find(
"Ref2DSignif") == std::string::npos)
return;
2812 std::make_unique<TCanvas>(
"canvas_bottom",
"canvas_bottom", canvas_top->GetWw(), canvas_top->GetWh());
2813 auto canvas_all = std::make_unique<TCanvas>(
"canvas_all",
"canvas_all", canvas_top->GetWw(), canvas_top->GetWh());
2816 canvas_bot->SetTopMargin(0);
2818 h2Ref->Scale(h2->Integral() / h2Ref->Integral());
2820 TH2* comparison = (TH2*) (h2->Clone());
2821 comparison->Divide(h2, h2Ref, 1.0, 1.0);
2822 comparison->SetTitle(
"");
2823 formatTH2(canvas_bot.get(), comparison);
2825 if (display.find(
"Ref2DRatio") != std::string::npos) {
2826 comparison->GetZaxis()->SetTitle(
"ratio to ref.");
2827 comparison->SetAxisRange(0.0, 2.0,
"Z");
2828 }
else if (display.find(
"Ref2DSignif") != std::string::npos) {
2829 comparison->GetZaxis()->SetTitle(
"difference to ref. (#sigma)");
2830 comparison->SetAxisRange(-4.5, 4.5,
"Z");
2838 for (
int binx = 0; binx <= comparison->GetNbinsX(); binx++) {
2839 for (
int biny = 0; biny <= comparison->GetNbinsY(); biny++) {
2840 value_a = h2->GetBinContent(binx, biny);
2841 value_b = h2Ref->GetBinContent(binx, biny);
2843 sigma_a = h2->GetBinError(binx, biny);
2844 sigma_b = h2Ref->GetBinError(binx, biny);
2846 if (sigma_a == 0 && sigma_b == 0) signif = 0;
2847 else signif = (value_a - value_b) / sqrt((sigma_a * sigma_a + sigma_b * sigma_b));
2849 comparison->SetBinContent(binx, biny, signif);
2854 comparison->Draw(
"colz");
2857 TPad* pad_bot =
new TPad(
"pad_bot",
"pad_bot", 0.005, 0.060, 0.995, 0.550);
2858 TPad* pad_top =
new TPad(
"pad_top",
"pad_top", 0.005, 0.550, 0.995, 0.995);
2860 pad_bot->SetTopMargin(0);
2861 pad_top->SetBottomMargin(0);
2863 pad_bot->SetFillStyle(0);
2864 pad_top->SetFillStyle(0);
2870 canvas_bot->DrawClonePad();
2873 canvas_top->SetBottomMargin(0);
2874 canvas_top->SetFillStyle(0);
2875 h2->GetXaxis()->SetLabelSize(0.);
2876 h2->GetXaxis()->SetTitleSize(0.);
2877 canvas_top->DrawClonePad();
2879 canvas_top->Clear();
2881 canvas_all->DrawClonePad();
2916 std::size_t found =
str.find(
"TLine");
2917 while (found != std::string::npos) {
2918 std::size_t found1 =
str.find_first_of(
')', found + 1);
2919 if (found1 != std::string::npos) {
2920 std::string coordinates =
str.substr(found + 6, found1 - found - 6);
2922 if (found1 <
str.size() - 3 &&
str.substr(found1 + 1, 3) ==
"NDC") {
2925 found1 = coordinates.find_first_of(
',');
2926 if (found1 != std::string::npos) {
2927 std::string cx1 = coordinates.substr(0, found1);
2928 double x1 = std::strtod(cx1.c_str(), NULL);
2929 std::size_t found2 = coordinates.find_first_of(
',', found1 + 1);
2930 if (found2 != std::string::npos) {
2931 std::string cy1 = coordinates.substr(found1 + 1, found2 - found1 - 1);
2932 double y1 = std::strtod(cy1.c_str(), NULL);
2933 found1 = coordinates.find_first_of(
',', found2 + 1);
2934 if (found1 != std::string::npos) {
2935 std::string cx2 = coordinates.substr(found2 + 1, found1 - found2 - 1);
2936 double x2 = std::strtod(cx2.c_str(), NULL);
2937 std::string cy2 = coordinates.substr(found1 + 1, coordinates.size());
2938 double y2 = std::strtod(cy2.c_str(), NULL);
2940 TLine* L =
new TLine;
2942 if (x1 <= 1.0 && x1 >= 0.0 && x2 <= 1.0 && x2 >= 0.0 && y1 <= 1.0 && y1 >= 0.0 && y2 <= 1.0 &&
2944 L->DrawLineNDC(x1, y1, x2, y2);
2947 L->DrawLine(x1, y1, x2, y2);
2953 found =
str.find(
"TLine", found + 1);
2956 found =
str.find(
"TText");
2957 while (found != std::string::npos) {
2958 std::string coordinates, cx1, cy1 =
"";
2959 std::size_t found1 =
str.find_first_of(
')', found + 1);
2960 std::size_t found2 =
str.find_first_of(
'\'', found + 1);
2961 if (found2 != std::string::npos) {
2962 found2 =
str.find_first_of(
'\"', found2 + 1);
2963 if (found2 != std::string::npos && found1 < found2) {
2964 found1 =
str.find_first_of(
')', found2 + 1);
2967 if (found1 != std::string::npos) {
2968 coordinates =
str.substr(found + 6, found1 - found - 6);
2970 if (found1 <
str.size() - 3 &&
str.substr(found1 + 1, 3) ==
"NDC") {
2973 found1 = coordinates.find_first_of(
',');
2974 if (found1 != std::string::npos) {
2975 cx1 = coordinates.substr(0, found1);
2976 double x1 = std::strtod(cx1.c_str(), NULL);
2977 found2 = coordinates.find_first_of(
',', found1 + 1);
2978 if (found2 != std::string::npos) {
2979 cy1 = coordinates.substr(found1 + 1, found2 - found1 - 1);
2980 double y1 = std::strtod(cy1.c_str(), NULL);
2981 std::string txt = coordinates.substr(found2 + 2, coordinates.size());
2984 TText* T =
new TText;
2986 if (x1 <= 1.0 && x1 >= 0.0 && y1 <= 1.0 && y1 >= 0.0) {
2987 T->DrawTextNDC(x1, y1, txt.c_str());
2990 T->DrawText(x1, y1, txt.c_str());
2995 found =
str.find(
"TText", found + 1);
2998 found =
str.find(
"TDota");
2999 while (found != std::string::npos) {
3000 std::size_t found1 =
str.find_first_of(
')', found + 1);
3001 if (found1 != std::string::npos) {
3002 std::string coordinates =
str.substr(found + 6, found1 - found - 6);
3004 if (found1 <
str.size() - 3 &&
str.substr(found1 + 1, 3) ==
"NDC") {
3007 found1 = coordinates.find_first_of(
',');
3008 if (found1 != std::string::npos) {
3009 std::string cx1 = coordinates.substr(0, found1);
3010 double x1 = std::strtod(cx1.c_str(), NULL);
3011 std::size_t found2 = coordinates.find_first_of(
',', found1 + 1);
3012 if (found2 != std::string::npos) {
3013 std::string cy1 = coordinates.substr(found1 + 1, found2 - found1 - 1);
3014 double y1 = std::strtod(cy1.c_str(), NULL);
3015 found1 = coordinates.find_first_of(
',', found2 + 1);
3016 if (found1 != std::string::npos) {
3017 std::string cx2 = coordinates.substr(found2 + 1, found1 - found2 - 1);
3018 double x2 = std::strtod(cx2.c_str(), NULL);
3019 std::string cy2 = coordinates.substr(found1 + 1, coordinates.size());
3020 double y2 = std::strtod(cy2.c_str(), NULL);
3022 TLine* L =
new TLine;
3025 if (x1 <= 1.0 && x1 >= 0.0 && x2 <= 1.0 && x2 >= 0.0 && y1 <= 1.0 && y1 >= 0.0 && y2 <= 1.0 &&
3027 L->DrawLineNDC(x1, y1, x2, y2);
3030 L->DrawLine(x1, y1, x2, y2);
3036 found =
str.find(
"TDota", found + 1);
3039 found =
str.find(
"TSize");
3040 while (found != std::string::npos) {
3041 std::string coordinates, cx1, cy1, txtsize =
"";
3042 std::size_t found1 =
str.find_first_of(
')', found + 1);
3043 std::size_t found2 =
str.find_first_of(
'\'', found + 1);
3044 if (found2 != std::string::npos) {
3045 found2 =
str.find_first_of(
'\"', found2 + 1);
3046 if (found2 != std::string::npos && found1 < found2) {
3047 found1 =
str.find_first_of(
')', found2 + 1);
3050 if (found1 != std::string::npos) {
3051 coordinates =
str.substr(found + 6, found1 - found - 6);
3053 if (found1 <
str.size() - 3 &&
str.substr(found1 + 1, 3) ==
"NDC") {
3056 found1 = coordinates.find_first_of(
',');
3057 if (found1 != std::string::npos) {
3058 cx1 = coordinates.substr(0, found1);
3059 double x1 = std::strtod(cx1.c_str(), NULL);
3060 found2 = coordinates.find_first_of(
',', found1 + 1);
3061 if (found2 != std::string::npos) {
3062 cy1 = coordinates.substr(found1 + 1, found2 - found1 - 1);
3063 double y1 = std::strtod(cy1.c_str(), NULL);
3064 std::size_t found3 = coordinates.find_first_of(
',', found2 + 1);
3065 if (found3 != std::string::npos) {
3066 txtsize = coordinates.substr(found2 + 1, found3 - found2 - 1);
3067 double size = std::strtod(txtsize.c_str(), NULL);
3068 std::string txt = coordinates.substr(found3 + 2, coordinates.size());
3071 TText* T =
new TText;
3072 T->SetTextSize(size / 100);
3074 if (x1 <= 1.0 && x1 >= 0.0 && y1 <= 1.0 && y1 >= 0.0) {
3075 T->DrawTextNDC(x1, y1, txt.c_str());
3078 T->DrawText(x1, y1, txt.c_str());
3084 found =
str.find(
"TSize", found + 1);