Statistical errors not propagated correctly

Dear developers,
I am using root 6.05/02 and I was trying to explain the error propagation to student, but unfortunately root did not support me #-o ! Here is what I did:

TH1D *h=new TH1D("h","",10,0,10);
h->SetDefaultSumw2(1);

for(int i=0;i<10000;i++)h->Fill(1);
h->GetBinContent(2)
(Double_t) 10000.0

 h->GetBinError(2)
(Double_t) 100.000

 h->Scale(0.1)
 h->GetBinContent(2)
(Double_t) 1000.00
 h->GetBinError(2)
(Double_t) 31.6228

This means that root calculated the square root of the bin not the scale factor multiplied by the square root of the bin before scaling. The bug (feature) did not exists in the old root versions.

Cheers

Hi,

I don’t think is a bug. As written in the documentation of the static function TH1::SetDefaultSumw2(),

root.cern.ch/doc/master/classTH … ed2ac153c2

[quote]all new histograms will automatically activate the storage of the sum of squares of errors
[/quote]

So this refers only for the new ones. You need to do :

TH1::SetDefaultSumw2(1);
TH1D *h=new TH1D("h","",10,0,10);

or using the non-static member function Sumw()

TH1D *h=new TH1D("h","",10,0,10);
h->Sumw2();

Then you will get the correct errors.
However, in my opinion, I think the scale by default should compute correctly the errors, independently if Sumw2 has been called or not. I’ll think about what is the best way to do this

Best Regards

Lorenzo