def plotData(pad, w, pdfname, dsetname, resid=False, cat=None, log=False): if cat.startswith('b0_'): cat = cat.replace('b0_', '') if cat.startswith('bs_'): cat = cat.replace('bs_', '') xtitle = { 'b0g': '#it{m}(' + rt.Dzb + rt.g + rt.Kp + rt.pim + ') [MeV/c^{2}]', 'b0pi0': '#it{m}(' + rt.Dzb + rt.piz + rt.Kp + rt.pim + ') [MeV/c^{2}]', 'bsg': '#it{m}(' + rt.Dzb + rt.g + rt.Km + rt.pip + ') [MeV/c^{2}]', 'bspi0': '#it{m}(' + rt.Dzb + rt.piz + rt.Km + rt.pip + ') [MeV/c^{2}]', 'cg': '#it{m}(' + rt.Dzb + rt.g + rt.pip + rt.pip + ') [MeV/c^{2}]', 'cpi0': '#it{m}(' + rt.Dzb + rt.piz + rt.pim + rt.pip + ') [MeV/c^{2}]' } leg = { 'b0g': { 'sig': rt.Decay('Bd', 'Dzb', 'g', 'Kp', 'pim'), 'misrec': rt.Decay('Bd', 'Dzb', 'piz', 'Kp', 'pim'), 'bdstpp': rt.Decay('Bd', 'Dzb', 'g', 'pip', 'pim'), 'bdstkk': rt.Decay('Bd', 'Dzb', 'g', 'Kp', 'Km'), 'bsdstkk': rt.Decay('Bs', 'Dzb', 'g', 'Kp', 'Km'), 'bdkp': rt.Decay('Bd', 'Dzb', 'Kp', 'pim'), 'bdsth': rt.Decay('Bm', 'Dzb', 'g', 'pim'), 'partrec': 'Part Reco', 'lbdph': rt.Decay('Lb', 'Dzb', 'p', 'pim'), 'lbdstph': rt.Decay('Lb', 'Dzb', 'g', 'p', 'pim'), 'comb': 'Combinatorial' }, 'b0pi0': { 'sig': rt.Decay('Bd', 'Dzb', 'piz', 'Kp', 'pim'), 'misrec': rt.Decay('Bd', 'Dzb', 'g', 'Kp', 'pim'), 'bdstpp': rt.Decay('Bd', 'Dzb', 'piz', 'pip', 'pim'), 'bdstkk': rt.Decay('Bd', 'Dzb', 'piz', 'Kp', 'Km'), 'bsdstkk': rt.Decay('Bs', 'Dzb', 'piz', 'Kp', 'Km'), 'bdkp': rt.Decay('Bd', 'Dzb', 'Kp', 'pim'), 'bdsth': rt.Decay('Bm', 'Dzb', 'piz', 'pim'), 'partrec': 'Part Reco', 'lbdph': rt.Decay('Lb', 'Dzb', 'p', 'pim'), 'lbdstph': rt.Decay('Lb', 'Dzb', 'piz', 'p', 'pim'), 'comb': 'Combinatorial' }, 'bsg': { 'sig': rt.Decay('Bs', 'Dzb', 'g', 'Km', 'pip'), 'misrec': rt.Decay('Bs', 'Dzb', 'piz', 'Km', 'pip'), 'bdstpp': rt.Decay('Bs', 'Dzb', 'g', 'pim', 'pip'), 'bdstkk': rt.Decay('Bs', 'Dzb', 'g', 'Km', 'Kp'), 'bsdstkk': rt.Decay('Bs', 'Dzb', 'g', 'Km', 'Kp'), 'bdkp': rt.Decay('Bs', 'Dzb', 'Km', 'pip'), 'bdsth': rt.Decay('Bp', 'Dzb', 'g', 'pip'), 'partrec': 'Part Reco', 'lbdph': rt.Decay('Lb', 'Dzb', 'p', 'Km'), 'lbdstph': rt.Decay('Lb', 'Dzb', 'g', 'p', 'Km'), 'comb': 'Combinatorial' }, 'bspi0': { 'sig': rt.Decay('Bs', 'Dzb', 'piz', 'Km', 'pip'), 'misrec': rt.Decay('Bs', 'Dzb', 'g', 'Km', 'pip'), 'bdstpp': rt.Decay('Bs', 'Dzb', 'piz', 'pim', 'pip'), 'bdstkk': rt.Decay('Bs', 'Dzb', 'piz', 'Km', 'Kp'), 'bsdstkk': rt.Decay('Bs', 'Dzb', 'piz', 'Km', 'Kp'), 'bdkp': rt.Decay('Bs', 'Dzb', 'Km', 'pip'), 'bdsth': rt.Decay('Bp', 'Dzb', 'piz', 'pip'), 'partrec': 'Part Reco', 'lbdph': rt.Decay('Lb', 'Dzb', 'p', 'Km'), 'lbdstph': rt.Decay('Lb', 'Dzb', 'piz', 'p', 'Km'), 'comb': 'Combinatorial' }, 'cg': { 'sig': rt.Decay('Bd', 'Dzb', 'g', 'pip', 'pim'), 'misrec': rt.Decay('Bd', 'Dzb', 'piz', 'pip', 'pim'), 'bdstkp': rt.Decay('Bs', 'Dzb', 'g', 'Km', 'pip'), 'bdkp': rt.Decay('Bd', 'Dzb', 'Kp', 'pim'), 'bdsth': rt.Decay('Bm', 'Dzb', 'g', 'pim'), 'comb': 'Combinatorial' }, 'cpi0': { 'sig': rt.Decay('Bd', 'Dzb', 'piz', 'pip', 'pim'), 'misrec': rt.Decay('Bd', 'Dzb', 'g', 'pip', 'pim'), 'bdstkp': rt.Decay('Bs', 'Dzb', 'piz', 'Km', 'pip'), 'bdkp': rt.Decay('Bd', 'Dzb', 'Kp', 'pim'), 'bdsth': rt.Decay('Bm', 'Dzb', 'piz', 'pim'), 'comb': 'Combinatorial' }, } pl = w.var('B_DTFDict_D0_B_M').frame() if cat: pl.GetXaxis().SetTitle(xtitle[cat]) tleg = TLegend(0.6, 0.5, 0.9, 0.95) tleg.SetFillColorAlpha(0, 0.) tleg.SetLineColor(0) if w.data(dsetname): w.data(dsetname).plotOn(pl) if w.pdf(pdfname): w.pdf(pdfname).plotOn(pl) w.pdf(pdfname).plotOn(pl, rf.Components('comb_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kBlack)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['comb'], "L") if cat != 'cg' and cat != 'cpi0': w.pdf(pdfname).plotOn(pl, rf.Components('partrec_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kRed + 3)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['partrec'], "L") w.pdf(pdfname).plotOn(pl, rf.Components('lbdph_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kMagenta)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['lbdph'], "L") w.pdf(pdfname).plotOn(pl, rf.Components('lbdstph_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kMagenta + 3)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['lbdstph'], "L") w.pdf(pdfname).plotOn(pl, rf.Components('bdsth_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kRed - 3)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['bdsth'], "L") if cat != 'cg' and cat != 'cpi0': w.pdf(pdfname).plotOn(pl, rf.Components('bdkp_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kOrange - 3)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['bdkp'], "L") w.pdf(pdfname).plotOn(pl, rf.Components('bsdstkk_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kGreen + 1)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['bsdstkk'], "L") w.pdf(pdfname).plotOn(pl, rf.Components('bdstkk_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kGreen + 3)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['bdstkk'], "L") w.pdf(pdfname).plotOn(pl, rf.Components('bdstpp_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kRed)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['bdstpp'], "L") else: w.pdf(pdfname).plotOn(pl, rf.Components('bdstkp_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kOrange - 3)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['bdstkp'], "L") w.pdf(pdfname).plotOn(pl, rf.Components('misrec_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kCyan)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['misrec'], "L") w.pdf(pdfname).plotOn(pl, rf.Components('sig_mc_pdf_%s' % cat), rf.LineStyle(2), rf.LineColor(kBlue + 3)) tleg.AddEntry(pl.getObject(int(pl.numItems()) - 1), leg[cat]['sig'], "L") w.pdf(pdfname).plotOn(pl) if resid and w.data(dsetname) and w.pdf(pdfname): pu = TPad(pad.GetName() + '_pu', '', 0., 0.33, 1., 1.) pd = TPad(pad.GetName() + '_pd', '', 0., 0., 1., 0.33) pu.SetBottomMargin(0.03) pd.SetTopMargin(0.03) pd.SetBottomMargin(0.35) pad.cd() pu.Draw() pd.Draw() pu.cd() pl.GetYaxis().SetTitleOffset(1.1) pl.GetXaxis().SetLabelSize(0.) pl.Draw() if log: pl.GetYaxis().SetRangeUser(0.1, 2. * pl.GetMaximum()) pl.Draw() pu.SetLogy() pd.cd() pull = pl.pullHist() # roofit does something funny with pull hist range so need a dummy hist for it pull.Draw() ymax = max(abs(pull.GetYaxis().GetXmin()), pull.GetYaxis().GetXmax()) pulld = TH1F(pull.GetName() + '_pd', '', pl.GetNbinsX(), pl.GetXaxis().GetXmin(), pl.GetXaxis().GetXmax()) pulld.GetYaxis().SetRangeUser(-ymax, ymax) pulld.GetXaxis().SetTitle(pl.GetXaxis().GetTitle()) pulld.GetYaxis().SetTitle("Pull") pl.GetXaxis().SetTitle("") pulld.GetXaxis().SetTitleSize(0.13) pulld.GetYaxis().SetTitleSize(0.13) pulld.GetXaxis().SetLabelSize(0.13) pulld.GetYaxis().SetLabelSize(0.13) pulld.GetXaxis().SetTitleOffset(1.1) pulld.GetYaxis().SetTitleOffset(0.6) pulld.GetYaxis().SetNdivisions(505) pulld.GetXaxis().SetTickLength(0.06) ll = TLine() ll.SetLineWidth(4) ll.SetLineColor(4) pd.cd() pd.Clear() pulld.Draw("HIST") pull.Draw("EPsame") ll.DrawLine(pulld.GetXaxis().GetXmin(), 0., pulld.GetXaxis().GetXmax(), 0.) pulld.Draw("AXISsame") gROOT.Append(pulld) else: pad.cd() pl.Draw() if log: pl.GetYaxis().SetRangeUser(0.1, 2 * pl.GetMaximum()) pl.Draw() pad.SetLogy() gROOT.Append(tleg) pad.cd() if not log: tleg.Draw("same") pad.Update() pad.Modified()
def plot_histos(process): for hist_int in range(0, len(ejets_up)): f_ejets = TFile.Open(ejets_path + ejets_root_file, 'read') f_mujets = TFile.Open(mujets_path + mujets_root_file, 'read') f_SL = TFile.Open(singlelepton_path + singlelepton_root_file, 'read') c1 = TCanvas('c1', 'Histogram Drawing Options', 0, 0, 800, 800) pad1 = TPad("pad1", "pad1", 0, 0.49, 1, 1.0) pad1.SetBottomMargin(0) # joins upper and lower plot pad1.Draw() pad2 = TPad("pad2", "pad2", 0, 0.37, 1, 0.49) pad2.SetTopMargin(0.0) # joins upper and lower plot pad2.SetBottomMargin(0) pad2.Draw() pad3 = TPad("pad3", "pad3", 0, 0.25, 1, 0.37) pad3.SetTopMargin(0.0) # joins upper and lower plot pad3.SetBottomMargin(0) pad3.Draw() pad4 = TPad("pad4", "pad4", 0, 0.05, 1, 0.25) pad4.SetTopMargin(0.0) # joins upper and lower plot pad4.SetBottomMargin(0.4) pad4.Draw() pad1.cd() hist_name_ejets = ejets_up[hist_int] hist_name_mujets = mujets_up[hist_int] hist_name_singlelepton = singlelepton_up[hist_int] sim = similar(hist_name_ejets, hist_name_mujets) if "ttphoton_PDF" not in hist_name_ejets: if sim < 0.9: print hist_name_ejets, " and ", hist_name_mujets, " are different!" sys.exit() sim2 = similar(hist_name_singlelepton, hist_name_ejets) # These should be identical if sim2 != 1.0: print hist_name_singlelepton, " and ", hist_name_ejets, " are different!" sys.exit() g["nom_h_ejets"] = f_ejets.Get(ejets_nominal[0]) g["up_h_ejets"] = f_ejets.Get(ejets_up[hist_int]) g["down_h_ejets"] = f_ejets.Get(ejets_down[hist_int]) g["nom_h_mujets"] = f_mujets.Get(mujets_nominal[0]) g["up_h_mujets"] = f_mujets.Get(mujets_up[hist_int]) g["down_h_mujets"] = f_mujets.Get(mujets_down[hist_int]) g["nom_h_singlelepton"] = f_SL.Get(singlelepton_nominal[0]) g["up_h_singlelepton"] = f_SL.Get(singlelepton_up[hist_int]) g["down_h_singlelepton"] = f_SL.Get(singlelepton_down[hist_int]) for i in channels: y1 = g["up_h_" + i].GetYaxis() y1.SetTitle("Events") y1.SetTitleOffset(2) x1 = g["up_h_" + i].GetXaxis() x1.SetTitle("event level descriminator") g["up_h_" + i].SetTitle("") x1.SetTitleOffset(1.5) g["up_h_" + i].Draw("same") g["down_h_" + i].Draw("same") g["nom_h_" + i].Draw("same") nom_h_ejets.SetMarkerColor(1) nom_h_ejets.SetLineColor(1) up_h_ejets.SetMarkerColor(632) up_h_ejets.SetLineColor(632) down_h_ejets.SetMarkerColor(857) down_h_ejets.SetLineColor(857) nom_h_mujets.SetMarkerStyle(4) nom_h_mujets.SetMarkerColor(1) nom_h_mujets.SetLineColor(1) up_h_mujets.SetMarkerColor(632) up_h_mujets.SetLineColor(632) up_h_mujets.SetMarkerStyle(4) down_h_mujets.SetMarkerColor(857) down_h_mujets.SetLineColor(857) down_h_mujets.SetMarkerStyle(4) nom_h_singlelepton.SetMarkerStyle(26) nom_h_singlelepton.SetMarkerColor(1) nom_h_singlelepton.SetLineColor(1) up_h_singlelepton.SetMarkerColor(632) up_h_singlelepton.SetLineColor(632) up_h_singlelepton.SetMarkerStyle(26) down_h_singlelepton.SetMarkerColor(857) down_h_singlelepton.SetLineColor(857) down_h_singlelepton.SetMarkerStyle(26) legend = TLegend(0.15, 0.4, 0.55, 0.85) for i in channels: if i == "singlelepton": legend.AddEntry( g["nom_h_" + i], g[i + "_nominal"][0].replace("event_ELD_MVA_", "").replace( "ejets", "SL").replace("_regBin", "") + " nominal", "lep") legend.AddEntry( g["up_h_" + i], g[i + "_up"][hist_int].replace( "event_ELD_MVA_", "").replace("ejets", "SL").replace("_regBin", ""), "lep") legend.AddEntry( g["down_h_" + i], g[i + "_down"][hist_int].replace( "event_ELD_MVA_", "").replace("ejets", "SL").replace("_regBin", ""), "lep") else: legend.AddEntry( g["nom_h_" + i], g[i + "_nominal"][0].replace("event_ELD_MVA_", "").replace( "_regBin", "") + " nominal", "lep") legend.AddEntry( g["up_h_" + i], g[i + "_up"][hist_int].replace("event_ELD_MVA_", "").replace("_regBin", ""), "lep") legend.AddEntry( g["down_h_" + i], g[i + "_down"][hist_int].replace( "event_ELD_MVA_", "").replace("_regBin", ""), "lep") legend.SetBorderSize(0) legend.SetTextSize(0.03) legend.SetFillColorAlpha(1, 0) legend.Draw() c1.Update() pad2.cd() r1 = make_ratio(nom_h_ejets, up_h_ejets, down_h_ejets, "e+jets") pad3.cd() r2 = make_ratio(nom_h_mujets, up_h_mujets, down_h_mujets, "#mu+jets") pad4.cd() r3 = make_ratio(nom_h_singlelepton, up_h_singlelepton, down_h_singlelepton, "single lepton") if not os.path.exists("histos/" + process + "/"): os.makedirs("histos/" + process + "/") c1.SaveAs("histos/" + process + "/" + hist_name_ejets + ".pdf") del c1 for i in channels: del g["nom_h_" + i] del g["up_h_" + i] del g["down_h_" + i]
f_ET_5.SetLineWidth(4) f_ET_5.SetLineColor(kBlue) f_ET_5.Draw('same') f_ET_10 = TF1('f_ET_10', '10/sin(2*atan(exp(-x)))', getFloat(getInfBin(EtaRanges), 'p'), getFloat(getSupBin(EtaRanges), 'p')) f_ET_10.SetLineWidth(4) f_ET_10.SetLineColor(kMagenta) f_ET_10.Draw('same') legend1 = TLegend(0.1, 0.85, 0.4, 0.9) legend1.AddEntry('f_ET_2', 'E_{T} = 2GeV', 'l') legend1.SetTextSize(0.025) legend1.SetLineColor(0) legend1.SetFillColorAlpha(0, 0) legend1.SetBorderSize(0) legend1.Draw('same') legend2 = TLegend(0.1, 0.8, 0.4, 0.85) legend2.AddEntry('f_ET_5', 'E_{T} = 5GeV', 'l') legend2.SetTextSize(0.025) legend2.SetLineColor(0) legend2.SetFillColorAlpha(0, 0) legend2.SetBorderSize(0) legend2.Draw('same') legend3 = TLegend(0.1, 0.75, 0.4, 0.8) legend3.AddEntry('f_ET_10', 'E_{T} = 10GeV', 'l') legend3.SetTextSize(0.025) legend3.SetLineColor(0)
def plot_histos(process): for hist_int in range(0, len(ee_up)): f_ee = TFile.Open(ee_path + ee_root_file, 'read') f_mumu = TFile.Open(mumu_path + mumu_root_file, 'read') f_emu = TFile.Open(emu_path + emu_root_file, 'read') f_DL = TFile.Open(dilepton_path + dilepton_root_file, 'read') c1 = TCanvas('c1', 'Histogram Drawing Options', 0, 0, 800, 800) pad1 = TPad("pad1", "pad1", 0, 0.43, 1, 1.0) pad1.SetBottomMargin(0) # joins upper and lower plot pad1.Draw() pad2 = TPad("pad2", "pad2", 0, 0.36, 1, 0.43) pad2.SetTopMargin(0.0) # joins upper and lower plot pad2.SetBottomMargin(0) pad2.Draw() pad3 = TPad("pad3", "pad3", 0, 0.29, 1, 0.36) pad3.SetTopMargin(0.0) # joins upper and lower plot pad3.SetBottomMargin(0) pad3.Draw() pad4 = TPad("pad4", "pad4", 0, 0.22, 1, 0.29) pad4.SetTopMargin(0.0) # joins upper and lower plot pad4.SetBottomMargin(0) pad4.Draw() pad5 = TPad("pad5", "pad5", 0, 0.05, 1, 0.22) pad5.SetTopMargin(0.0) # joins upper and lower plot pad5.SetBottomMargin(0.4) pad5.Draw() pad1.cd() hist_name_ee = ee_up[hist_int] hist_name_mumu = mumu_up[hist_int] hist_name_emu = emu_up[hist_int] hist_name_dilepton = dilepton_up[hist_int] sim1 = similar(hist_name_ee, hist_name_mumu) sim2 = similar(hist_name_mumu, hist_name_emu) if "ttphoton_PDF" not in hist_name_ee: if sim1 < 0.9 or sim2 < 0.9: print hist_name_ee, " and ", hist_name_mumu, " are different!" sys.exit() sim3 = similar(hist_name_dilepton, hist_name_ee) # These should be identical if sim3 != 1.0: print hist_name_dilepton, " and ", hist_name_ee, " are different!" sys.exit() g["nom_h_ee"] = f_ee.Get(ee_nominal[0]) g["up_h_ee"] = f_ee.Get(ee_up[hist_int]) g["down_h_ee"] = f_ee.Get(ee_down[hist_int]) g["nom_h_mumu"] = f_mumu.Get(mumu_nominal[0]) g["up_h_mumu"] = f_mumu.Get(mumu_up[hist_int]) g["down_h_mumu"] = f_mumu.Get(mumu_down[hist_int]) g["nom_h_emu"] = f_emu.Get(emu_nominal[0]) g["up_h_emu"] = f_emu.Get(emu_up[hist_int]) g["down_h_emu"] = f_emu.Get(emu_down[hist_int]) g["nom_h_dilepton"] = f_DL.Get(dilepton_nominal[0]) g["up_h_dilepton"] = f_DL.Get(dilepton_up[hist_int]) g["down_h_dilepton"] = f_DL.Get(dilepton_down[hist_int]) for i in channels: y1 = g["up_h_" + i].GetYaxis() y1.SetTitle("Events") y1.SetTitleOffset(2) x1 = g["up_h_" + i].GetXaxis() x1.SetTitle("event level descriminator") g["up_h_" + i].SetTitle("") x1.SetTitleOffset(1.5) g["up_h_" + i].Draw("same") g["down_h_" + i].Draw("same") g["nom_h_" + i].Draw("same") nom_h_ee.SetMarkerColor(1) nom_h_ee.SetLineColor(1) up_h_ee.SetMarkerColor(632) up_h_ee.SetLineColor(632) down_h_ee.SetMarkerColor(857) down_h_ee.SetLineColor(857) nom_h_mumu.SetMarkerStyle(4) nom_h_mumu.SetMarkerColor(1) nom_h_mumu.SetLineColor(1) up_h_mumu.SetMarkerColor(632) up_h_mumu.SetLineColor(632) up_h_mumu.SetMarkerStyle(4) down_h_mumu.SetMarkerColor(857) down_h_mumu.SetLineColor(857) down_h_mumu.SetMarkerStyle(4) nom_h_emu.SetMarkerStyle(4) nom_h_emu.SetMarkerColor(1) nom_h_emu.SetLineColor(1) up_h_emu.SetMarkerColor(632) up_h_emu.SetLineColor(632) up_h_emu.SetMarkerStyle(4) down_h_emu.SetMarkerColor(857) down_h_emu.SetLineColor(857) down_h_emu.SetMarkerStyle(4) nom_h_dilepton.SetMarkerStyle(26) nom_h_dilepton.SetMarkerColor(1) nom_h_dilepton.SetLineColor(1) up_h_dilepton.SetMarkerColor(632) up_h_dilepton.SetLineColor(632) up_h_dilepton.SetMarkerStyle(26) down_h_dilepton.SetMarkerColor(857) down_h_dilepton.SetLineColor(857) down_h_dilepton.SetMarkerStyle(26) legend = TLegend(0.15, 0.4, 0.55, 0.85) for i in channels: if i == "dilepton": legend.AddEntry( g["nom_h_" + i], g[i + "_nominal"][0].replace("event_ELD_MVA_", "").replace( "ee", "SL").replace("_regBin", "") + " nominal", "lep") legend.AddEntry( g["up_h_" + i], g[i + "_up"][hist_int].replace( "event_ELD_MVA_", "").replace("ee", "SL").replace("_regBin", ""), "lep") legend.AddEntry( g["down_h_" + i], g[i + "_down"][hist_int].replace( "event_ELD_MVA_", "").replace("ee", "SL").replace("_regBin", ""), "lep") else: legend.AddEntry( g["nom_h_" + i], g[i + "_nominal"][0].replace("event_ELD_MVA_", "").replace( "_regBin", "") + " nominal", "lep") legend.AddEntry( g["up_h_" + i], g[i + "_up"][hist_int].replace("event_ELD_MVA_", "").replace("_regBin", ""), "lep") legend.AddEntry( g["down_h_" + i], g[i + "_down"][hist_int].replace( "event_ELD_MVA_", "").replace("_regBin", ""), "lep") legend.SetBorderSize(0) legend.SetTextSize(0.03) legend.SetFillColorAlpha(1, 0) legend.Draw() c1.Update() pad2.cd() r1 = make_ratio(nom_h_ee, up_h_ee, down_h_ee, "ee") pad3.cd() r2 = make_ratio(nom_h_mumu, up_h_mumu, down_h_mumu, "#mu#mu") pad4.cd() r4 = make_ratio(nom_h_emu, up_h_emu, down_h_emu, "e#mu") pad5.cd() r5 = make_ratio(nom_h_dilepton, up_h_dilepton, down_h_dilepton, "dilepton") if not os.path.exists("histos/" + process + "/"): os.makedirs("histos/" + process + "/") c1.SaveAs("histos/" + process + "/" + hist_name_ee + ".pdf") del c1 for i in channels: del g["nom_h_" + i] del g["up_h_" + i] del g["down_h_" + i]