Warning in TH2::GetBinContent

Dear Sir,

I’ve hot the same warning of this message I found using google. I need to use a particular version of root so I cannot use the most recent ones. So I have this warning:

Warning in TH2::GetBinContent: this method must be overridden!

What does it mean: A possible solution is to move the Sumw2() call into the TH2F constructor… ?

What I need to do?

Thank you so much

F. Ruffini

Philip,

Thanks for reporting this problem. Your solution is correct and now available in the SVN trunk.

Rene Brun

Philip Rodrigues wrote:
Hi Roottalk,
I noticed a little annoying misfeature in TH2F::TH2F, shown by the
following snippet:

TH1::SetDefaultSumw2()
TH2F* h2=new TH2F(“foo”, “bar”, 100, 0, 10, 100, 0, 10)

This results in the following warning being printed many times (once per
bin I think):
Warning in TH2::GetBinContent: this method must be overridden!

The reason is that the TH2F constructor calls the TH2 constructor, which
has:

if (fgDefaultSumw2) Sumw2();

This results in TH1::Sumw2() being called, before the TH2F is
constructed, so the call in TH1::Sumw2() to GetBinContent() gets
resolved to TH2::GetBinContent instead of TH2F::GetBinContent.

A possible solution is to move the Sumw2() call into the TH2F
constructor. This fixes it for me.

The same problem affects TH3 too.

Regards,
Philip

[quote]> Warning in TH2::GetBinContent: this method must be overridden![/quote]It means that inadvertently a TH2 object was created instead of a TH2D or TH2F (TH2 object can not be used).

Philippe.