TH1 GetBinContent RuntimeWarning

Hello all,
When I try to use TH1.SetDefaultSumw2() in PyROOT, I get the following error:
TH1::GetBinContent:0: RuntimeWarning: this method must be overridden!

I am using python 2.4.6 and ROOT 5.22.00. The Sumw2 structure does seem to be created, but I see this error for every single bin in every single histogram.

Here is an example macro

#!/usr/bin/env python
import sys,math
from array import array
from optparse import OptionParser
argv_org = list(sys.argv)
sys.argv = [e for e in sys.argv if e != '-h']
sys.argv.append('-b')
from ROOT import *
sys.argv = sys.argv[:-1]
sys.argv = argv_org


xaxis = [-10.0, 0.0, 10.0, 15.0, 20, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 100.0, 165.0, 600]


def main():
    TH1.SetDefaultSumw2()

    test = TH1F("test","some title",13,array('d',xaxis))

    return


if __name__ == '__main__':
    main()

Hi,

this appears to be an old problem in hist/src/THn.cxx and was fixed by moving the “if (fgDefaultSumw2) Sumw2()” from the base class to the most derived class constructors. The fix is in releases v5-24 and later.

(Note that the python RuntimeWarning is a translated CINT warning.)

Cheers,
Wim