# Problem in h->Integral/binWidth

Dear experts,
I loop over a tree, and without applying any cuts, I fill histogram. Both the tree and the hist have nentries 26364, but when I try to retrieve this number with [1], I found val = 263640.
I did that with other trees and each time I found val = 10 * nentries. Do you know what is wrong?

PS: when I’m doing [2] I find the expected value val = 1

Regards

[1]
val = hist->Integral()/hist->GetBinWidth(1) // here val == 10 * nentries

[2]
hist->Scale(1/(hist->Integral()/hist->GetBinWidth(1))); // normalized to area
val = hist->Integral()/hist->GetBinWidth(1); // here val ==1 as expected

h->Integral() returns the number of entries. ( = h->GetEntries() ) (A summatory)
h->Integral(“width”) returns the “actual” integral. ( = h->Integral()*binWidth if fixed bin size)

root.cern.ch/doc/master/classTH … 340830a163

Dear ferhue,

• yes, h->Integral() = nentries.

• but I’m confused. To normalize my hist area to 1, is [1] correct?

• because if [1] is correct, when I compute [2] after I did [1], I do not find 1?

[1]
hist->Scale(1/(hist->Integral()/hist->GetBinWidth(1)));

[2]
hist[i]->Integral(“width”)

Try:

``````const Double_t area = h->Integral("width");
h->Scale(1./area);
cout << h->Integral("width") << endl;``````

Is your bin width fixed or do you have bins with variable size?

``````[1]