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”):
h->GetXaxis()->SetCanExtend(kFALSE);
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!
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.