1182 bool drawRefs,
const std::string& run_min_LB,
1183 const std::string& pathName,
int cnvsType) {
1187 int iMarkerStyle = 20;
1188 gStyle->SetFrameBorderMode(0);
1189 gStyle->SetFrameFillColor(0);
1190 gStyle->SetCanvasBorderMode(0);
1191 gStyle->SetPadBorderMode(0);
1192 gStyle->SetPadColor(0);
1193 gStyle->SetCanvasColor(0);
1194 gStyle->SetTitleColor(0);
1195 gStyle->SetStatColor(0);
1196 gStyle->SetFillColor(1);
1197 gStyle->SetPalette(1, 0);
1198 gStyle->SetTitleFontSize(0.06);
1199 gStyle->SetTitleH(0.06);
1200 gStyle->SetMarkerStyle(iMarkerStyle);
1201 gStyle->SetOptStat(111100);
1202 gStyle->SetStatBorderSize(0);
1203 gStyle->SetStatX(0.99);
1204 gStyle->SetStatY(0.99);
1205 gStyle->SetStatW(0.2);
1206 gStyle->SetStatH(0.1);
1212 TImage* img =
nullptr;
1216 std::string pathname(groupDir->GetPath());
1217 std::string display =
"";
1218 bool WasCollectionReference =
false;
1220 bool LookForDisplay;
1221 if (file_version == 1) {
1222 LookForDisplay =
containsDir(
"Config/annotations/display", (pathname +
"/" + nameHis +
"_"));
1223 if (LookForDisplay) {
1224 display =
getStringName(pathname +
"/" + nameHis +
"_/Config/annotations/display", file_version);
1226 }
else if (file_version == 2) {
1227 std::optional<std::string> JSON_content;
1228 LookForDisplay =
containsDir((nameHis +
"_"), pathname);
1229 if (LookForDisplay) {
1230 JSON_content =
containsKeyInJSON(
"/annotations/display",
"Config", (pathname +
"/" + nameHis +
"_"));
1232 LookForDisplay =
true;
1234 LookForDisplay =
false;
1237 if (LookForDisplay) {
1238 display = JSON_content.value();
1242 bool PlotOverflows = (display.find(
"PlotUnderOverflow") != std::string::npos);
1244 std::size_t found = display.find(
"Draw=");
1245 std::string drawopt =
"";
1246 while (found != std::string::npos) {
1247 std::size_t found1 = display.find_first_of(
',', found + 1);
1248 auto temp = display.substr(found + 5, found1 != std::string::npos ? found1 - found - 5 : display.size());
1249 std::ranges::transform(temp, temp.begin(), [](
unsigned char c) { return std::tolower(c); });
1251 found = display.find(
"Draw=", found + 1);
1254 found = display.find(
"DrawRef=");
1255 std::string drawrefopt =
"";
1256 while (found != std::string::npos) {
1257 std::size_t found1 = display.find_first_of(
',', found + 1);
1258 auto temp = display.substr(found + 8, found1 != std::string::npos ? found1 - found - 8 : display.size());
1259 std::ranges::transform(temp, temp.begin(), [](
unsigned char c) { return std::tolower(c); });
1261 found = display.find(
"DrawRef=", found + 1);
1263 if (drawrefopt ==
"") {
1264 drawrefopt = drawopt;
1267 found = display.find(
"DrawRef2D=");
1268 std::string drawrefopt2D =
"";
1269 while (found != std::string::npos) {
1270 std::size_t found1 = display.find_first_of(
',', found + 1);
1271 auto temp = display.substr(found + 10, found1 != std::string::npos ? found1 - found - 10 : display.size());
1272 std::ranges::transform(temp, temp.begin(), [](
unsigned char c) { return std::tolower(c); });
1273 drawrefopt2D += temp;
1274 found = display.find(
"DrawRef2D=", found + 1);
1278 found = display.find(
"DataName");
1279 std::string datatitle;
1280 if (found == std::string::npos) {
1283 while (found != std::string::npos) {
1284 std::size_t found1 = display.find_first_of(
',', found + 1);
1285 if (found1 != std::string::npos) {
1286 datatitle += display.substr(found + 9, found1 - found - 9);
1288 datatitle += display.substr(found + 9, display.size());
1290 found = display.find(
"DataName", found + 1);
1293 TKey* hkey = groupDir->FindKey(nameHis.c_str());
1295 std::cerr <<
"Did not find TKey for \"" << nameHis <<
"\", will not save this histogram.\n";
1296 return std::pair<std::string, std::string>{
1301 TObject* hobj = hkey->ReadObj();
1304 TEfficiency* eRef(0);
1306 std::vector<TH1*> hRefs;
1307 std::vector<TEfficiency*> eRefs;
1308 bool hasPlotted(
false);
1309 TH1*
h =
dynamic_cast<TH1*
>(hobj);
1310 TH2* h2 =
dynamic_cast<TH2*
>(
h);
1311 TGraph* g =
dynamic_cast<TGraph*
>(hobj);
1312 TEfficiency* e =
dynamic_cast<TEfficiency*
>(hobj);
1314 std::string name = nameHis;
1321 std::string AlgoName(
"");
1322 AlgoName =
getStringName(pathname +
"/" + nameHis +
"_/Config/name", file_version);
1325 found = display.find(
"TCanvas", found + 1);
1326 if (found != std::string::npos) {
1327 std::size_t found1 = display.find_first_of(
',', found + 1);
1328 ww = std::atoi((display.substr(found + 8, found1 - found - 8)).c_str());
1329 found = display.find_first_of(
')', found1 + 1);
1330 wh = std::atoi((display.substr(found1 + 1, found - found1 - 1)).c_str());
1333 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww, wh);
1341 gPad->SetGridx(display.find(
"SetGridx") != std::string::npos);
1342 gPad->SetGridy(display.find(
"SetGridy") != std::string::npos);
1343 std::size_t found = display.find(
"SetPalette");
1344 if (found != std::string::npos) {
1345 std::size_t found1 = display.find_first_of(
'(', found + 1);
1346 std::size_t found2 = display.find_first_of(
",)", found + 1);
1347 std::string cn = display.substr(found1 + 1, found2 - found1 - 1);
1348 int n1 = std::strtol(cn.c_str(), NULL, 0);
1349 gStyle->SetPalette((Int_t) n1);
1351 found = display.find(
"SetGridStyle");
1352 if (found != std::string::npos) {
1353 std::size_t found1 = display.find_first_of(
'(', found + 1);
1354 std::size_t found2 = display.find_first_of(
",)", found + 1);
1355 std::string cn = display.substr(found1 + 1, found2 - found1 - 1);
1356 int n1 = std::strtol(cn.c_str(), NULL, 0);
1357 gStyle->SetGridStyle((Style_t) n1);
1361 found = display.find(
"gaus");
1362 if (found != std::string::npos) {
1363 Double_t minstat = 0.;
1364 std::size_t fpos1, fpos2, fpos;
1365 fpos = display.find(
"MinStat");
1366 if (fpos != std::string::npos) {
1367 fpos1 = display.find(
'(', fpos + 1);
1368 if (fpos1 != std::string::npos) {
1369 fpos2 = display.find(
')', fpos1 + 1);
1370 if (fpos2 != std::string::npos) {
1371 std::string s_minstat = display.substr(fpos1 + 1, fpos2 - fpos1 - 1);
1372 minstat = std::strtod(s_minstat.c_str(), NULL);
1376 std::string fitopt(
"");
1377 fpos = display.find(
"FitOption");
1378 if (fpos != std::string::npos) {
1379 fpos1 = display.find(
'(', fpos + 1);
1380 if (fpos1 != std::string::npos) {
1381 fpos2 = display.find(
')', fpos1 + 1);
1382 if (fpos2 != std::string::npos) {
1383 fitopt = display.substr(fpos1 + 1, fpos2 - fpos1 - 1);
1388 std::size_t found1 = display.find(
"doublegaus");
1389 if (found1 != std::string::npos) {
1390 std::size_t found2 = display.find(
'(', found1 + 1);
1391 if (found2 != std::string::npos) {
1392 std::size_t found3 = display.find(
')', found2 + 1);
1393 if (found3 != std::string::npos) {
1394 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
1395 Double_t
xmin = std::strtod(range.c_str(), NULL);
1396 std::size_t found4 = display.find(
',', found2 + 1);
1397 if (found4 != std::string::npos) {
1398 range = display.substr(found4 + 1, found3 - found4 - 1);
1399 Double_t
xmax = std::strtod(range.c_str(), NULL);
1400 TF1* f1 =
new TF1(
"f1",
"gaus",
xmin,
xmax);
1403 f1->GetParameters(par);
1404 TF1* func =
new TF1(
"func",
"gaus(0)+gaus(3)",
xmin,
xmax);
1405 func->SetParameters(par);
1406 func->SetParameter(3,
h->GetBinContent(
h->GetMaximumBin()));
1407 func->SetParameter(4,
h->GetMean());
1408 func->SetParameter(5, par[2]);
1409 func->SetLineColor(kRed);
1410 func->SetLineWidth(2);
1411 if (
h->GetEffectiveEntries() > minstat) {
1412 h->Fit(func, (
"rq" + fitopt).c_str());
1421 std::size_t found1 = display.find(
"gauspluspol1");
1422 if (found1 != std::string::npos) {
1423 std::size_t found2 = display.find(
'(', found1 + 1);
1424 if (found2 != std::string::npos) {
1425 std::size_t found3 = display.find(
')', found2 + 1);
1426 if (found3 != std::string::npos) {
1427 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
1428 Double_t
xmin = std::strtod(range.c_str(), NULL);
1429 std::size_t found4 = display.find(
',', found2 + 1);
1430 if (found4 != std::string::npos) {
1431 range = display.substr(found4 + 1, found3 - found4 - 1);
1432 Double_t
xmax = std::strtod(range.c_str(), NULL);
1433 TF1* func =
new TF1(
"func",
"gaus(0)+pol1(3)",
xmin,
xmax);
1434 func->SetLineColor(kRed);
1435 func->SetLineWidth(2);
1436 func->SetParameters(
h->GetBinContent(
h->GetMaximumBin()),
h->GetMean(),
h->GetRMS());
1437 if (
h->GetEffectiveEntries() > minstat) {
1438 h->Fit(func, (
"rq" + fitopt).c_str());
1446 found1 = display.find(
"gausplusexpo");
1447 if (found1 != std::string::npos) {
1448 std::size_t found2 = display.find(
'(', found1 + 1);
1449 if (found2 != std::string::npos) {
1450 std::size_t found3 = display.find(
')', found2 + 1);
1451 if (found3 != std::string::npos) {
1452 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
1453 Double_t
xmin = std::strtod(range.c_str(), NULL);
1454 std::size_t found4 = display.find(
',', found2 + 1);
1455 if (found4 != std::string::npos) {
1456 range = display.substr(found4 + 1, found3 - found4 - 1);
1457 Double_t
xmax = std::strtod(range.c_str(), NULL);
1459 TF1* func =
new TF1(
"func",
"gaus(0)+expo(3)",
xmin,
xmax);
1460 func->SetLineColor(kRed);
1461 func->SetLineWidth(2);
1462 func->SetParameters(
h->GetBinContent(
h->GetMaximumBin()),
h->GetMean(),
h->GetRMS());
1463 if (
h->GetEffectiveEntries() > minstat) {
1464 h->Fit(func, (
"rq" + fitopt).c_str());
1472 std::size_t found2 = display.find(
'(', found + 1);
1473 if (found2 != std::string::npos) {
1474 std::size_t found3 = display.find(
')', found2 + 1);
1475 if (found3 != std::string::npos) {
1476 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
1477 Double_t
xmin = std::strtod(range.c_str(), NULL);
1478 std::size_t found4 = display.find(
',', found2 + 1);
1479 if (found4 != std::string::npos) {
1480 range = display.substr(found4 + 1, found3 - found4 - 1);
1481 Double_t
xmax = std::strtod(range.c_str(), NULL);
1482 TF1* func =
new TF1(
"func",
"gaus",
xmin,
xmax);
1483 func->SetLineColor(kRed);
1484 func->SetLineWidth(2);
1485 if (
h->GetEffectiveEntries() > minstat) {
1486 h->Fit(func, (
"rq" + fitopt).c_str());
1499 if (h2->GetMinimum() >= 0 && h2->GetMaximum() > 0.) {
1500 gPad->SetLogy(display.find(
"LogY") != std::string::npos);
1501 gPad->SetLogz(display.find(
"LogZ") != std::string::npos);
1504 gPad->SetLogx(display.find(
"LogX") != std::string::npos);
1506 if (
h->GetXaxis()->GetXmin() >=
h->GetXaxis()->GetXmax()) {
1507 std::cerr <<
"HanOutputFile::saveHistogramToFile(): "
1508 <<
"Inconsistent x-axis settings: min=" <<
h->GetXaxis()->GetXmin() <<
", "
1509 <<
"max=" <<
h->GetXaxis()->GetXmax() <<
", "
1510 <<
"Will not save this histogram.\n";
1511 return std::pair<std::string, std::string>{
1515 if (
h->GetYaxis()->GetXmin() >=
h->GetYaxis()->GetXmax()) {
1516 std::cerr <<
"HanOutputFile::saveHistogramToFile(): "
1517 <<
"Inconsistent y-axis settings: min=" <<
h->GetYaxis()->GetXmin() <<
", "
1518 <<
"max=" <<
h->GetYaxis()->GetXmax() <<
", "
1519 <<
"Will not save this histogram.\n";
1520 return std::pair<std::string, std::string>{
1525 if (drawopt ==
"") {
1529 if (file_version == 1) {
1530 groupDir->cd((nameHis +
"_/Results").c_str());
1531 gDirectory->GetObject(
"Reference;1",
ref);
1532 }
else if (file_version == 2) {
1533 if (groupDir->GetDirectory((nameHis +
"_").c_str()) != 0) {
1534 groupDir->cd((nameHis +
"_").c_str());
1535 gDirectory->GetObject(
"Reference;1",
ref);
1538 h2Ref =
dynamic_cast<TH2*
>(
ref);
1539 TCollection* colln =
dynamic_cast<TCollection*
>(
ref);
1541 h2Ref =
dynamic_cast<TH2*
>(colln->MakeIterator()->Next());
1543 if (h2Ref && (drawrefopt2D !=
"")) {
1545 h2Ref->Draw(drawrefopt2D.c_str());
1548 h2->Draw((
"SAME" + drawopt).c_str());
1550 if (drawopt.find(
"lego") == std::string::npos) {
1553 if (h2Ref)
ratioplot2D(myC.get(), h2, h2Ref, display);
1558 t.SetTextSize(0.03);
1559 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
1562 tt.SetTextSize(0.03);
1563 tt.DrawLatex(0.02, 0.01, pathName.c_str());
1565 }
else if (
h != 0) {
1567 if (display.find(
"StatBox") != std::string::npos) {
1570 if (
h->GetXaxis()->GetXmin() >=
h->GetXaxis()->GetXmax()) {
1571 std::cerr <<
"HanOutputFile::saveHistogramToFile(): "
1572 <<
"Inconsistent x-axis settings: min=" <<
h->GetXaxis()->GetXmin() <<
", "
1573 <<
"max=" <<
h->GetXaxis()->GetXmax() <<
", "
1574 <<
"Will not save this histogram.\n";
1575 return std::pair<std::string, std::string>{
1579 h->SetLineColor(kBlack);
1580 h->SetMarkerColor(1);
1587 if (file_version == 1) {
1588 groupDir->cd((nameHis +
"_/Results").c_str());
1589 gDirectory->GetObject(
"Reference;1",
ref);
1590 }
else if (file_version == 2) {
1591 if (groupDir->GetDirectory((nameHis +
"_").c_str()) != 0) {
1592 groupDir->cd((nameHis +
"_").c_str());
1593 gDirectory->GetObject(
"Reference;1",
ref);
1596 hRef =
dynamic_cast<TH1*
>(
ref);
1598 hRefs.push_back(hRef);
1600 TCollection* colln =
dynamic_cast<TCollection*
>(
ref);
1602 WasCollectionReference =
true;
1603 std::unique_ptr<TIterator> icolln(colln->MakeIterator());
1605 while ((ref2 = icolln->Next())) {
1606 hRef =
dynamic_cast<TH1*
>(ref2);
1608 if (hRef->GetDimension() ==
h->GetDimension()) {
1609 hRefs.push_back(hRef);
1611 }
else std::cout <<
"hRef cast failed!!!" << std::endl;
1618 if (hRefs.size() > 0) {
1619 legend =
new TLegend(0.55, 0.77, 0.87, 0.87);
1620 legend->SetTextFont(62);
1621 legend->SetMargin(0.15);
1622 legend->SetFillStyle(0);
1623 legend->SetBorderSize(0);
1624 legend->AddEntry(
h, datatitle.c_str());
1626 for (
auto hRef : hRefs) {
1630 TProfile* pRef =
dynamic_cast<TProfile*
>(hRef);
1632 hRef->SetMarkerColor(local_color);
1635 hRef->SetLineColor(local_color);
1636 hRef->SetLineWidth(2);
1637 double ymin = (hRef->GetMinimum() <
h->GetMinimum()) ? hRef->GetMinimum() :
h->GetMinimum();
1638 double ymax = (hRef->GetMaximum() >
h->GetMaximum()) ? hRef->GetMaximum() :
h->GetMaximum();
1640 if (PlotOverflows) {
1655 bool isLogY = (display.find(
"LogY") != std::string::npos);
1659 double lymax = log(
ymax);
1660 double lymin = log(
ymin);
1661 h->SetAxisRange(exp(lymin - (lymax - lymin) * 0.05), exp(lymax + (lymax - lymin) * 0.05),
1664 std::cerr <<
"ymin is <0. and LogY requested for histogram \"" << pathname +
"/" + nameHis
1665 <<
"\", ymin=" <<
ymin << std::endl;
1668 double yMargin = (
ymax -
ymin) * 0.05;
1669 h->SetAxisRange(
ymin - yMargin,
ymax + yMargin,
"Y");
1671 h->GetXaxis()->SetRangeUser(
xmin,
xmax);
1672 hRef->GetXaxis()->SetRangeUser(
xmin,
xmax);
1674 if (
h->GetMinimum() >= 0. && hRef->GetMinimum() >= 0. &&
h->GetMaximum() > 0. &&
1675 hRef->GetMaximum() > 0.) {
1676 gPad->SetLogy(display.find(
"LogY") != std::string::npos);
1679 gPad->SetLogx(display.find(
"LogX") != std::string::npos);
1682 h->Draw(drawopt.c_str());
1685 hRef->Draw((
"SAME" + drawrefopt).c_str());
1688 if (display.find(
"ScaleRef") != std::string::npos) {
1689 scale = getScaleVal(display);
1690 }
else if (
h->Integral(
"width") > 0.0 && hRef->Integral(
"width") > 0.0 &&
1691 (AlgoName.find(
"BinContentComp") == std::string::npos) &&
1692 (display.find(
"NoNorm") == std::string::npos)) {
1693 scale =
h->Integral(
"width") / hRef->Integral(
"width");
1698 hRef->SetMarkerColor(local_color);
1700 hRef->SetLineColor(local_color);
1701 double ymin = (hRef->GetMinimum() <
h->GetMinimum()) ? hRef->GetMinimum() :
h->GetMinimum();
1702 double ymax = (hRef->GetMaximum() >
h->GetMaximum()) ? hRef->GetMaximum() :
h->GetMaximum();
1704 if (PlotOverflows) {
1721 bool isLogY = (display.find(
"LogY") != std::string::npos);
1727 double lymax = log(
ymax);
1728 double lymin = log(
ymin);
1729 h->SetAxisRange(exp(lymin - (lymax - lymin) * 0.05), exp(lymax + (lymax - lymin) * 0.05),
"Y");
1732 std::cerr <<
"ymin is <=0. and LogY requested for histogram \"" << pathname +
"/" + nameHis
1733 <<
"\", ymin=" <<
ymin << std::endl;
1737 h->SetAxisRange(
ymin - yDiff * 0.05,
ymax + yDiff * 0.05,
"Y");
1740 h->GetXaxis()->SetRangeUser(
xmin,
xmax);
1741 hRef->GetXaxis()->SetRangeUser(
xmin,
xmax);
1743 if (
h->GetMinimum() >= 0 && hRef->GetMinimum() >= 0 &&
h->GetMaximum() > 0. && hRef->GetMaximum() > 0.) {
1744 gPad->SetLogy(display.find(
"LogY") != std::string::npos);
1747 gPad->SetLogx(display.find(
"LogX") != std::string::npos);
1751 h->Draw(drawopt.c_str());
1754 hRef->Draw((
"SAME" + drawrefopt).c_str());
1756 if (WasCollectionReference) {
1757 legend->AddEntry(hRef, hRef->GetName());
1759 std::string refInfo(
"");
1760 refInfo =
getStringName(pathname +
"/" + nameHis +
"_/Config/annotations/refInfo", file_version);
1761 legend->AddEntry(hRef, refInfo !=
"Undefined" ? refInfo.c_str() :
"Reference");
1764 h->Draw((
"SAME" + drawopt).c_str());
1768 if (
h->GetMinimum() >= 0) {
1769 gPad->SetLogy(display.find(
"LogY") != std::string::npos);
1772 gPad->SetLogx(display.find(
"LogX") != std::string::npos);
1775 h->Draw(drawopt.c_str());
1789 t.SetTextSize(0.03);
1790 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
1793 tt.SetTextSize(0.03);
1794 tt.DrawLatex(0.02, 0.01, pathName.c_str());
1802 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww, wh);
1804 if (g->GetMinimum() >= 0. && g->GetMaximum() > 0.) {
1805 gPad->SetLogy(display.find(
"LogY") != std::string::npos);
1813 g->Draw((std::string(
"AP") + drawopt).c_str());
1817 t.SetTextSize(0.03);
1818 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
1821 tt.SetTextSize(0.03);
1822 tt.DrawLatex(0.02, 0.01, pathName.c_str());
1831 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww, wh);
1833 if (drawopt ==
"") {
1834 if (e->GetDimension() == 1) {
1841 if (file_version == 1) {
1842 groupDir->cd((nameHis +
"_/Results").c_str());
1843 gDirectory->GetObject(
"Reference;1",
ref);
1844 }
else if (file_version == 2) {
1845 if (groupDir->cd((nameHis +
"_").c_str())) {
1846 gDirectory->GetObject(
"Reference;1",
ref);
1849 eRef =
dynamic_cast<TEfficiency*
>(
ref);
1851 eRefs.push_back(eRef);
1853 TCollection* colln =
dynamic_cast<TCollection*
>(
ref);
1855 WasCollectionReference =
true;
1856 TIterator* icolln = colln->MakeIterator();
1858 while ((ref2 = icolln->Next())) {
1859 eRef =
dynamic_cast<TEfficiency*
>(ref2);
1861 if (eRef->GetDimension() == e->GetDimension()) {
1862 eRefs.push_back(eRef);
1864 }
else std::cout <<
"eRef cast failed!!!" << std::endl;
1870 if (eRefs.size() > 0) {
1871 legend =
new TLegend(0.55, 0.77, 0.87, 0.87);
1872 legend->SetTextFont(62);
1873 legend->SetMargin(0.15);
1874 legend->SetFillStyle(0);
1875 legend->SetBorderSize(0);
1876 legend->AddEntry(e, datatitle.c_str());
1878 for (
auto eRef : eRefs) {
1888 eRef->SetMarkerColor(local_color);
1889 eRef->SetLineColor(local_color);
1892 e->Draw(drawopt.c_str());
1898 if (WasCollectionReference) {
1899 legend->AddEntry(eRef, eRef->GetName());
1901 std::string refInfo(
"");
1902 refInfo =
getStringName(pathname +
"/" + nameHis +
"_/Config/annotations/refInfo", file_version);
1903 legend->AddEntry(eRef, refInfo !=
"Undefined" ? refInfo.c_str() :
"Reference");
1909 e->Draw(drawopt.c_str());
1914 e->GetPaintedGraph()->GetXaxis()->SetTitleColor();
1920 t.SetTextSize(0.03);
1921 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
1924 tt.SetTextSize(0.03);
1925 tt.DrawLatex(0.02, 0.01, pathName.c_str());
1931 if (
x) rv.assign(
x,
y);
1934 std::pair<std::string, std::string> rvPair {
1946 TDirectory* groupDir1,
1947 TDirectory* groupDir2,
bool drawRefs,
1948 const std::string& run_min_LB,
const std::string& pathName,
1952 gStyle->SetFrameBorderMode(0);
1953 gStyle->SetFrameFillColor(0);
1954 gStyle->SetCanvasBorderMode(0);
1955 gStyle->SetPadBorderMode(0);
1956 gStyle->SetPadColor(0);
1957 gStyle->SetCanvasColor(0);
1958 gStyle->SetTitleColor(0);
1959 gStyle->SetStatColor(0);
1960 gStyle->SetFillColor(1);
1961 gStyle->SetPalette(1, 0);
1962 gStyle->SetTitleFontSize(0.06);
1963 gStyle->SetTitleH(0.06);
1964 gStyle->SetMarkerStyle(20);
1965 gStyle->SetOptStat(111100);
1966 gStyle->SetStatBorderSize(0);
1967 gStyle->SetStatX(0.99);
1968 gStyle->SetStatY(0.99);
1969 gStyle->SetStatW(0.2);
1970 gStyle->SetStatH(0.1);
1973 std::string pathname(groupDir1->GetPath());
1974 std::string display =
"";
1976 bool LookForDisplay;
1977 if (file_version == 1) {
1978 LookForDisplay =
containsDir(
"Config/annotations/display", (pathname +
"/" + nameHis +
"_"));
1979 if (LookForDisplay) {
1980 display =
getStringName(pathname +
"/" + nameHis +
"_/Config/annotations/display", file_version);
1982 }
else if (file_version == 2) {
1983 std::optional<std::string> JSON_content;
1984 LookForDisplay =
containsDir((nameHis +
"_"), pathname);
1985 if (LookForDisplay) {
1986 JSON_content =
containsKeyInJSON(
"/annotations/display",
"Config", (pathname +
"/" + nameHis +
"_"));
1988 LookForDisplay =
true;
1990 LookForDisplay =
false;
1993 if (LookForDisplay) {
1994 display = JSON_content.value();
1999 std::size_t found = display.find(
"Draw");
2000 std::string drawopt =
"";
2001 while (found != std::string::npos) {
2002 std::size_t found1 = display.find_first_of(
',', found + 1);
2003 auto temp = display.substr(found + 5, found1 != std::string::npos ? found1 - found - 5 : display.size() );
2004 std::ranges::transform(temp, temp.begin(), [](
unsigned char c) { return std::tolower(c); });
2006 found = display.find(
"Draw", found + 1);
2010 TKey* hkey = groupDir1->FindKey(nameHis.c_str());
2012 TKey* hkey2 = groupDir2->FindKey(nameHis.c_str());
2013 if (hkey == 0 || hkey2 == 0) {
2014 std::cerr <<
"Did not find TKey for \"" << nameHis <<
"\", will not save this histogram.\n";
2019 TObject* hobj = hkey->ReadObj();
2020 TObject* hobj2 = hkey2->ReadObj();
2022 TH1*
h(0), *hist2(0);
2023 TH2* h2(0), *h2_2(0), *h2Diff(0);
2024 TGraph* g(0), *g2(0);
2025 TEfficiency* e(0), *e2(0);
2028 std::string nameJSON = nameHis;
2029 std::string namePNG = nameHis;
2031 nameJSON +=
".json";
2032 std::string::size_type i = location.find_last_of(
'/');
2033 if (i != (location.size() - 1)) {
2036 namePNG = location + namePNG;
2037 nameJSON = location + nameJSON;
2038 std::string AlgoName =
getStringName(pathname +
"/" + nameHis +
"_/Config/name", file_version);
2041 found = display.find(
"TCanvas");
2042 if (found != std::string::npos) {
2043 std::size_t found1 = display.find_first_of(
',', found + 1);
2044 ww = std::atoi((display.substr(found + 8, found1 - found - 8)).c_str());
2045 found = display.find_first_of(
')', found1 + 1);
2046 wh = std::atoi((display.substr(found1 + 1, found - found1 - 1)).c_str());
2049 if ((
h =
dynamic_cast<TH1*
>(hobj)) != 0 && (hist2 =
dynamic_cast<TH1*
>(hobj2)) != 0) {
2050 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww, wh);
2056 std::string tmpdraw(drawopt);
2057 if ((h2 =
dynamic_cast<TH2*
>(
h)) != 0 && ((h2_2 =
dynamic_cast<TH2*
>(hist2)) != 0)) {
2059 h2Diff = (TH2*) h2->Clone(
"difference");
2070 h2Diff->Add(h2, h2_2, 1.0, -1.0);
2071 h2Diff->SetLineColor(2);
2072 h2Diff->SetMarkerColor(2);
2073 if (!
drawH2(myC.get(), h2Diff, tmpdraw, display))
return false;
2077 t.SetTextSize(0.03);
2078 t.DrawLatex(0.02, 0.04, (run_min_LB +
" difference").c_str());
2081 tt.SetTextSize(0.03);
2082 tt.DrawLatex(0.02, 0.01, pathName.c_str());
2085 }
else if (
h != 0 && hist2 != 0) {
2088 if (display.find(
"ScaleRef") != std::string::npos) {
2089 scale = getScaleVal(display);
2090 }
else if (
h->Integral(
"width") > 0.0 && hist2->Integral(
"width") > 0.0 &&
2091 (AlgoName.find(
"BinContentComp") == std::string::npos) &&
2092 (display.find(
"NoNorm") == std::string::npos)) {
2093 scale =
h->Integral(
"width") / hist2->Integral(
"width");
2095 hist2->Scale(scale);
2096 double ymin = (hist2->GetMinimum() <
h->GetMinimum()) ? hist2->GetMinimum() :
h->GetMinimum();
2097 double ymax = (hist2->GetMaximum() >
h->GetMaximum()) ? hist2->GetMaximum() :
h->GetMaximum();
2098 double yMargin = (
ymax -
ymin) * 0.05;
2099 h->SetAxisRange(
ymin - yMargin,
ymax + yMargin,
"Y");
2101 h->SetMarkerColor(1);
2104 hist2->SetMarkerColor(4);
2105 hist2->SetLineColor(4);
2106 hist2->SetFillStyle(0);
2107 hist2->SetLineWidth(2);
2109 if (file_version == 1) {
2110 groupDir1->cd((nameHis +
"_/Results").c_str());
2112 groupDir1->cd((nameHis +
"_").c_str());
2114 gDirectory->GetObject(
"Reference;1", hRef);
2117 if (!
drawH1(myC.get(),
h, hRef, tmpdraw, display, AlgoName))
return false;
2120 if (!
drawH1(myC.get(), hist2, 0, tmpdraw, display, AlgoName))
return false;
2122 legend =
new TLegend(0.55, 0.77, 0.87, 0.87);
2123 legend->SetTextFont(62);
2124 legend->SetMargin(0.15);
2125 legend->SetFillStyle(0);
2126 legend->SetBorderSize(0);
2128 std::size_t foundN1 = run_min_LB.find_first_of(
"-");
2129 std::size_t foundN2 = run_min_LB.find_first_of(
',');
2131 legend->AddEntry(
h, (
"Run " + run_min_LB.substr(5, foundN1 - 5)).c_str());
2132 legend->AddEntry(hist2, (
"Run " + run_min_LB.substr(foundN1 + 1, foundN2 - foundN1 - 1)).c_str());
2134 legend->AddEntry(hRef,
"Reference");
2140 t.SetTextSize(0.03);
2141 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
2144 tt.SetTextSize(0.03);
2145 tt.DrawLatex(0.02, 0.01, pathName.c_str());
2154 if (((g =
dynamic_cast<TGraph*
>(hobj)) != 0) && ((g2 =
dynamic_cast<TGraph*
>(hobj2)) != 0)) {
2155 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww, wh);
2157 if (g->GetMinimum() >= 0. && g2->GetMinimum() >= 0. && g->GetMaximum() > 0. && g2->GetMaximum() > 0.) {
2158 gPad->SetLogy(display.find(
"LogY") != std::string::npos);
2162 g->Draw((std::string(
"AP") + drawopt).c_str());
2164 g2->SetMarkerColor(2);
2165 g2->SetLineColor(2);
2166 g2->Draw((std::string(
"P") + drawopt +
" same").c_str());
2169 t.SetTextSize(0.03);
2170 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
2173 tt.SetTextSize(0.03);
2174 tt.DrawLatex(0.02, 0.01, pathName.c_str());
2181 if (((e =
dynamic_cast<TEfficiency*
>(hobj)) != 0) && ((e2 =
dynamic_cast<TEfficiency*
>(hobj2)) != 0)) {
2182 auto myC = std::make_unique<TCanvas>(nameHis.c_str(),
"myC", ww, wh);
2187 e->Draw((std::string(
"AP") + drawopt).c_str());
2191 e->GetPaintedGraph()->GetXaxis()->SetTitleColor();
2194 e2->SetMarkerColor(2);
2195 e2->SetLineColor(2);
2196 e2->Draw((std::string(
"P") + drawopt +
" same").c_str());
2199 t.SetTextSize(0.03);
2200 t.DrawLatex(0.02, 0.04, run_min_LB.c_str());
2203 tt.SetTextSize(0.03);
2204 tt.DrawLatex(0.02, 0.01, pathName.c_str());
2285 size_t found = display.find(
"gaus");
2287 if (found != std::string::npos) {
2288 Double_t minstat = 0.;
2289 std::size_t fpos1, fpos2, fpos;
2290 fpos = display.find(
"MinStat");
2291 if (fpos != std::string::npos) {
2292 fpos1 = display.find(
'(', fpos + 1);
2293 if (fpos1 != std::string::npos) {
2294 fpos2 = display.find(
')', fpos1 + 1);
2295 if (fpos2 != std::string::npos) {
2296 std::string s_minstat = display.substr(fpos1 + 1, fpos2 - fpos1 - 1);
2297 minstat = std::strtod(s_minstat.c_str(), NULL);
2301 std::string fitopt(
"");
2302 fpos = display.find(
"FitOption");
2303 if (fpos != std::string::npos) {
2304 fpos1 = display.find(
'(', fpos + 1);
2305 if (fpos1 != std::string::npos) {
2306 fpos2 = display.find(
')', fpos1 + 1);
2307 if (fpos2 != std::string::npos) {
2308 fitopt = display.substr(fpos1 + 1, fpos2 - fpos1 - 1);
2313 std::size_t found1 = display.find(
"doublegaus");
2314 if (found1 != std::string::npos) {
2315 std::size_t found2 = display.find(
'(', found1 + 1);
2316 if (found2 != std::string::npos) {
2317 std::size_t found3 = display.find(
')', found2 + 1);
2318 if (found3 != std::string::npos) {
2319 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
2320 Double_t
xmin = std::strtod(range.c_str(), NULL);
2321 std::size_t found4 = display.find(
',', found2 + 1);
2322 if (found4 != std::string::npos) {
2323 range = display.substr(found4 + 1, found3 - found4 - 1);
2324 Double_t
xmax = std::strtod(range.c_str(), NULL);
2325 TF1* f1 =
new TF1(
"f1",
"gaus",
xmin,
xmax);
2328 f1->GetParameters(par);
2329 TF1* func =
new TF1(
"func",
"gaus(0)+gaus(3)",
xmin,
xmax);
2330 func->SetParameters(par);
2331 func->SetParameter(3,
h->GetBinContent(
h->GetMaximumBin()));
2332 func->SetParameter(4,
h->GetMean());
2333 func->SetParameter(5, par[2]);
2334 func->SetLineColor(kRed);
2335 func->SetLineWidth(2);
2336 if (
h->GetEffectiveEntries() > minstat) {
2337 h->Fit(func, (
"rq" + fitopt).c_str());
2346 std::size_t found1 = display.find(
"gauspluspol1");
2347 if (found1 != std::string::npos) {
2348 std::size_t found2 = display.find(
'(', found1 + 1);
2349 if (found2 != std::string::npos) {
2350 std::size_t found3 = display.find(
')', found2 + 1);
2351 if (found3 != std::string::npos) {
2352 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
2353 Double_t
xmin = std::strtod(range.c_str(), NULL);
2354 std::size_t found4 = display.find(
',', found2 + 1);
2355 if (found4 != std::string::npos) {
2356 range = display.substr(found4 + 1, found3 - found4 - 1);
2357 Double_t
xmax = std::strtod(range.c_str(), NULL);
2358 TF1* func =
new TF1(
"func",
"gaus(0)+pol1(3)",
xmin,
xmax);
2359 func->SetLineColor(kRed);
2360 func->SetLineWidth(2);
2361 func->SetParameters(
h->GetBinContent(
h->GetMaximumBin()),
h->GetMean(),
h->GetRMS());
2362 if (
h->GetEffectiveEntries() > minstat) {
2363 h->Fit(func, (
"rq" + fitopt).c_str());
2371 found1 = display.find(
"gausplusexpo");
2372 if (found1 != std::string::npos) {
2373 std::size_t found2 = display.find(
'(', found1 + 1);
2374 if (found2 != std::string::npos) {
2375 std::size_t found3 = display.find(
')', found2 + 1);
2376 if (found3 != std::string::npos) {
2377 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
2378 Double_t
xmin = std::strtod(range.c_str(), NULL);
2379 std::size_t found4 = display.find(
',', found2 + 1);
2380 if (found4 != std::string::npos) {
2381 range = display.substr(found4 + 1, found3 - found4 - 1);
2382 Double_t
xmax = std::strtod(range.c_str(), NULL);
2384 TF1* func =
new TF1(
"func",
"gaus(0)+expo(3)",
xmin,
xmax);
2385 func->SetLineColor(kRed);
2386 func->SetLineWidth(2);
2387 func->SetParameters(
h->GetBinContent(
h->GetMaximumBin()),
h->GetMean(),
h->GetRMS());
2388 if (
h->GetEffectiveEntries() > minstat) {
2389 h->Fit(func, (
"rq" + fitopt).c_str());
2397 std::size_t found2 = display.find(
'(', found + 1);
2398 if (found2 != std::string::npos) {
2399 std::size_t found3 = display.find(
')', found2 + 1);
2400 if (found3 != std::string::npos) {
2401 std::string range = display.substr(found2 + 1, found3 - found2 - 1);
2402 Double_t
xmin = std::strtod(range.c_str(), NULL);
2403 std::size_t found4 = display.find(
',', found2 + 1);
2404 if (found4 != std::string::npos) {
2405 range = display.substr(found4 + 1, found3 - found4 - 1);
2406 Double_t
xmax = std::strtod(range.c_str(), NULL);
2407 TF1* func =
new TF1(
"func",
"gaus",
xmin,
xmax);
2408 func->SetLineColor(kRed);
2409 func->SetLineWidth(2);
2410 if (
h->GetEffectiveEntries() > minstat) {
2411 h->Fit(func, (
"rq" + fitopt).c_str());
2421 if (!drawopt.empty()) {
2680 if (display.find(
"RatioPad") == std::string::npos)
return;
2682 unsigned int ww = myC_upperpad->GetWw();
2683 unsigned int wh = myC_upperpad->GetWh();
2684 std::string padname =
"PAD";
2685 std::string padname_ratio =
"PAD_main";
2686 auto myC_ratiopad = std::make_unique<TCanvas>(padname_ratio.c_str(),
"myC_ratiopad", ww, wh);
2687 auto myC_main = std::make_unique<TCanvas>(padname.c_str(),
"myC_main", ww, wh);
2691 myC_ratiopad->SetTopMargin(0);
2692 myC_ratiopad->SetLogx(display.find(
"LogX") != std::string::npos);
2699 TProfile* phRef =
dynamic_cast<TProfile*
>(hRef);
2700 TProfile* ph =
dynamic_cast<TProfile*
>(
h);
2701 std::unique_ptr<TH1F> clonehist;
2702 std::unique_ptr<TH1F> clonehistref;
2705 clonehist.reset((TH1F*) ph->ProjectionX());
2707 clonehist.reset((TH1F*)
h->Clone());
2708 if (!clonehist->GetSumw2()) {
2713 clonehistref.reset((TH1F*) phRef->ProjectionX());
2715 clonehistref.reset((TH1F*) hRef->Clone());
2716 if (!clonehistref->GetSumw2()) {
2717 clonehistref->Sumw2();
2720 if (!clonehist or !clonehistref) {
2723 clonehist->SetBit(kCanDelete);
2724 clonehist->Divide(clonehistref.get());
2728 formatTH1(myC_ratiopad.get(), clonehist.get());
2729 clonehist->SetTitle(
"");
2732 double delta = 0.75;
2733 if (display.find(
"delta(") != std::string::npos) {
2734 delta = std::stod(display.substr(display.find(
"delta(") + 6));
2736 clonehist->SetAxisRange(1. - delta, 1. + delta,
"Y");
2738 clonehist->GetYaxis()->SetNdivisions(3,
true);
2739 clonehist->SetMarkerStyle(1);
2740 clonehist->Draw(
"E");
2741 clonehist->GetXaxis()->SetTitleSize(0.11);
2742 clonehist->GetXaxis()->SetLabelSize(0.11);
2743 clonehist->GetYaxis()->SetTitleSize(0.11);
2744 clonehist->GetYaxis()->SetLabelSize(0.11);
2746 TPad* lowerPad =
new TPad(
"lowerPad",
"lowerPad", .005, .060, .995, .250);
2747 lowerPad->SetTopMargin(0);
2748 lowerPad->SetFillStyle(0);
2750 TPad* upperPad =
new TPad(
"upperPad",
"upperPad", .005, .250, .995, .995);
2751 upperPad->SetBottomMargin(0);
2752 upperPad->SetFillStyle(0);
2756 myC_ratiopad->DrawClonePad();
2759 line.SetLineColor(kRed);
2760 line.SetLineWidth(1);
2762 double xmin = clonehist->GetXaxis()->GetXmin();
2763 double xmax = clonehist->GetXaxis()->GetXmax();
2768 myC_upperpad->SetBottomMargin(0);
2769 myC_upperpad->SetFillStyle(0);
2770 h->GetXaxis()->SetLabelSize(0.);
2771 h->GetXaxis()->SetTitleSize(0.);
2772 myC_upperpad->DrawClonePad();
2774 myC_upperpad->Clear();
2775 myC_main->DrawClonePad();
2777 std::ignore = clonehist.release();
2781 for (TObject* o : *(myC_main->GetListOfPrimitives())) {
2782 o->SetBit(kCanDelete);
2783 if (
auto* o2 =
dynamic_cast<TPad*
>(o)) {
2784 for (
auto* o3: *(o2->GetListOfPrimitives())) {
2785 if (!
dynamic_cast<TFrame*
>(o3)) {
2786 o3->SetBit(kCanDelete);
2795 for (TObject* o : *(myC_upperpad->GetListOfPrimitives())) {
2796 o->SetBit(kCanDelete);
2797 if (
auto* o2 =
dynamic_cast<TPad*
>(o)) {
2798 for (
auto* o3: *(o2->GetListOfPrimitives())) {
2799 if (!
dynamic_cast<TFrame*
>(o3)) {
2800 o3->SetBit(kCanDelete);
2808 if (display.find(
"Ref2DRatio") == std::string::npos && display.find(
"Ref2DSignif") == std::string::npos)
return;
2811 std::make_unique<TCanvas>(
"canvas_bottom",
"canvas_bottom", canvas_top->GetWw(), canvas_top->GetWh());
2812 auto canvas_all = std::make_unique<TCanvas>(
"canvas_all",
"canvas_all", canvas_top->GetWw(), canvas_top->GetWh());
2815 canvas_bot->SetTopMargin(0);
2817 h2Ref->Scale(h2->Integral() / h2Ref->Integral());
2819 TH2* comparison = (TH2*) (h2->Clone());
2820 comparison->Divide(h2, h2Ref, 1.0, 1.0);
2821 comparison->SetTitle(
"");
2822 formatTH2(canvas_bot.get(), comparison);
2824 if (display.find(
"Ref2DRatio") != std::string::npos) {
2825 comparison->GetZaxis()->SetTitle(
"ratio to ref.");
2826 comparison->SetAxisRange(0.0, 2.0,
"Z");
2827 }
else if (display.find(
"Ref2DSignif") != std::string::npos) {
2828 comparison->GetZaxis()->SetTitle(
"difference to ref. (#sigma)");
2829 comparison->SetAxisRange(-4.5, 4.5,
"Z");
2837 for (
int binx = 0; binx <= comparison->GetNbinsX(); binx++) {
2838 for (
int biny = 0; biny <= comparison->GetNbinsY(); biny++) {
2839 value_a = h2->GetBinContent(binx, biny);
2840 value_b = h2Ref->GetBinContent(binx, biny);
2842 sigma_a = h2->GetBinError(binx, biny);
2843 sigma_b = h2Ref->GetBinError(binx, biny);
2845 if (sigma_a == 0 && sigma_b == 0) signif = 0;
2846 else signif = (value_a - value_b) / sqrt((sigma_a * sigma_a + sigma_b * sigma_b));
2848 comparison->SetBinContent(binx, biny, signif);
2853 comparison->Draw(
"colz");
2856 TPad* pad_bot =
new TPad(
"pad_bot",
"pad_bot", 0.005, 0.060, 0.995, 0.550);
2857 TPad* pad_top =
new TPad(
"pad_top",
"pad_top", 0.005, 0.550, 0.995, 0.995);
2859 pad_bot->SetTopMargin(0);
2860 pad_top->SetBottomMargin(0);
2862 pad_bot->SetFillStyle(0);
2863 pad_top->SetFillStyle(0);
2869 canvas_bot->DrawClonePad();
2872 canvas_top->SetBottomMargin(0);
2873 canvas_top->SetFillStyle(0);
2874 h2->GetXaxis()->SetLabelSize(0.);
2875 h2->GetXaxis()->SetTitleSize(0.);
2876 canvas_top->DrawClonePad();
2878 canvas_top->Clear();
2880 canvas_all->DrawClonePad();
2915 std::size_t found =
str.find(
"TLine");
2916 while (found != std::string::npos) {
2917 std::size_t found1 =
str.find_first_of(
')', found + 1);
2918 if (found1 != std::string::npos) {
2919 std::string coordinates =
str.substr(found + 6, found1 - found - 6);
2921 if (found1 <
str.size() - 3 &&
str.substr(found1 + 1, 3) ==
"NDC") {
2924 found1 = coordinates.find_first_of(
',');
2925 if (found1 != std::string::npos) {
2926 std::string cx1 = coordinates.substr(0, found1);
2927 double x1 = std::strtod(cx1.c_str(), NULL);
2928 std::size_t found2 = coordinates.find_first_of(
',', found1 + 1);
2929 if (found2 != std::string::npos) {
2930 std::string cy1 = coordinates.substr(found1 + 1, found2 - found1 - 1);
2931 double y1 = std::strtod(cy1.c_str(), NULL);
2932 found1 = coordinates.find_first_of(
',', found2 + 1);
2933 if (found1 != std::string::npos) {
2934 std::string cx2 = coordinates.substr(found2 + 1, found1 - found2 - 1);
2935 double x2 = std::strtod(cx2.c_str(), NULL);
2936 std::string cy2 = coordinates.substr(found1 + 1, coordinates.size());
2937 double y2 = std::strtod(cy2.c_str(), NULL);
2939 TLine* L =
new TLine;
2941 if (x1 <= 1.0 && x1 >= 0.0 && x2 <= 1.0 && x2 >= 0.0 && y1 <= 1.0 && y1 >= 0.0 && y2 <= 1.0 &&
2943 L->DrawLineNDC(x1, y1, x2, y2);
2946 L->DrawLine(x1, y1, x2, y2);
2952 found =
str.find(
"TLine", found + 1);
2955 found =
str.find(
"TText");
2956 while (found != std::string::npos) {
2957 std::string coordinates, cx1, cy1 =
"";
2958 std::size_t found1 =
str.find_first_of(
')', found + 1);
2959 std::size_t found2 =
str.find_first_of(
'\'', found + 1);
2960 if (found2 != std::string::npos) {
2961 found2 =
str.find_first_of(
'\"', found2 + 1);
2962 if (found2 != std::string::npos && found1 < found2) {
2963 found1 =
str.find_first_of(
')', found2 + 1);
2966 if (found1 != std::string::npos) {
2967 coordinates =
str.substr(found + 6, found1 - found - 6);
2969 if (found1 <
str.size() - 3 &&
str.substr(found1 + 1, 3) ==
"NDC") {
2972 found1 = coordinates.find_first_of(
',');
2973 if (found1 != std::string::npos) {
2974 cx1 = coordinates.substr(0, found1);
2975 double x1 = std::strtod(cx1.c_str(), NULL);
2976 found2 = coordinates.find_first_of(
',', found1 + 1);
2977 if (found2 != std::string::npos) {
2978 cy1 = coordinates.substr(found1 + 1, found2 - found1 - 1);
2979 double y1 = std::strtod(cy1.c_str(), NULL);
2980 std::string txt = coordinates.substr(found2 + 2, coordinates.size());
2983 TText* T =
new TText;
2985 if (x1 <= 1.0 && x1 >= 0.0 && y1 <= 1.0 && y1 >= 0.0) {
2986 T->DrawTextNDC(x1, y1, txt.c_str());
2989 T->DrawText(x1, y1, txt.c_str());
2994 found =
str.find(
"TText", found + 1);
2997 found =
str.find(
"TDota");
2998 while (found != std::string::npos) {
2999 std::size_t found1 =
str.find_first_of(
')', found + 1);
3000 if (found1 != std::string::npos) {
3001 std::string coordinates =
str.substr(found + 6, found1 - found - 6);
3003 if (found1 <
str.size() - 3 &&
str.substr(found1 + 1, 3) ==
"NDC") {
3006 found1 = coordinates.find_first_of(
',');
3007 if (found1 != std::string::npos) {
3008 std::string cx1 = coordinates.substr(0, found1);
3009 double x1 = std::strtod(cx1.c_str(), NULL);
3010 std::size_t found2 = coordinates.find_first_of(
',', found1 + 1);
3011 if (found2 != std::string::npos) {
3012 std::string cy1 = coordinates.substr(found1 + 1, found2 - found1 - 1);
3013 double y1 = std::strtod(cy1.c_str(), NULL);
3014 found1 = coordinates.find_first_of(
',', found2 + 1);
3015 if (found1 != std::string::npos) {
3016 std::string cx2 = coordinates.substr(found2 + 1, found1 - found2 - 1);
3017 double x2 = std::strtod(cx2.c_str(), NULL);
3018 std::string cy2 = coordinates.substr(found1 + 1, coordinates.size());
3019 double y2 = std::strtod(cy2.c_str(), NULL);
3021 TLine* L =
new TLine;
3024 if (x1 <= 1.0 && x1 >= 0.0 && x2 <= 1.0 && x2 >= 0.0 && y1 <= 1.0 && y1 >= 0.0 && y2 <= 1.0 &&
3026 L->DrawLineNDC(x1, y1, x2, y2);
3029 L->DrawLine(x1, y1, x2, y2);
3035 found =
str.find(
"TDota", found + 1);
3038 found =
str.find(
"TSize");
3039 while (found != std::string::npos) {
3040 std::string coordinates, cx1, cy1, txtsize =
"";
3041 std::size_t found1 =
str.find_first_of(
')', found + 1);
3042 std::size_t found2 =
str.find_first_of(
'\'', found + 1);
3043 if (found2 != std::string::npos) {
3044 found2 =
str.find_first_of(
'\"', found2 + 1);
3045 if (found2 != std::string::npos && found1 < found2) {
3046 found1 =
str.find_first_of(
')', found2 + 1);
3049 if (found1 != std::string::npos) {
3050 coordinates =
str.substr(found + 6, found1 - found - 6);
3052 if (found1 <
str.size() - 3 &&
str.substr(found1 + 1, 3) ==
"NDC") {
3055 found1 = coordinates.find_first_of(
',');
3056 if (found1 != std::string::npos) {
3057 cx1 = coordinates.substr(0, found1);
3058 double x1 = std::strtod(cx1.c_str(), NULL);
3059 found2 = coordinates.find_first_of(
',', found1 + 1);
3060 if (found2 != std::string::npos) {
3061 cy1 = coordinates.substr(found1 + 1, found2 - found1 - 1);
3062 double y1 = std::strtod(cy1.c_str(), NULL);
3063 std::size_t found3 = coordinates.find_first_of(
',', found2 + 1);
3064 if (found3 != std::string::npos) {
3065 txtsize = coordinates.substr(found2 + 1, found3 - found2 - 1);
3066 double size = std::strtod(txtsize.c_str(), NULL);
3067 std::string txt = coordinates.substr(found3 + 2, coordinates.size());
3070 TText* T =
new TText;
3071 T->SetTextSize(size / 100);
3073 if (x1 <= 1.0 && x1 >= 0.0 && y1 <= 1.0 && y1 >= 0.0) {
3074 T->DrawTextNDC(x1, y1, txt.c_str());
3077 T->DrawText(x1, y1, txt.c_str());
3083 found =
str.find(
"TSize", found + 1);