Scaling of histogram sets BinError to 0

Dear all,

I see very strange behaviour for a histogram: when scaling with 1.0 via the function Scale(), the errors of all bins are set to 0.0 afterwards. I attached a little script I wrote and the corresponding input root file. The corresponding output in my case is:

Integral is 92680.95672607422
Bin content 5539.64990234375, bin error 74.42882440522455
Scale histogram with 1.0
Integral is 92680.95672607422
Bin content 5539.64990234375, bin error 0.0

Any help is very much appreciated!

tmp_renamed.root (120.8 KB) (632 Bytes)

Please read tips for efficient and successful posting and posting code

_ROOT Version: 6.26/08
_Platform: CentOS7
Compiler: Not Provided

Maybe that’s connected to the “IMPORTANT NOTE” here: ROOT: TH1 Class Reference

@moneta can help I am sure.


This is caused by the fact that the entries of the histograms are zero. I don’t know why, since it is coming from a file, maybe we should remove this check in TH1::Sumw2 that is used to fill the histogram bin errors correctly.
As a workaround just do before scaling:



ok thanks for the comment. The workaround works :slight_smile: I could also find why the histogram has zero entries: the histogram was filled with the function “AddBinContent()”. In contrast to “SetBinContent()” it seems the function is not updating the bin entries. I don’t know if this is the intended behaviour.

AddBinContent is more an internal function of the histogram, which is more efficient. If using that function you would need to set the entries by hand, calling SetEntries


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.