Shift bins under modulus

Is there a way to shift bins modulo some float? If I have some data on bins over [0,5] with features at 1 and 3.5, can I shift the bin centers by +2 to move those same features to 2 and 0.5?

Some motivation since I might be tackling this problem in a bad way. I have some TH1F’s which all have three peaks some with nicer statistics than others. While the peak that happens closest to 0 isn’t the same physical event for all the histograms, the temporal spacing and order of the events in the histogram are. That is, I can guarantee species A is followed by B followed by C followed by A followed… etc. but I don’t know a priori what species corresponds to the peak that has time closest to zero. I want to use TSpectrum’s peak detection, Search but I don’t want medium sized peaks over the boundary to be marked near 0 and the max bin since that double counts.

Since the time differences are known, I figure if I get two correct peaks and a third is a boundary repeat, I can shift to not chop peaks and then reidentify the peaks.

ROOT Version: 6.20/04
Platform: Ubuntu 20.04
Compiler: linuxx8664gcc

May be it would be enough to change the X axis limits with SetLimits ?


But will that take data that’s chopped off the left and put it on the right? I will likely manually rebin with something like copying the data and shifting with original[i] = copy[(i+index_shift)%nbins] I just wondered about a built-in, as periodic data seems like it would be analyzed enough to have tools for it.

I do not think there is a built-in way to do it. May be @moneta can confirm.

Yes we do not have such function. If it is just shifting the axis, keeping the same bins, you can do as @couet suggested.
If not you would need to create a new histograms, loop on the bins and copying the content according to your specific procedure using SetBinContent

Thanks for the reply! I’ll be going with SetBinContent