# Histogram integral is modified after rebinning

Hello,
with a root file (the file is too big to attach it directly in this post), I do the following step

root testTree.root gStyle->SetOptStat(1001111); tcalib->Draw("E1>>h(100,800,900)"); h->Integral();
I got the following figure

Now if I rebin using the Editor (on the left), you can see that the integral value is modified (from 3.868e5 to 1.789e5).

If I rebin once more, the integral value does not change anymore.

Moreover, if I do

gStyle->SetOptStat(1001111); tcalib->Draw("E1>>h(100,800,900)"); h->Integral() (const Double_t)3.86838000000000000e+05 h->Rebin(2) h->Integral() (const Double_t)3.86838000000000000e+05
The integral value is not modified if I use Rebin() function via the command line. But if I rebin using the editor, the integral is modified. Do you have any explanation?

I tried with ROOT 5.28.00b and 5.34.10 and I get the same behaviour.

No idea of what happens?
I do not think I did something wrong, so I would like to know if the proble; comes from my ROOT file or from ROOT…

I succeed to generate a smaller ROOT file which reproduces the problem. I attached it.
So, if you type

root testTree.root gStyle->SetOptStat(1001111); tcalib->Draw("E1>>h(100,800,900)"); cout << h->Integral() << endl;
you will get 258746. After, if you Rebin using the graphical tools (Editor) like described in my first post, the integral will be 50854…
testTree.root (1.89 MB)

That’s not really my field of expertise but I think you need the option “width”:

cout << h->Integral("width") << endl;

[quote=“couet”]That’s not really my field of expertise but I think you need the option “width”:

cout << h->Integral("width") << endl; [/quote]
Hmmm, the integral value is still modified after a “graphical” rebinning.
First, I get 258746 and after the rebinning, I get 25427.

The strange thing is this behaviour occurs only when my histogram contains more than a certain number of events. For example, if you type

you may rebin without any problem; the integral value is not modified
However, if you type

The histogram disappears (it is empty) after a rebinning via the editor …

This problem is explained in sft.its.cern.ch/jira/browse/ROOT-5900
A simple solution is to call TTree::SetEstimate with a larger value (larger than the histogram entries)

Lorenzo