TH1 Overflow bins: GetSumOfAllWeights(true) and GetBinContent/Print("all") disagree


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.38.04 From tags/6-38-04@6-38-04
Platform: linuxx8664gcc
Compiler: g++ (GCC) 15.2.0 std202302


I have several histograms (generated by EL::AnaAlgorithm) whose overflow bins are empty, e.g.

$ h_Z_pdgId->GetBinContent(0)
(double) 0.0000000
$ h_Z_pdgId->GetBinContent(h_Z_pdgId->GetNbinsX() + 1)
(double) 0.0000000

The histogram printout agrees:

$ h_Z_pdgId->Print("all")
TH1.Print Name  = h_Z_pdgId, Entries= 9856, Total sum= 1.291e+12
 fSumw[0]=0, x=-25.5, error=0
 fSumw[1]=0, x=-24.5, error=0
 ...
 fSumw[48]=0, x=22.5, error=0
 fSumw[49]=1.291e+12, x=23.5, error=1.53674e+10
 fSumw[50]=0, x=24.5, error=0
 fSumw[51]=0, x=25.5, error=0

but the values of GetSumOfWeights() and GetSumOfAllWeights(true) differ significantly:

$ h_Z_pdgId->GetSumOfWeights()
(double) 1.2909971e+12
$ h_Z_pdgId->GetSumOfAllWeights(true)
(double) 1.1618974e+13

What on earth is happening here?

I’ve attached a file containing these histograms:
hist-run.root (47.3 KB)

It’s a bug in ROOT 6.36(.14 and older) and 6.38(.06 and older), fixed in 6.40.