(I will change “sometimes” in the title with the proper term, as soon as I learn it). Talking about rebinning, ROOT has two “kinds” of histograms. An image will explain best:
That I will by now call “Type A”, and:
When I create an histogram, ROOT decides (I don’t know how: the decision changes e.g. changing the cut on the tree I project from) what “type” the histogram will be.
My problem is, if an 1D histogram is assigned “type A”, then, after I rescale the axis, for example like https://root-forum.cern.ch/t/can-we-shift-histogram-for-several-channels/12050/2 (I cannot do the
a->GetXbins() thing because my histogram has “fix bins”), or to be short:
tree->Project("hist","e","t>4000"); TAxis* axis = hist->GetXaxis(); axis->Set(axis->GetNbins(), p0 + axis->GetXmin()*p1, p0 + axis->GetXmax()*p1 ); hist->ResetStats(); hist->Draw();
If I now try to rebin the type A histogram, the bin contents sort of revert to before the axis rescaling. I mean: in the following, the big peak is at around 4100 keV and channel 2200. Here is the histogram after axis rescaling:
And this is what I see after clicking the bar for reducing the number of bins by 1/2:
If the histogram happens to be of type B, I instead get the expected result after rebinning.
If you want an example from me, I can give you my data and the cut you need to make ROOT decide for type A. But probably you know how to force the histogram to the type you want, so that we can test something very simple.
By the way, if you can tell me how to force degrading an histogram from type A to B (it does so by itself sometimes), that would be an acceptable workaround.