Rebin a histogram while changing x axis scale

I have a spectrum, from a “faulty” DAQ, where some bits are missing, as shown in the following image

What I thought of doing, is making the histogram “less” accurate with 1024 instead of 4096 channels. The first thing that crossed my mind was to use the Rebin(4) function, so the outcome is the following

While the peak is smoother, I see no difference in the channels. I would expect that the spectrum would be suppressed by a factor of 4, but that’s not the case.

To expand more I would expect the following behaviour. Let’s assume the following channels

1 2 3 4 5 6 7 8 9 10 11 12

After the Rebin(4) I would expect the first 4 channels(1, 2, 3, 4) to become 1, the next 4(5, 6, 7, 8) to become channel 2, the next 4(9, 10, 11, 12) to become the new channel 3 and so on…

Was I wrong to expect such a behaviour? Is there a way to do the rebining while changing the total naumber of channels?

Thank’s in advance!

1 Like

Hi,
I don’t understand what you are expecting. Rebinning just combine bins together, but it is not supposed to change the values of the x axis. If you want the x values (for example for the bin 1 from [0,4] to be [0,1] ) just call
h1->SetBins( h1.GetNbinsX(), newxmin, newxmax);

Lorenzo