Dear ROOTers,
I ran across a strange behavior with the Sumw2() function. When running ROOT 5.26/00 on a SL5 x86_64, the following code #1 works fine:
TH1F * h = new TH1F( "h", "H", 5, -2, 2 );
h->Fill( 1, 4 );
h->Sumw2();
h->GetBinContent(4)
(const Double_t)4.00000000000000000e+00
h->GetBinError(4)
(const Double_t)2.00000000000000000e+00 // OK!
The following code #2 produces NaN errors:
TH1F * h = new TH1F( "h", "H", 5, -2, 2 );
h->Fill( 1, -4 );
h->GetBinContent(4)
(const Double_t)(-4.00000000000000000e+00)
h->Sumw2()
h->GetBinContent(4)
(const Double_t)(-4.00000000000000000e+00) // OK
h->GetBinError(4)
(const Double_t)nan
With the following code #3 (Fill() and Sumw2() are swapped) the error is even wrong!
TH1F * h = new TH1F( "h", "H", 5, -2, 2 );
h->Sumw2()
h->Fill( 1, -4 );
h->GetBinError(4)
(const Double_t)4.00000000000000000e+00 // should be 2.00000000000000000e+00
I noticed that code #2 works fine running ROOT 5.30/00 on my laptop MacOsX Lion 10.7.3, while code #3 has the same behavior.
Kind regards,
Riccardo