diff --git a/hist/hist/src/TProfile3D.cxx b/hist/hist/src/TProfile3D.cxx index 4756da07a4778..261d2f96a9b30 100644 --- a/hist/hist/src/TProfile3D.cxx +++ b/hist/hist/src/TProfile3D.cxx @@ -814,7 +814,8 @@ void TProfile3D::GetStats(Double_t *stats) const if (fBuffer) ((TProfile3D*)this)->BufferEmpty(); // Loop on bins - if ( (fTsumw == 0 /* && fEntries > 0 */) || fXaxis.TestBit(TAxis::kAxisRange) || fYaxis.TestBit(TAxis::kAxisRange)) { + if ((fTsumw == 0 /* && fEntries > 0 */) || fXaxis.TestBit(TAxis::kAxisRange) || fYaxis.TestBit(TAxis::kAxisRange) || + fZaxis.TestBit(TAxis::kAxisRange)) { // check for labels axis . In that case corresponding statistics do not make sense and it is set to zero Bool_t labelXaxis = ((const_cast(fXaxis)).GetLabels() && fXaxis.CanExtend()); @@ -826,11 +827,38 @@ void TProfile3D::GetStats(Double_t *stats) const Double_t x,y,z; for (bin=0;binSetRange(1, 1); + + EXPECT_DOUBLE_EQ(0.5, profile.GetMean(1)); + EXPECT_DOUBLE_EQ(1., profile.GetMean(2)); + EXPECT_DOUBLE_EQ(5., profile.GetMean(3)); +} + +TEST(TProfile3D, GetStatsHonoursStatOverflowsWithZRange) +{ + TProfile3D profile("profile", "", 2, 0, 4, 3, 0, 12, 4, 0, 40); + profile.SetStatOverflows(TH1::kConsider); + profile.Fill(-1., 2., 5., 4.); + profile.Fill(1., 2., 5., 8.); + profile.GetZaxis()->SetRange(1, 1); + + double stats[13] = {}; + profile.GetStats(stats); + EXPECT_DOUBLE_EQ(2., stats[0]); + EXPECT_DOUBLE_EQ(0., profile.GetMean(1)); +} + TEST(TProfile3D, Chi2Test) { TProfile3D reference("reference", "reference", 10, 0, 10, 11, 0, 11, 12, 0, 12);