You can convert a graph into a histogram:
{
TGraph *g = new TGraph("m1.txt");
// g->Sort(); // just a precaution
Int_t n = g->GetN();
// note: if the graph's points "x coordinates" are not equidistant,
// they will usually not coincide with the histogram's "bin centers"
Double_t *x = new Double_t[(n + 1)];
x[0] = (3.0 * g->GetX()[0] - g->GetX()[1]) / 2.0;
x[n] = (3.0 * g->GetX()[(n - 1)] - g->GetX()[(n - 2)]) / 2.0;
for (Int_t i = 1; i < n; i++)
{ x[i] = (g->GetX()[(i - 1)] + g->GetX()[i]) / 2.0; }
TH1D *h = new TH1D("h", "time histogram;Time;Events", n, x);
for (Int_t i = 0; i < n; i++) {
h->SetBinContent(i + 1, g->GetY()[i]);
}
h->ResetStats(); // reset the statistics including the number of entries
delete [] x; // no longer needed
delete g; // no longer needed
gStyle->SetOptStat("neMRuoISK");
h->Draw();
// g->SetMarkerStyle(20); g->Draw("P");
}