void Profile() { // Create a canvas giving the coordinates and the size TCanvas *c1 = new TCanvas("c1", "Profile example",200,10,700,500); TFile *f0 = new TFile ("TBCResolution_100K_sample1_5K_correct.root"); TH2F *h; h = (TH2F*)f0->Get("DeltaTVSChannel_RR"); TProfile *prof = h->ProfileX(); //project a 2D histogram into a profile histo(plots the mean with its standard error per bin) along X prof->SetAxisRange(21.75, 21.95,"Y"); // selects the range of Y axis //prof->SetAxisRange(0, 8192,"X"); gStyle->SetStatFormat("6.7g"); // sets the significant figures to be 7 prof->Fit("pol0"); gStyle->SetOptFit(); // shows statistics box prof->Draw(); }