I have plotted a TH1F histogram, I would like to now plot a TGraph from this histogram. But don’t know how to go about doing that, may I have some kindly.
Int_t n = 6000000;
Float_t norm = sigma/h_rapidity->Integral("width");// normalizing histogram to cross-section
// hdndy->Scale(sigma/(binwidth *nevents));
hdndy = (TH1F*)h_rapidity->Clone();// making copy of rapidity histogram
hdndy->GetXaxis()->SetTitle(" Rapidity");
hdndy->GetYaxis()->SetTitle("d\sigma/dy");
hdndy->Scale(norm); //d\sigma/dy histogram.
hdndy->Draw("CL");
void h2g() {
auto h = new TH1F("h","h",100,-4,4);
h->FillRandom("gaus",20000);
auto g = new TGraph();
for(int i = 1; i <= h->GetNbinsX(); i++ ) g->SetPoint(i-1, h->GetBinCenter(i), h->GetBinContent(i));
g->Draw("AL");
}