void test2(){ auto c1 = new TCanvas("c1", "A ratio example"); TFile *f1 = new TFile("tutorial1afinal.root","READ"); TFile *f2 = new TFile("ZHerwig.root","READ"); TTree *t11= (TTree*)f1->Get("tree1"); TTree *t22= (TTree*)f2->Get("tree1"); double m0,m00,m1,m11,m2,m22,Mm1,Mm11; int i; t11->SetBranchAddress("eta11",&m11); t22->SetBranchAddress("Meta11",&m22); TH1F *h1= new TH1F("h1","#eta",100,-3,3); TH1F *h2= new TH1F("h2","#eta",100,-3,3); int n11 =t11->GetEntries(); int n22 =t22->GetEntries(); for (i=0; iGetEntry(i); h1->Fill(m11); } for (i=0; iGetEntry(i); h2->Fill(m22); } TString title = Form("#font[60]{p-p collisions, 13.6 TeV}"); TLatex tex; tex.SetTextFont(42); TLegend *legend1 = new TLegend(0.3,0.7,0.5,0.9); legend1->AddEntry(h1,"eta:e-","l"); legend1->AddEntry(h2,"eta:mu-","l"); h2->SetLineColor(2); h2->SetLineWidth(2); h1->SetLineColor(4); h1->SetLineWidth(2); legend1->Draw(); auto rp1 = new TRatioPlot(h2,h1); rp1->SetGraphDrawOpt("lines"); //rp1->SetSeparationMargin(0.0); rp1->Draw(); rp1->GetLowerRefYaxis()->SetTitle("ratio"); // rp1->GetLowerRefXaxis()->SetTitle("#eta"); rp1->GetUpperRefYaxis()->SetTitle("entries"); rp1->GetUpperRefXaxis()->SetTitle("#eta"); rp1->GetLowerRefGraph()->SetMinimum(-0.4); rp1->GetLowerRefGraph()->SetMaximum(2); tex.DrawLatex(0.18,0.87,title); }