Create a variable binning TH1D knowing only bin centers and contents

Hello rooters,

I have a set of (x,y) points that are part of a distribution, so I want to make a histogram. The binning is variable but I don’t know how it got created.

What I have is the bin center and the bin content.
Is there a way to read this ascii file and make a histogram out of the points?
It looks like an easy thing to do, but I can’t get my head around it!
I tried in the past (Create histogram with a varying binning knowing BinCenter) but with no success.

A TGraph wouldn’t work, because conceptually it is a distribution and also I would like to use TH1 functions down the road.

That’s how my data points look like:

Bin Center  Bin Content
1.8685E-10	1.8574E+06
3.2121E-10	4.5234E+06
5.7568E-10	2.2107E+07
9.8964E-10	1.0395E+08
1.7737E-09	3.5861E+08
3.0490E-09	1.4443E+09
5.6971E-09	4.4367E+09
1.0211E-08	1.1674E+10
1.7553E-08	3.3190E+10
3.2797E-08	7.1969E+10
5.6381E-08	1.1450E+11
1.0105E-07	1.0598E+11
1.8110E-07	4.5234E+10
3.2457E-07	9.6204E+09
5.8171E-07	5.3838E+09
1.0000E-06	5.3838E+09
1.8685E-06	4.9829E+09
3.0810E-06	4.9829E+09
5.7568E-06	4.2683E+09
1.0757E-05	4.1062E+09
1.7737E-05	3.9504E+09
3.1788E-05	3.9504E+09
5.4646E-05	4.1062E+09
1.0211E-04	3.6562E+09
1.8300E-04	3.6562E+09
3.1458E-04	3.1318E+09
5.6381E-04	3.1318E+09
1.0105E-03	3.1318E+09
1.8110E-03	3.0129E+09
3.1132E-03	2.6827E+09
5.8171E-03	2.5809E+09
1.0426E-02	2.3886E+09
1.7922E-02	2.0461E+09
3.2121E-02	2.7885E+09
5.7568E-02	1.5605E+09
9.8964E-02	2.1268E+09
1.8491E-01	2.5809E+09
3.1788E-01	3.1318E+09
5.6971E-01	3.6562E+09
1.0211E+00	4.4367E+09
1.7553E+00	4.4367E+09
3.1458E+00	3.0129E+09
5.6381E+00	1.5605E+09
1.0105E+01	5.2807E+08
1.7371E+01	2.3886E+07

Thanks for the reply!

This line is not clear to me

x[0] = (3.0 * g->GetX()[0] - g->GetX()[1]) / 2.0;

Why do you multiply with 3 and divide by 2?

x[0] = g->GetX()[0] - (g->GetX()[1] - g->GetX()[0]) / 2.0;