Hi, I have a rootfile, which has a 2D histogram with lowest bin (20,25).
Is there an easy way to extend the lower threshold such that the bin has range of (12,25) with same bincontent?
I guess one can literally use setbincontent, getbincontent functions for every single entry to recreate entire 2Dhist.
However, I expect that experts would know a much faster shortcut for my situation where I need to change only one bin’s lower threshold and save that as root file.
Are the axes of your histogram “fix bin size” or “variable bin size”?
Try (if you want to modify the “x axis”):
your_histogram->GetXaxis()->IsVariableBinSize()
If the axis is a “fix bin size” then, you will need to create a new histogram with correct axes ranges.
If the axis is a “variable bin size” then, you can simply execute (if you want to modify the “x axis”):
(*(TArrayD*)your_histogram->GetXaxis()->GetXbins())[0] = 12.; // the lowest edge
Afterwards, you need to execute:
// one must set the new proper "xmin" and "xmax" for this axis
your_histogram->GetXaxis()->SetLimits(
(*your_histogram->GetXaxis()->GetXbins())[0],
(*your_histogram->GetXaxis()->GetXbins())[your_histogram->GetNbinsX()]
);