I am observing an extremely strange thing. Can SetBinContent change the number of bins?
This is the code I have
h->SetBinContent(h->GetNbinsX()+ 1, scale);
cout << "Finish Lumi normalizing histogram.\n";
and this is the output
Finish Lumi normalizing histogram.
Where should I add this piece of code?
TH1::kCanRebin is not defined in root!
It exists in ROOT 5 (In compiled code #include “TH1.h”).
It seems that some genius removed it in ROOT 6
So, in ROOT 6, try (in compiled code #include “TAxis.h”):
thanks a lot,
I tried it and it works. However, I still do not fundamentally understand why the number of bins would change when I call SetBinContent() function.
I only want to set the content of the overflow bin!
if you dont like the way it is implemented you may exploit
the inheritance of say TH1F from TArrayF:
TH1F h("zz", "yy", 10,0,10);
h = 2; // bin 2
h = 34; // underflow
h = 26; // overflow
h = 34;
Error in <TArrayF::operator>: index 12 out of bounds...
Just be aware that TH1F::SetBinContent automatically performs some [url=https://root-forum.cern.ch/t/bin-errors-with-addbincontent-and-sumw2/19465/5 side actions[/url] (which are not done if you go via the TArrayF shortcut).
In any case, after you manually modify bin contents, I think you should call TH1::ResetStats.