From cb2c09ebf873d97b23d3f5f70df85bf5a8840e2f Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 11:24:03 +0100 Subject: [PATCH 01/12] [hist] raise error of badly sorted edges as with variable binwidth --- hist/hist/src/TAxis.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hist/hist/src/TAxis.cxx b/hist/hist/src/TAxis.cxx index 5b6c0ae65dff9..cf8b9d62b12b2 100644 --- a/hist/hist/src/TAxis.cxx +++ b/hist/hist/src/TAxis.cxx @@ -27,6 +27,7 @@ #include "snprintf.h" #include +#include #include #include @@ -779,10 +780,17 @@ void TAxis::SaveAttributes(std::ostream &out, const char *name, const char *subn //////////////////////////////////////////////////////////////////////////////// /// Initialize axis with fix bins +/// +/// An error is printed if xup <= xlow +/// or in any of them is infinite (due to resulting undefined fixed bin width) void TAxis::Set(Int_t nbins, Double_t xlow, Double_t xup) { fNbins = nbins; + if (xup <= xlow) + Error("TAxis::Set", "upper edge must be strictly higher than lower edge"); + if (std::isinf(xlow) || std::isinf(xup)) + Error("TAxis::Set", "fixed binwidth not compatible with infinite lower/upper edges"); fXmin = xlow; fXmax = xup; if (!fParent) SetDefaults(); @@ -791,6 +799,8 @@ void TAxis::Set(Int_t nbins, Double_t xlow, Double_t xup) //////////////////////////////////////////////////////////////////////////////// /// Initialize axis with variable bins +/// +/// An error is printed if bin edges are not in strictly increasing order void TAxis::Set(Int_t nbins, const Float_t *xbins) { @@ -801,7 +811,7 @@ void TAxis::Set(Int_t nbins, const Float_t *xbins) fXbins.fArray[bin] = xbins[bin]; for (bin=1; bin<= fNbins; bin++) if (fXbins.fArray[bin] <= fXbins.fArray[bin - 1]) - Error("TAxis::Set", "bins must be in increasing order"); + Error("TAxis::Set", "bin edges must be in increasing order"); fXmin = fXbins.fArray[0]; fXmax = fXbins.fArray[fNbins]; if (!fParent) SetDefaults(); From 85d222accc8b5c4cfde12684368fb3b21b6c9213 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 11:27:34 +0100 Subject: [PATCH 02/12] [test] further test cases --- hist/hist/test/test_TH1.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hist/hist/test/test_TH1.cxx b/hist/hist/test/test_TH1.cxx index 73d4ba9f5cef1..de4b5801e1fc9 100644 --- a/hist/hist/test/test_TH1.cxx +++ b/hist/hist/test/test_TH1.cxx @@ -318,5 +318,8 @@ TEST(TH1, SetBufferedSumw2) // https://github.com/root-project/root/issues/20185 TEST(TAxis, EqualBinEdges) { - ROOT_EXPECT_ERROR(TAxis _({1, 1}), "TAxis::Set", "bins must be in increasing order"); + ROOT_EXPECT_ERROR(TAxis _({1, 1}), "TAxis::Set", "bin edges must be in increasing order"); + ROOT_EXPECT_ERROR(TAxis _(1, 1, 0), "TAxis::Set", "upper edge must be strictly higher than lower edge"); + ROOT_EXPECT_ERROR(TAxis _(1, -std::numeric_limits::infinity(), 0), "TAxis::Set", "fixed binwidth not compatible with infinite lower/upper edges"); + ROOT_EXPECT_ERROR(TAxis _(1, 0. std::numeric_limits::infinity()), "TAxis::Set", "fixed binwidth not compatible with infinite lower/upper edges"); } From 936489beffc774e087e0c2abb3a0c68f2de8ed82 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 11:34:20 +0100 Subject: [PATCH 03/12] [hist7] throw when passing inf and nan edges --- hist/histv7/inc/ROOT/RRegularAxis.hxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hist/histv7/inc/ROOT/RRegularAxis.hxx b/hist/histv7/inc/ROOT/RRegularAxis.hxx index e5961bc93bb7c..92cb8047b5ea5 100644 --- a/hist/histv7/inc/ROOT/RRegularAxis.hxx +++ b/hist/histv7/inc/ROOT/RRegularAxis.hxx @@ -10,6 +10,7 @@ #include "RLinearizedIndex.hxx" #include +#include #include #include #include @@ -66,6 +67,13 @@ public: std::string msg = "high must be > low, but " + std::to_string(fLow) + " >= " + std::to_string(fHigh); throw std::invalid_argument(msg); } + if (std::isinf(fLow) || std::isinf(fHigh)) { + std::string msg = "both low and high must be finite, but are: " + std::to_string(fLow) + " and" + std::to_string(fHigh); + throw std::invalid_argument(msg); + } else if (std::isnan(fLow) || std::isnan(fHigh)) { + std::string msg = "neither low nor high can be nan, but are: " + std::to_string(fLow) + " and" + std::to_string(fHigh); + throw std::invalid_argument(msg); + } fInvBinWidth = nNormalBins / (fHigh - fLow); } From 1b73339076cde685fc0b6a509123d27c749c8369 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 11:36:50 +0100 Subject: [PATCH 04/12] [hist] warn when nan edges --- hist/hist/src/TAxis.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hist/hist/src/TAxis.cxx b/hist/hist/src/TAxis.cxx index cf8b9d62b12b2..c0e4df5abbbd1 100644 --- a/hist/hist/src/TAxis.cxx +++ b/hist/hist/src/TAxis.cxx @@ -791,6 +791,8 @@ void TAxis::Set(Int_t nbins, Double_t xlow, Double_t xup) Error("TAxis::Set", "upper edge must be strictly higher than lower edge"); if (std::isinf(xlow) || std::isinf(xup)) Error("TAxis::Set", "fixed binwidth not compatible with infinite lower/upper edges"); + if (std::isnan(xlow) || std::isnan(xup)) + Error("TAxis::Set", "lower/upper edges should not be NaN"); fXmin = xlow; fXmax = xup; if (!fParent) SetDefaults(); From d9917a846ea83378986a73cca2d2a1988fe42b00 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 11:41:14 +0100 Subject: [PATCH 05/12] [test] missing comma --- hist/hist/test/test_TH1.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hist/hist/test/test_TH1.cxx b/hist/hist/test/test_TH1.cxx index de4b5801e1fc9..7a749a3ccaf55 100644 --- a/hist/hist/test/test_TH1.cxx +++ b/hist/hist/test/test_TH1.cxx @@ -321,5 +321,5 @@ TEST(TAxis, EqualBinEdges) ROOT_EXPECT_ERROR(TAxis _({1, 1}), "TAxis::Set", "bin edges must be in increasing order"); ROOT_EXPECT_ERROR(TAxis _(1, 1, 0), "TAxis::Set", "upper edge must be strictly higher than lower edge"); ROOT_EXPECT_ERROR(TAxis _(1, -std::numeric_limits::infinity(), 0), "TAxis::Set", "fixed binwidth not compatible with infinite lower/upper edges"); - ROOT_EXPECT_ERROR(TAxis _(1, 0. std::numeric_limits::infinity()), "TAxis::Set", "fixed binwidth not compatible with infinite lower/upper edges"); + ROOT_EXPECT_ERROR(TAxis _(1, 0., std::numeric_limits::infinity()), "TAxis::Set", "fixed binwidth not compatible with infinite lower/upper edges"); } From 45552c83dddf06bedae3d2553d6c7db1d76ca6da Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 12:42:00 +0100 Subject: [PATCH 06/12] [hist] missed one --- hist/hist/src/TAxis.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hist/hist/src/TAxis.cxx b/hist/hist/src/TAxis.cxx index c0e4df5abbbd1..7826da3f506af 100644 --- a/hist/hist/src/TAxis.cxx +++ b/hist/hist/src/TAxis.cxx @@ -831,7 +831,7 @@ void TAxis::Set(Int_t nbins, const Double_t *xbins) fXbins.fArray[bin] = xbins[bin]; for (bin=1; bin<= fNbins; bin++) if (fXbins.fArray[bin] <= fXbins.fArray[bin - 1]) - Error("TAxis::Set", "bins must be in increasing order"); + Error("TAxis::Set", "bin edges must be in increasing order"); fXmin = fXbins.fArray[0]; fXmax = fXbins.fArray[fNbins]; if (!fParent) SetDefaults(); From 92c7de7099ca919aff516617614b5cb8aefe056f Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 12:43:40 +0100 Subject: [PATCH 07/12] [hist] more verbose error --- hist/hist/src/TAxis.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hist/hist/src/TAxis.cxx b/hist/hist/src/TAxis.cxx index 7826da3f506af..f965774268e39 100644 --- a/hist/hist/src/TAxis.cxx +++ b/hist/hist/src/TAxis.cxx @@ -788,7 +788,7 @@ void TAxis::Set(Int_t nbins, Double_t xlow, Double_t xup) { fNbins = nbins; if (xup <= xlow) - Error("TAxis::Set", "upper edge must be strictly higher than lower edge"); + Error("TAxis::Set", "upper edge %g must be strictly higher than lower edge %g", xup, xlow); if (std::isinf(xlow) || std::isinf(xup)) Error("TAxis::Set", "fixed binwidth not compatible with infinite lower/upper edges"); if (std::isnan(xlow) || std::isnan(xup)) From d5a3b9d6cab8f33ca5c16461aa3f9daa4662a82e Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 12:57:31 +0100 Subject: [PATCH 08/12] [hist] avoid zero-bin-width in def constructor --- hist/hist/src/TH2Poly.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hist/hist/src/TH2Poly.cxx b/hist/hist/src/TH2Poly.cxx index 0ee3531957bf8..1ae34f478c878 100644 --- a/hist/hist/src/TH2Poly.cxx +++ b/hist/hist/src/TH2Poly.cxx @@ -18,7 +18,7 @@ #include "TList.h" #include "TMath.h" #include - +#include /** \class TH2Poly \ingroup Histograms @@ -146,7 +146,7 @@ times, it is better to divide into a small number of cells. TH2Poly::TH2Poly() { - Initialize(0., 0., 0., 0., 25, 25); + Initialize(0., std::numeric_limits::epsilon(), 0., std::numeric_limits::epsilon(), 25, 25); SetName("NoName"); SetTitle("NoTitle"); SetFloat(); From 60ad68eedeaceede0a3e95b8cd8afe077390ae78 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 13:02:25 +0100 Subject: [PATCH 09/12] [tree] avoid zero binwidth --- tree/treeplayer/src/TSelectorDraw.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tree/treeplayer/src/TSelectorDraw.cxx b/tree/treeplayer/src/TSelectorDraw.cxx index e1830a6751658..53312fe27edc5 100644 --- a/tree/treeplayer/src/TSelectorDraw.cxx +++ b/tree/treeplayer/src/TSelectorDraw.cxx @@ -36,7 +36,7 @@ A specialized TSelector for TTree::Draw. #include "TClass.h" #include "TColor.h" #include "strlcpy.h" - +#include const Int_t kCustomHistogram = BIT(17); @@ -573,6 +573,7 @@ void TSelectorDraw::Begin(TTree *tree) fNbins[0] = hist->GetXaxis()->GetNbins(); } else { TString precision = gEnv->GetValue("Hist.Precision.1D", "float"); + auto delta = fVmin[0] == fVmax[0] ? std::numeric_limits::epsilon() : 0; if (precision.Contains("float")) { hist = new TH1F(hname, htitle.Data(), fNbins[0], fVmin[0], fVmax[0]); } else { From baee8b7fa858d589fdeb4eae0e288b2660df67ec Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 13:06:43 +0100 Subject: [PATCH 10/12] [tree] safety against zero-bin-width --- tree/treeplayer/src/TSelectorDraw.cxx | 38 ++++++++++++++++----------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/tree/treeplayer/src/TSelectorDraw.cxx b/tree/treeplayer/src/TSelectorDraw.cxx index 53312fe27edc5..9d4c6fe485ad9 100644 --- a/tree/treeplayer/src/TSelectorDraw.cxx +++ b/tree/treeplayer/src/TSelectorDraw.cxx @@ -573,11 +573,11 @@ void TSelectorDraw::Begin(TTree *tree) fNbins[0] = hist->GetXaxis()->GetNbins(); } else { TString precision = gEnv->GetValue("Hist.Precision.1D", "float"); - auto delta = fVmin[0] == fVmax[0] ? std::numeric_limits::epsilon() : 0; + auto delta = fVmin[0] == fVmax[0] ? std::numeric_limits::epsilon() : 0.; if (precision.Contains("float")) { - hist = new TH1F(hname, htitle.Data(), fNbins[0], fVmin[0], fVmax[0]); + hist = new TH1F(hname, htitle.Data(), fNbins[0], fVmin[0], fVmax[0] + delta); } else { - hist = new TH1D(hname, htitle.Data(), fNbins[0], fVmin[0], fVmax[0]); + hist = new TH1D(hname, htitle.Data(), fNbins[0], fVmin[0], fVmax[0] + delta); } hist->SetLineColor(fTree->GetLineColor()); hist->SetLineWidth(fTree->GetLineWidth()); @@ -653,14 +653,15 @@ void TSelectorDraw::Begin(TTree *tree) fVmax[1] = oldhtemp->GetXaxis()->GetXmax(); } } + auto delta = fVmin[1] == fVmax[1] ? std::numeric_limits::epsilon() : 0.; if (opt.Contains("profs")) { - hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], "s"); + hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1] + delta, "s"); } else if (opt.Contains("profi")) { - hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], "i"); + hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1] + delta, "i"); } else if (opt.Contains("profg")) { - hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], "g"); + hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1] + delta, "g"); } else { - hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], ""); + hp = new TProfile(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1] + delta, ""); } if (!hkeep) { hp->SetBit(kCanDelete); @@ -685,10 +686,12 @@ void TSelectorDraw::Begin(TTree *tree) h2 = (TH2F*)fOldHistogram; } else { TString precision = gEnv->GetValue("Hist.Precision.2D", "float"); + auto delta0 = fVmin[0] == fVmax[0] ? std::numeric_limits::epsilon() : 0.; + auto delta1 = fVmin[1] == fVmax[1] ? std::numeric_limits::epsilon() : 0.; if (precision.Contains("float")) { - h2 = new TH2F(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], fNbins[0], fVmin[0], fVmax[0]); + h2 = new TH2F(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1] + delta1, fNbins[0], fVmin[0], fVmax[0] + delta0); } else { - h2 = new TH2D(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1], fNbins[0], fVmin[0], fVmax[0]); + h2 = new TH2D(hname, htitle.Data(), fNbins[1], fVmin[1], fVmax[1] + delta1, fNbins[0], fVmin[0], fVmax[0] + delta0); } h2->SetLineColor(fTree->GetLineColor()); h2->SetLineWidth(fTree->GetLineWidth()); @@ -795,14 +798,16 @@ void TSelectorDraw::Begin(TTree *tree) fVmax[1] = ymax; if (xmin < xmax && ymin < ymax) canExtend = false; } + auto delta1 = fVmin[1] == fVmax[1] ? std::numeric_limits::epsilon() : 0.; + auto delta2 = fVmin[2] == fVmax[2] ? std::numeric_limits::epsilon() : 0.; if (opt.Contains("profs")) { - hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], "s"); + hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2] + delta2, fNbins[1], fVmin[1], fVmax[1] + delta1, "s"); } else if (opt.Contains("profi")) { - hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], "i"); + hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2] + delta2, fNbins[1], fVmin[1], fVmax[1] + delta1, "i"); } else if (opt.Contains("profg")) { - hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], "g"); + hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2] + delta2, fNbins[1], fVmin[1], fVmax[1] + delta1, "g"); } else { - hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], ""); + hp = new TProfile2D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2] + delta2, fNbins[1], fVmin[1], fVmax[1] + delta1, ""); } if (!hkeep) { hp->SetBit(kCanDelete); @@ -855,10 +860,13 @@ void TSelectorDraw::Begin(TTree *tree) h3 = (TH3F*)fOldHistogram; } else { TString precision = gEnv->GetValue("Hist.Precision.3D", "float"); + auto delta0 = fVmin[0] == fVmax[0] ? std::numeric_limits::epsilon() : 0.; + auto delta1 = fVmin[1] == fVmax[1] ? std::numeric_limits::epsilon() : 0.; + auto delta2 = fVmin[2] == fVmax[2] ? std::numeric_limits::epsilon() : 0.; if (precision.Contains("float")) { - h3 = new TH3F(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], fNbins[0], fVmin[0], fVmax[0]); + h3 = new TH3F(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2] + delta2, fNbins[1], fVmin[1], fVmax[1] + delta1, fNbins[0], fVmin[0], fVmax[0] + delta0); } else { - h3 = new TH3D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2], fNbins[1], fVmin[1], fVmax[1], fNbins[0], fVmin[0], fVmax[0]); + h3 = new TH3D(hname, htitle.Data(), fNbins[2], fVmin[2], fVmax[2] + delta2, fNbins[1], fVmin[1], fVmax[1] + delta1, fNbins[0], fVmin[0], fVmax[0] + delta0); } h3->SetLineColor(fTree->GetLineColor()); h3->SetLineWidth(fTree->GetLineWidth()); From 2c7b38e660c2a44b52c4490aa846b90bc0faa081 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 13:53:17 +0100 Subject: [PATCH 11/12] Update test_TH1.cxx --- hist/hist/test/test_TH1.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hist/hist/test/test_TH1.cxx b/hist/hist/test/test_TH1.cxx index 7a749a3ccaf55..eb40fd4d9e6fb 100644 --- a/hist/hist/test/test_TH1.cxx +++ b/hist/hist/test/test_TH1.cxx @@ -319,7 +319,7 @@ TEST(TH1, SetBufferedSumw2) TEST(TAxis, EqualBinEdges) { ROOT_EXPECT_ERROR(TAxis _({1, 1}), "TAxis::Set", "bin edges must be in increasing order"); - ROOT_EXPECT_ERROR(TAxis _(1, 1, 0), "TAxis::Set", "upper edge must be strictly higher than lower edge"); + ROOT_EXPECT_ERROR(TAxis _(1, 1, 0), "TAxis::Set", "upper edge 0 must be strictly higher than lower edge 1"); ROOT_EXPECT_ERROR(TAxis _(1, -std::numeric_limits::infinity(), 0), "TAxis::Set", "fixed binwidth not compatible with infinite lower/upper edges"); ROOT_EXPECT_ERROR(TAxis _(1, 0., std::numeric_limits::infinity()), "TAxis::Set", "fixed binwidth not compatible with infinite lower/upper edges"); } From 7a477d36c6313a1eb87f5a4ddd4272b46e1ab9f7 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 26 Oct 2025 13:55:35 +0100 Subject: [PATCH 12/12] Update stressHistogram.cxx --- test/stressHistogram.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/stressHistogram.cxx b/test/stressHistogram.cxx index bfb7361a83806..81cc198ccbcd4 100644 --- a/test/stressHistogram.cxx +++ b/test/stressHistogram.cxx @@ -6269,26 +6269,26 @@ bool testMerge1DWithBuffer(bool allNoLimits) // where different axis are used, BUT the largest bin width must be // a multiple of the smallest bin width - double x1 = 1; double x2 = 0; + double x1 = 0; double x2 = 1; if (!allNoLimits) { // case when one of the histogram has limits (mix mode) x1 = minRange; x2 = maxRange; } - TH1D* h0 = new TH1D("h0", "h0-Title", numberOfBins, 1, 0); + TH1D* h0 = new TH1D("h0", "h0-Title", numberOfBins, 0, 1); TH1D* h1 = new TH1D("h1", "h1-Title", numberOfBins, x1, x2); - TH1D* h2 = new TH1D("h2", "h2-Title", 1,1,0); - TH1D* h3 = new TH1D("h3", "h3-Title", 1,1,0); - TH1D* h4 = new TH1D("h4", "h4-Title", numberOfBins, x1,x2); + TH1D* h2 = new TH1D("h2", "h2-Title", 1, 0, 1); + TH1D* h3 = new TH1D("h3", "h3-Title", 1, 0, 1); + TH1D* h4 = new TH1D("h4", "h4-Title", numberOfBins, x1, x2); h0->Sumw2(); h1->Sumw2();h2->Sumw2();h4->Sumw2(); // The below histograms will be merged into h0, so they all need to fit into the buffer. // Otherwise, the axis ranges will be computed already during the partial merge. h0->SetBuffer(nEvents * 10); - h1->SetBuffer(nEvents*10); - h2->SetBuffer(nEvents*10); - h3->SetBuffer(nEvents*10); - h4->SetBuffer(nEvents*10); + h1->SetBuffer(nEvents * 10); + h2->SetBuffer(nEvents * 10); + h3->SetBuffer(nEvents * 10); + h4->SetBuffer(nEvents * 10); for ( Int_t e = 0; e < nEvents; ++e ) {