Creating multiple histograms for different user ranges

Hello!
I am doing some analyses from a root file, which I write a macro for. In this macro, I have a main histogram that consists of all the data points I need, it has 30 bins and x-axis range is from 0 to 150(meters), signifying 1 bin for each 5m distance.
I need to produce multiple histograms, where each histogram is the of one bin width. So, one histo for 0-5m, another for 5-10m, another for 10-15m and so on. And one final histogram that contains the entire plot from 0 to 150.
I could write an if loop/switch for each range but I assume that would require creating 30(+1) different histograms which seems inefficient.
Is there any other way to solve this?

ROOT Version: 6.28
Platform: Ubuntu 22.04
Compiler: g++


Hi,

It depends in the end on the context where this has to be done, but I do not necessarily see issues with that.
It is not unusual to book histograms and other resources, e.g. for data reduction techniques, at the beginning of macros/programs/classes, also explicitly, on multiple lines.

Cheers,
D

Thank you for reply!
It seems that this is the way to go.