Ratio Plot

I have three root files which are attached with this message: One is from Sherpa, Other is from Madgraph and third one is from data.

I’m using this code to superimpose the three plots for a particular variable e.g eta in this case.

{
TFile f1(“madgraph_zeejets.root”,“read”);
TGraphAsymmErrors ae = (TGraphAsymmErrors)f1->Get(“jet_ee_eta1jetcase”);

TFile f2(“sherpa_zeejets.root”,“read”);
TGraphAsymmErrors aa = (TGraphAsymmErrors)f2->Get(“jet_ee_eta1jetcase”);

TFile f3(“jet1eta_data.root”,“read”);
TCanvas c3 = (TCanvas)f3.Get(“c1”);

TH1D *h1;

TList* l = c3->GetListOfPrimitives();
TIter next(l);
TObject *found, obj;
while ((obj=next())) {
if (obj->InheritsFrom(TH1D::Class())) {
h1 = (TH1D
)obj;
}
}

TCanvas c4;
h1->Draw(“E”);
h1->SetLineColor(kBlack);
h1->SetLineWidth(2);

ae->Draw(“E”);
ae->SetLineColor(kRed);
ae->SetLineWidth(2);

aa->Draw(“E”);
aa->SetLineColor(kBlue);
aa->SetLineWidth(2);

}

But I also want to draw ratio plots also. (data/madgraph & data/sherpa)
Can you please extend this code & tell me how to draw ratio.

Thanks in advance…
sherpa_zeejets.root (10.9 KB)
madgraph_zeejets.root (10.9 KB)
jet1eta_data.root (14.9 KB)

Hi - Something like this should work ;

  TCanvas *c1 = new TCanvas();
  c1->cd();   
   TPad *pad1 = new TPad("pad1","pad1",0,0.3,1,1);
   pad1->SetBottomMargin(0);
   pad1->Draw();
   pad1->cd();

   TH1F *h3=h1->DrawCopy();
   
   TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);
   pad2->SetTopMargin(0);
   pad2->Draw();
   pad2->cd();
   h3->SetMinimum(0.8);
   h3->SetMaximum(1.2);
   h3->Sumw2();
   h3->SetStats(0);
   h3->Divide(ae);
   h3->SetMarkerStyle(21);
   h3->Draw("ep");