Variable size binning

i am dealing with the following problem:
i have to create an histogram with variable bin size(let’s call this binning A). i am reading abscissa x and ordinate y from an ascii file, but they have a different binning (let’s call this other binning B) from what i want to get at the end
my idea was to read the ascii file and put it into a TGraph and then put the TGraph into a TH1F that I create with the binning I desire (A). Is it possible,is there any method to do that? i didn’t find it anyway.
how should i solve my problem?

alternatively, i can create from the ascii file an TH1F with binning B,but then how to get a TH1F with the binning desired (A)?

regards and thanks for help,

Why don’t you simply use TGraph ?
You have X and Y coordinates, TGraph seems more natural.

i cannot use TGraph because i need to get each point at the position of a certain well determined bin (fixed by what i called binning A in the first post).

so I guess you should book a TH1 with the number of bins you need.
Then you fill it for each X(i) position with the weight Y(i)…
I hope I understood what you really want…

thanks for helping.
the problem is that the ascii file has values for y corresponding to values of x that are different from what i have to fix in my histogram. maybe it is not clear and should i try to explain better?

Yes,

Please explain better your problem.
What do you mean put a TGraph in a TH1. A TGraph is a set of (x,y) observation, a TH1 is an estimator for the density of a set of (x) observations. So, they are very different objects!

Lorenzo

hi,

concerning ROOT the problem is:

how can I pass from a TH1F with a binning (variable) to another TH1F with a different binning.

TGraph was just an idea to overcome the problem, but it is not the solution for me.

Hi,
This is possible only if the bin overlap, i.e. if the new binning is larger than the old one and contains exactly the same bins. See the function TH1::Rebin.
Otherwise, by binning you loose information on the original observations, so you cannot move to a different binning

Lorenzo