TH1::Scale with width option also scales fEntries

Dear All,

I am not convinced yet that this is a bug that’s why I post it here first (not on Jira).

I’ve been normalizing a histo with the “width” option. I noticed that it also scales the number
of entries. This is because of line 1087 here:
root.cern.ch/root/html606/TH1_8cxx_source.html

The point is that scaling with “width” uses the TH1::Add method with a “special” syntax
such that if the second scale factor is negative it does not add but scale the histo taking
the bin width into account.

However, I am not sure if a histo with a bin width of 0.5 and 1e6 entries should have 2 entries
after normalizing … it should still have 1e6 entries, no?

Here is an example:
root [0] TH1F* h_5 = new TH1F(“h_5”, “h_5”, 20, -5., 5.);
root [1] h_5->FillRandom(“gaus”, 1e6)
root [2] h_5->GetEntries()
(Double_t) 1.00000e+06
root [3] h_5->Scale(1./h_5->Integral(), “width”)
root [4] h_5->GetEntries()
(Double_t) 2.00000

Regards
Andi

Hi,

Thank you for reporting this problem. It is there only when the “width” option is used and when the errors are not stored.
When scaling you should call anyway TH1::Sumw2() to get the correct histogram statistics. I’ll do this automatically.

Thank you for reporting this problem

Lorenzo