import os,sys
from ROOT import *
import math

gStyle.SetOptFit(1)
gStyle.SetStatY(0.95)
gStyle.SetStatX(0.90)
gStyle.SetStatW(0.2)
gStyle.SetStatH(0.15)
gStyle.SetFitFormat('2.2e')
default = TH1F()
default.SetDefaultSumw2()

histo_file = TFile('histos.root')
histo = histo_file.Get('h_e2L_R07_fakerate_pt').Clone()
histo.Divide(histo_file.Get('h_e1L_R13_fakerate_pt').Clone())
histo.SetMarkerStyle(21)
histo.SetMarkerSize(1.5)

cP = TCanvas("canvas","canvas",700,600);
cP.SetRightMargin(0.1)
cP.SetFillColor(kWhite)
cP.SetTopMargin(0.05)
cP.SetBottomMargin(0.20)

f1 = TF1("f1","pol0",0,100)

histo.Draw('pe')
fit_start = 20
histo.Fit('f1',"S","same",25,100)
f1.SetLineColor(kRed+1)
f1.Draw("same")
histo.SetMaximum(2)

histo.GetYaxis().SetTitle('Ratio 2L/1L')
histo.GetYaxis().CenterTitle()
cP.Modified()
cP.SaveAs('test.png'%locals())

    
    
