I have a TH2D file, say,
TH2D RAW = new TH2D(“spectrum”,“spectrum”,1023,0,1023,2000,0,2000);
here the total bins in yaxis is 2000.
Now I would like to rebin along the yaxis bying merging 2 bins into one bin of a new histogram, for example, bin number 200 and 201 of the RAW to a new bin…
I try to do in the following way
TH2D *hnew = RAW->RebinY(2,“hnew”);
I would expect that now the total bins for the rebinned histogram hnew is 2000/2=1000. However, when I plot it, I still can see 2000 bins in yaxis, but with changed bin content…
I got the same as you when I use GetNbins(). However, when I plot it by hnew->Draw(“colz”), I still can see 2000 bins in yaxis… I do not understand this…
One last question: how can I change the yunit in yaxis to 1 bin after rebinning, namely, 1 in the axis actually corresponds to bin 1? In such a way, we will more easily see the actual time (yaxis) from our data.