from ROOT import TFile, TH1F, TCanvas, TLegend, gStyle
import ROOT as root

filename = "signal_sample_hist_root/EXO-ggToXdXdHToBB_sinp_0p35_tanb_1p0_mXd_10_MH3_600_MH4_150_MH2_600_MHC_600_CP3Tune_13TeV_new_0000_0.root"

c1 = root.TCanvas("c1","c1", 900, 5000) #width-length
c1.Divide(2,4,0.01,0.01)

file = root.TFile(filename)
leg = root.TLegend(0.55,0.7,0.85,0.85)
leg.SetBorderSize(0)
leg.SetTextSize(0.027)
gStyle.SetOptStat(0)

c1.cd(1)
h = file.Get("h")
h.SetTitle("MET Before Filter")
h.SetLineColor(1)
h.SetLineWidth(4)
h.GetXaxis().SetTitle("MET (GeV)")
h.GetYaxis().SetTitle("number of events")
h.Draw()
leg.Draw()

c1.cd(2)
h0 = file.Get("h0")
h0.SetTitle("MET After 1 Filter")
h0.SetLineColor(2)
h0.SetLineWidth(4)
h0.GetXaxis().SetTitle("MET (GeV)")
h0.GetYaxis().SetTitle("number of events")
h0.Draw()
leg.Draw()

c1.cd(3)
h1 = file.Get("h1")
h1.SetTitle("MET After 2 Filters")
h1.SetLineColor(3)
h1.SetLineWidth(4)
h1.GetXaxis().SetTitle("MET (GeV)")
h1.GetYaxis().SetTitle("number of events")
h1.Draw()
leg.Draw()

c1.cd(4)
h2 = file.Get("h2")
h2.SetTitle("MET After 3 Filters")
h2.SetLineColor(4)
h2.SetLineWidth(4)
h2.GetXaxis().SetTitle("MET (GeV)")
h2.GetYaxis().SetTitle("number of events")
h2.Draw()
leg.Draw()

c1.cd(5)
h3 = file.Get("h3")
h3.SetTitle("MET After 4 Filters")
h3.SetLineColor(793)
h3.SetLineWidth(4)
h3.GetXaxis().SetTitle("MET (GeV)")
h3.GetYaxis().SetTitle("number of events")
h3.Draw()
leg.Draw()

c1.cd(6)
h4 = file.Get("h4")
h4.SetTitle("MET After 5 Filters")
h4.SetLineColor(6)
h4.SetLineWidth(4)
h4.GetXaxis().SetTitle("MET (GeV)")
h4.GetYaxis().SetTitle("number of events")
h4.Draw()
leg.Draw()

c1.cd(7)
h5 = file.Get("h5")
h5.SetTitle("MET After 6 Filters")
h5.SetLineColor(7)
h5.SetLineWidth(4)
h5.GetXaxis().SetTitle("MET (GeV)")
h5.GetYaxis().SetTitle("number of events")
h5.Draw()
leg.Draw()

c1.cd(8)
h6 = file.Get("h6")
h6.SetTitle("MET After 7 Filters")
h6.SetLineColor(797)
h6.SetLineWidth(4)
h6.GetXaxis().SetTitle("MET (GeV)")
h6.GetYaxis().SetTitle("number of events")
h6.Draw()
leg.Draw()


c1.cd()
c1.Update()
c1.SaveAs("EXO-ggToXdXdHToBB_sinp_0p35_tanb_1p0_mXd_10_MH3_600_MH4_150_MH2_600_MHC_600_CP3Tune_13TeV_new_0000_0.pdf")

