Re: TH2::TH2 and SetDefaultSumw2

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Mon, 31 Mar 2008 19:13:15 +0200


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
>
>
Received on Mon Mar 31 2008 - 19:13:21 CEST

This archive was generated by hypermail 2.2.0 : Tue Apr 01 2008 - 05:50:02 CEST