Skip to content

Commit cff5bf8

Browse files
linevdpiparo
authored andcommitted
Fix SavePrimitive for histograms and profiles
By mistake variable name and not real histogram name was written into produced ROOT macro. As result, after execution of such macro wrong histogram name appears in stats box. Was not directly detected by stressGraphics tests
1 parent 9e0d890 commit cff5bf8

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

hist/hist/src/TH1.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7344,7 +7344,7 @@ void TH1::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
73447344
constexpr auto max_precision{std::numeric_limits<double>::digits10 + 1};
73457345
out << std::setprecision(max_precision);
73467346

7347-
out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << hname << "\", \""
7347+
out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << TString(savedName).ReplaceSpecialCppChars() << "\", \""
73487348
<< TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << GetXaxis()->GetNbins();
73497349
if (!sxaxis.IsNull())
73507350
out << ", " << sxaxis << ".data()";

hist/hist/src/TH2Poly.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ void TH2Poly::SavePrimitive(std::ostream &out, Option_t *option)
13261326
out << " \n";
13271327

13281328
// Construct the class initialization
1329-
out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << hname << "\", \""
1329+
out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << TString(GetName()).ReplaceSpecialCppChars() << "\", \""
13301330
<< TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << fCellX << ", " << fXaxis.GetXmin() << ", "
13311331
<< fXaxis.GetXmax() << ", " << fCellY << ", " << fYaxis.GetXmin() << ", " << fYaxis.GetXmax() << ");\n";
13321332

hist/hist/src/TProfile.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ void TProfile::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
16511651
if (GetXaxis()->GetXbins()->fN && GetXaxis()->GetXbins()->fArray)
16521652
sxaxis = SavePrimitiveVector(out, hname + "_x", GetXaxis()->GetXbins()->fN, GetXaxis()->GetXbins()->fArray);
16531653

1654-
out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << hname << "\", \""
1654+
out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << TString(GetName()).ReplaceSpecialCppChars() << "\", \""
16551655
<< TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << GetXaxis()->GetNbins() << ", ";
16561656
if (!sxaxis.IsNull())
16571657
out << sxaxis << ".data()";

hist/hist/src/TProfile2D.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ void TProfile2D::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
18941894
if (GetYaxis()->GetXbins()->fN && GetYaxis()->GetXbins()->fArray)
18951895
syaxis = SavePrimitiveVector(out, hname + "_y", GetYaxis()->GetXbins()->fN, GetYaxis()->GetXbins()->fArray);
18961896

1897-
out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << hname << "\", \""
1897+
out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << TString(GetName()).ReplaceSpecialCppChars() << "\", \""
18981898
<< TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << GetXaxis()->GetNbins() << ", ";
18991899
if (!sxaxis.IsNull())
19001900
out << sxaxis << ".data()";

hist/hist/src/TProfile3D.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ void TProfile3D::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
12591259
szaxis = SavePrimitiveVector(out, hname + "_z", GetZaxis()->GetXbins()->fN, GetZaxis()->GetXbins()->fArray);
12601260
}
12611261

1262-
out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << hname << "\", \""
1262+
out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << TString(GetName()).ReplaceSpecialCppChars() << "\", \""
12631263
<< TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << GetXaxis()->GetNbins() << ", ";
12641264
if (!sxaxis.IsNull())
12651265
out << sxaxis << ".data()";

0 commit comments

Comments
 (0)