TH1F with variable Bin Size and Add


is there a way, to rebin a Histogram with variable bin size?
One Idea would be, to create a new Histogram with less bins but same Lower and Upper Range of the X-Axis, and add the old Histogram.

How does Histogram adding work? If it adds the Content of bin i to bin i of the other Histogram it wont work, but if it adds the Content of bin i to GetBinCenter(i) of the other Histogram it would work.

I hope it became clear, what i mean…


TH1::Add requires the same number of bins and limits. However you can use TH1::Rebins to convert your fix bin histograms into a variable bin size histogram. See


Oh, I missed that function, thanks for the help.

But i have some problems using it, maybe someone can give me a hint:

I have a class, in which my TH1F is rebinned, and want to return *TH1F… but how do i get a pointer to hnew? I’m sure there is a way to find an object like TH1F by name and return the pointer, but I cant find it :frowning:

Thx for the help,


I do not understand your question. TH1::Rebin returns a TH1*


Oh, you’re right, the question was somehow stupid, for some reason I thought it would return void.

Thanks for the fast answer :slight_smile: