// Simple ROOT macro to plot a histogram. // Modify arguments as needed. // To execute, type .X plotDist.C { TFile* f = new TFile("simpleMC.root"); f->ls(); TH1D* h1 = (TH1D*)f.Get("h_Exp"); // normalize histogram to unit area double Ntot = h1->GetEntries(); double dx = h1->GetXaxis()->GetBinWidth(1); double norm = 1./(dx*Ntot); h1->Scale(norm); h1->SetXTitle("x"); h1->SetYTitle("f(x;#xi)"); h1->Draw(); // plot some things on top of it const int numPoints = 5; double x[numPoints] = {0., 1., 2., 3., 4.}; double y[numPoints] = {0.9, 0.5, 0.3, 0.1, 0.05}; TGraph tg(numPoints, x, y); tg.SetLineWidth(2); tg.Draw("C,same"); // C for curve, same to superimpose }