void exampleRatioPlot() { auto h1 = new TH1D("h1","h1",50,-3,3); auto h2 = new TH1D("h2","h2",50,-3,3); h1->FillRandom("gaus", 1000); h2->FillRandom("gaus", 10000); h1->Sumw2(); h2->Sumw2(); h1->Scale(1./h1->Integral()); h2->Scale(1./h2->Integral()); h1->ResetStats(); h2->ResetStats(); c1 = new TCanvas(); c1->Divide(1,3); c1->cd(1); h1->Draw("HIST E"); h2->SetMarkerStyle(20); h2->Draw("SAME E"); // compute ratio c1->cd(2); auto ratio = new TGraphAsymmErrors(50); ratio->Divide(h1,h2,"pois midp"); ratio->SetMarkerStyle(20); ratio->GetXaxis()->SetRangeUser(-3,3); ratio->SetMinimum(-2); ratio->SetMaximum(10); ratio->Draw("AP"); auto line = new TLine(-3,1,3,1); line->SetLineColor(kBlue); line->Draw(); ratio->SetTitle("Ratio using Poisson statistics"); ratio->Draw("P"); // do using TH1::Divide c1->cd(3); auto hr = (TH1*) h1->Clone("hratio"); hr->Reset(); hr->Divide(h1,h2); hr->SetMarkerStyle(20); hr->SetMinimum(-2); hr->SetMaximum(10); hr->SetTitle("Ratio using Normal statistics"); hr->Draw("E"); }