def get_yield(background, tcut, isData) : cut = "" if not isData and "fakes" not in background.name: #cut = "(" + tcut + ") * " + str(b.scale_factor) #cut = "(" + tcut + ") * " + str(background.scale_factor) cut = "(" + tcut + ") " #cut = "(" + tcut + ") * eventweight * " + str(background.scale_factor) elif "fakes" in background.name : cut = "(" + tcut + ") * FakeWeight * " + str(background.scale_factor) print "fakes cut string = %s"%cut else : cut = "(" + tcut + ")" #if background.name == "zjets" : # print 45*"-" # print "%s scan: "%background.name # background.tree.Scan("eventweight",tcut) cut = r.TCut(cut) sel = r.TCut("1") #h = pu.th1f("h_"+background.treename+"_yield_", "", 20, -10, 10,"","") h = pu.th1f("h_"+background.treename+"_yield_", "", 4, 0, 4,"","") cmd = "%s>>%s"%("isMC", h.GetName()) background.tree.Draw(cmd, cut * sel, "goff") err = r.Double(0.0) integral = h.IntegralAndError(0, -1, err) h.Delete() return integral, err
def getCutYield(tcut, bkg, cutNumber) : # create a canvas to prevent ROOT from telling us its doing things c = r.TCanvas("c_"+bkg.treename+"_cutflow_"+str(cutNumber), "", 800, 600) c.cd() h = pu.th1f("h_"+bkg.treename+"_cutflow_"+str(cutNumber), "", 4, 0, 1,"","") #cut = "(" + tcut + ") * " + str(b.scale_factor) weight_str = "" if "fakes" in bkg.name : weight_str = "FakeWeight * " + str(bkg.scale_factor) print "fakes weight string = %s"%weight_str else : weight_str = "eventweight" cut = "(" + tcut + ") * %s * "%weight_str + str(bkg.scale_factor) #cut = "(" + tcut + ") * eventweight * " + str(bkg.scale_factor) cut = r.TCut(cut) sel = r.TCut("1") cmd = "isMC>>%s"%h.GetName() bkg.tree.Draw(cmd, cut * sel) stat_err = r.Double(0.0) integral = h.IntegralAndError(0,-1,stat_err) h.Delete() c.Close() # prevent annoying canvas warnings return integral
def get_yield(sample, region): cut = "(" + region.tcut + ")" cut = r.TCut(cut) sel = r.TCut("1") h = pu.th1f("h_" + str(sample.run_number) + "_%s" % region.name + "_yield", "", 4, -1, 3, "", "") cmd = "%s>>%s" % ("isMC", h.GetName()) sample.tree.Draw(cmd, cut * sel, "goff") err = r.Double(0.0) integral = h.IntegralAndError(0, -1, err) h.Delete() return integral, err
def get_histogram(plot, sig, reg, variation="") : """ Make the histogram for a given selection for the signal point 'sig' for a given variation variation : weighting ----------- ----------- right : susy3BodyRightPol left : susy3BodyLeftPol mass : susy3BodyOnlyMass """ final_weight = "" if variation == "nom" : final_weight = "eventweightNOPUPW" elif variation == "right" : final_weight = "eventweightNOPUPW * susy3BodyRightPol" elif variation == "left" : final_weight = "eventweightNOPUPW * susy3BodyLeftPol" elif variation == "mass" : final_weight = "eventweightNOPUPW * susy3BodyOnlyMass" else : print "get_histogram ERROR Unhandled variation \"" + variation + "\"! Exitting." sys.exit() cut = "(" + reg.tcut + ") * " + final_weight print "cut: ", cut cut = r.TCut(cut) sel = r.TCut("1") h = pu.th1f("h_" + variation + "_" + sig.name, "", int(plot.nbins), plot.x_range_min, plot.x_range_max, plot.x_label, plot.y_label) h.SetMinimum(plot.y_range_min) h.SetMaximum(plot.y_range_max) h.GetXaxis().SetTitleOffset(-999) h.GetXaxis().SetLabelOffset(-999) h.Sumw2() cmd = "%s>>%s"%(plot.variable, h.GetName()) sig.tree.Draw(cmd, cut * sel, "goff") return h
def make_wp_comparison_plot(variable, sample, reg) : print 50*"-" print "Plotting WP comparison : %s"%variable nice_names = {} nice_names["bjets_n"] = "b-jet Multiplicity" nice_names["sjets_n"] = "Non b-tagged jet Multiplicity" nice_names["bjets_pt0"] = "Lead b-jet p_{T} [GeV]" nice_names["bjets_pt1"] = "2nd b-jet p_{T} [GeV]" nice_names["bjets_pt2"] = "3rd b-jet p_{T} [GeV]" nice_names["bjets_pt3"] = "4th b-jet p_{T} [GeV]" nice_names["bjets_nTrk0"] = "Lead b-jet # tracks" nice_names["bjets_nTrk1"] = "2nd b-jet # tracks" nice_names["bjets_nTrk2"] = "3rd b-jet # tracks" nice_names["bjets_nTrk3"] = "4th b-jet # Ttracks" nice_names["bjets_jvt0"] = "Lead b-jet JVT" nice_names["bjets_jvt1"] = "2nd b-jet JVT" nice_names["bjets_jvt2"] = "3rd b-jet JVT" nice_names["bjets_jvt3"] = "4th b-jet JVT" nice_names["bjets_eta0"] = "Lead b-jet #eta" nice_names["bjets_eta1"] = "2nd b-jet #eta" nice_names["bjets_eta2"] = "3rd b-jet #eta" nice_names["bjets_eta3"] = "4th b-jet #eta" nice_names["mt2"] = "m_{t2} [GeV]" nice_names["MDR"] = "M_{#Delta}^{R} [GeV]" nice_names["DPB_vSS"] = "#Delta#phi_{#beta}^{R}" bounds = {} bounds["bjets_n"] = [1,0,10,1e9] bounds["sjets_n"] = [1,0,10,1e9] bounds["bjets_pt0"] = [10, 0, 350,1e9] bounds["bjets_pt1"] = [10, 0, 350,1e9] bounds["bjets_pt2"] = [10, 0, 200,1e9] bounds["bjets_pt3"] = [10, 0, 200,1e9] bounds["bjets_nTrk0"] = [1, 0, 30, 1e9] bounds["bjets_nTrk1"] = [1, 0, 30, 1e9] bounds["bjets_nTrk2"] = [1, 0, 30, 1e9] bounds["bjets_nTrk3"] = [1, 0, 30, 1e9] bounds["bjets_jvt0"] = [0.02, 0, 1, 1e9] bounds["bjets_jvt1"] = [0.02, 0, 1, 1e9] bounds["bjets_jvt2"] = [0.02, 0, 1, 1e9] bounds["bjets_jvt3"] = [0.02, 0, 1, 1e9] bounds["bjets_eta0"] = [0.2, -3, 3, 1e9] bounds["bjets_eta1"] = [0.2, -3, 3, 1e9] bounds["bjets_eta2"] = [0.2, -3, 3, 1e9] bounds["bjets_eta3"] = [0.2, -3, 3, 1e9] bounds["mt2"] = [10, 0, 300, 1e9] bounds["MDR"] = [10, 0, 300, 1e9] bounds["DPB_vSS"] = [0.1, 0, 3.2, 1e9] variables = {} variables["bjets_n"] = { 70 : "nBJets70", 77 : "nBJets", 85 : "nBJets85" , 0 : "nBJetsMatched"} variables["sjets_n"] = { 70 : "nSJets70", 77 : "nSJets", 85 : "nSJets85" , 0 : "nSJetsMatched"} variables["bjets_pt0"] = { 70 : "bj70_pt[0]", 77 : "bj_pt[0]", 85 : "bj85_pt[0]", 0 : "bjMatched_pt[0]"} variables["bjets_pt1"] = { 70 : "bj70_pt[1]", 77 : "bj_pt[1]", 85 : "bj85_pt[1]", 0 : "bjMatched_pt[1]" } variables["bjets_pt2"] = { 70 : "bj70_pt[2]", 77 : "bj_pt[2]", 85 : "bj85_pt[2]", 0 : "bjMatched_pt[2]" } variables["bjets_pt3"] = { 70 : "bj70_pt[3]", 77 : "bj_pt[3]", 85 : "bj85_pt[3]", 0 : "bjMatched_pt[3]" } variables["bjets_nTrk0"] = { 70 : "bj70_nTrk[0]", 77 : "bj_nTrk[0]", 85 : "bj85_nTrk[0]", 0 : "bjMatched_nTrk[0]" } variables["bjets_nTrk1"] = { 70 : "bj70_nTrk[1]", 77 : "bj_nTrk[1]", 85 : "bj85_nTrk[1]", 0 : "bjMatched_nTrk[1]" } variables["bjets_nTrk2"] = { 70 : "bj70_nTrk[2]", 77 : "bj_nTrk[2]", 85 : "bj85_nTrk[2]", 0 : "bjMatched_nTrk[2]" } variables["bjets_nTrk3"] = { 70 : "bj70_nTrk[3]", 77 : "bj_nTrk[3]", 85 : "bj85_nTrk[3]", 0 : "bjMatched_nTrk[3]" } variables["bjets_jvt0"] = { 70 : "bj70_jvt[0]", 77 : "bj_jvt[0]", 85 : "bj85_jvt[0]" , 0 : "bjMatched_jvt[0]"} variables["bjets_jvt1"] = { 70 : "bj70_jvt[1]", 77 : "bj_jvt[1]", 85 : "bj85_jvt[1]" , 0 : "bjMatched_jvt[1]"} variables["bjets_jvt2"] = { 70 : "bj70_jvt[2]", 77 : "bj_jvt[2]", 85 : "bj85_jvt[2]" , 0 : "bjMatched_jvt[2]"} variables["bjets_jvt3"] = { 70 : "bj70_jvt[3]", 77 : "bj_jvt[3]", 85 : "bj85_jvt[3]" , 0 : "bjMatched_jvt[3]"} variables["bjets_eta0"] = { 70 : "bj70_eta[0]", 77 : "bj_eta[0]", 85 : "bj85_eta[0]", 0 : "bjMatched_eta[0]" } variables["bjets_eta1"] = { 70 : "bj70_eta[1]", 77 : "bj_eta[1]", 85 : "bj85_eta[1]", 0 : "bjMatched_eta[1]" } variables["bjets_eta2"] = { 70 : "bj70_eta[2]", 77 : "bj_eta[2]", 85 : "bj85_eta[2]", 0 : "bjMatched_eta[2]" } variables["bjets_eta3"] = { 70 : "bj70_eta[3]", 77 : "bj_eta[3]", 85 : "bj85_eta[3]", 0 : "bjMatched_eta[3]" } variables["mt2"] = { 70 : "mt2", 77 : "mt2", 85 : "mt2", 0 : "mt2" } variables["MDR"] = { 70 : "MDR", 77 : "MDR", 85 : "MDR", 0 : "MDR" } variables["DPB_vSS"] = { 70 : "DPB_vSS", 77 : "DPB_vSS", 85 : "DPB_vSS", 0 : "DPB_vSS" } colors = {} colors[70] = 30 colors[77] = 38 colors[85] = 46 colors[0] = r.kBlack p = plot.Plot1D() p.initialize("%s"%str(reg.name), variable, "wp_comp_%s_%s"%(reg.name, variable)) p.labels(x=nice_names[variable], y = "Events") p.xax(bounds[variable][0], bounds[variable][1], bounds[variable][2]) p.yax(0.1, bounds[variable][3]) p.doLogY = True p.setRatioCanvas(p.name) # canvas rcan = p.ratioCanvas rcan.canvas.cd() rcan.upper_pad.cd() if p.isLog() : rcan.upper_pad.SetLogy(True) rcan.upper_pad.Update() # axes hax = r.TH1F("axis", "", int(p.nbins), p.x_range_min, p.x_range_max) hax.SetMinimum(p.y_range_min) hax.SetMaximum(1e9) hax.GetXaxis().SetTitle(p.x_label) hax.GetXaxis().SetTitleFont(42) hax.GetXaxis().SetLabelFont(42) hax.GetXaxis().SetLabelSize(0.035) hax.GetXaxis().SetTitleOffset(-999) hax.GetYaxis().SetTitle(p.y_label) hax.GetYaxis().SetTitleFont(42) hax.GetYaxis().SetLabelFont(42) hax.GetYaxis().SetTitleOffset(1.4) hax.GetYaxis().SetLabelOffset(0.013) hax.GetYaxis().SetLabelSize(1.2 * 0.035) hax.GetYaxis().SetTitleSize(0.055 * 0.85) hax.Draw() rcan.upper_pad.Update() # legend leg = pu.default_legend(xl=0.55, yl=0.71, xh=0.93, yh=0.90) # hists for different WP histos = {} working_points = [70, 77, 85, 0] for wp in working_points : if ("data" in sample.name or "run" in sample.name) and wp==0 : continue h = pu.th1f("h_" + variable + "_" + str(wp), "", int(p.nbins), p.x_range_min, p.x_range_max, p.x_label, p.y_label) h.SetLineColor(colors[wp]) if wp == 0 : h.SetLineStyle(2) h.SetFillStyle(0) h.SetLineWidth(2) h.GetXaxis().SetLabelOffset(-999) h.SetMaximum(1e9) h.Sumw2 weight_str = "eventweight" cut = "" if wp == 70 : reg.tcut += " && nBJets70>0" elif wp == 77 : reg.tcut += " && nBJets>0" elif wp == 85 : reg.tcut += " && nBJets85>0" elif wp == 0 : reg.tcut += " && nBJetsMatched>0" if "data" not in sample.name or "run" not in sample.name : cut = "(" + reg.tcut + ") * %s * %s"%(weight_str, str(8.42)) else : cut = "(" + reg.tcut + ")" cut = r.TCut(cut) sel = r.TCut("1") cmd = "%s>>+%s"%(variables[variable][wp], h.GetName()) sample.tree.Draw(cmd, cut * sel, "goff") # print the yield +/- stat error stat_err = r.Double(0.0) integral = h.IntegralAndError(0,-1, stat_err) print "%s : %.2f +/- %.2f"%(str(wp), integral, stat_err) # add overflow pu.add_overflow_to_lastbin(h) if wp != 0 : leg.AddEntry(h, "%s %s%% MV2c10 WP"%(sample.displayname, str(wp)), "l") elif wp==0 and ("data" not in sample.name or "run" not in sample.name) : leg.AddEntry(h, "%s 77%% MV2c10 + Truth Match"%sample.displayname, "l") histos[wp] = h rcan.upper_pad.Update() r.gPad.SetGrid() histos[70].Draw("hist") histos[77].Draw("hist same") histos[85].Draw("hist same") if len(histos)==4 : histos[0].Draw("hist same") rcan.upper_pad.Update() #draw the legend leg.Draw() # text pu.draw_text(text="ATLAS", x=0.18, y =0.85, size=0.06, font=72) pu.draw_text(text="Internal", x=0.325, y =0.85, size =0.06, font=42) if not ("run" in sample.name.lower() or "data" in sample.name.lower()) : pu.draw_text(text="L = ~27 fb^{-1}, #sqrt{s} = 13 TeV", x=0.18, y=0.79, size=0.04) else : pu.draw_text(text="L = ~200 pb^{-1}, #sqrt{s} = 13 TeV", x=0.18, y =0.79, size=0.04) pu.draw_text(text=reg.displayname, x=0.18, y=0.74, size=0.04) r.gPad.SetTickx() r.gPad.SetTicky() ######## Lower Pad rcan.lower_pad.cd() #h_den = histos[77].Clone("h_den") ## y-axis #yax = h_den.GetYaxis() #yax.SetRangeUser(0,2) #yax.SetTitle("WP X / WP 77%") #yax.SetTitleSize(0.1 * 0.83) #yax.SetLabelSize(0.1 * 0.81) #yax.SetLabelOffset(0.98 * 0.013 * 1.08) #yax.SetTitleOffset(0.45*1.2) #yax.SetLabelFont(42) #yax.SetTitleFont(42) #yax.SetNdivisions(5) ## x-axis #xax = h_den.GetXaxis() #xax.SetTitleSize(1.1 * 0.14) #xax.SetLabelSize(yax.GetLabelSize()) #xax.SetLabelOffset(1.15*0.02) #xax.SetTitleOffset(0.85*xax.GetTitleOffset()) #xax.SetLabelFont(42) #xax.SetTitleFont(42) #h_den.SetTickLength(0.06) #h_den.Draw("axis") #rcan.lower_pad.Update() # 70 h_70 = histos[70].Clone("h70") # y-axis yax = h_70.GetYaxis() #yax.SetRangeUser(0,2) yax.SetTitle("WP X / WP 77%") yax.SetTitleSize(0.1 * 0.83) yax.SetLabelSize(0.1 * 0.81) yax.SetLabelOffset(0.98 * 0.013 * 1.08) yax.SetTitleOffset(0.45*1.2) yax.SetLabelFont(42) yax.SetTitleFont(42) yax.SetNdivisions(5) # x-axis xax = h_70.GetXaxis() xax.SetTitleSize(1.0 * 0.14) xax.SetLabelSize(yax.GetLabelSize()) xax.SetLabelOffset(1.15*0.02) xax.SetTitleOffset(0.85*xax.GetTitleOffset()) xax.SetLabelFont(42) xax.SetTitleFont(42) h_77 = histos[77].Clone("h77") h_85 = histos[85].Clone("h85") h_70.GetYaxis().SetRangeUser(0,5) h_77.GetYaxis().SetRangeUser(0,5) h_85.GetYaxis().SetRangeUser(0,5) h_70.SetNdivisions(5) h_77.SetNdivisions(5) h_85.SetNdivisions(5) h_70.Divide(h_77) h_85.Divide(h_77) h_70.Draw("hist") h_85.Draw("hist same") if len(histos) == 4 : h_0 = histos[0].Clone("h0") h_0.GetYaxis().SetRangeUser(0,5) h_0.SetNdivisions(5) h_0.Divide(h_77) h_0.Draw("hist same") rcan.lower_pad.Update() # lines pu.draw_line(p.x_range_min, 1.0, p.x_range_max, 1.0, color=r.kRed, style=2, width=1) # save outname = p.name + "_" + sample.name + ".eps" rcan.canvas.SaveAs(outname) out = "./bjet_check_plots/" utils.mv_file_to_dir(outname, out, True) fullname = out + "/" + outname print "%s saved to : %s"%(outname, os.path.abspath(fullname))
def make_plot(samples, plot, region): c = plot.canvas c.cd() c.SetFrameFillColor(0) c.SetFillColor(0) c.SetLeftMargin(0.14) c.SetRightMargin(0.05) c.SetBottomMargin(1.3 * c.GetBottomMargin()) c.Update() r.gPad.SetGrid() # prepare legend leg = pu.default_legend(xl=0.6, yl=0.69, xh=0.97, yh=0.88) histos = [] for sample in samples: print "\t> %s" % sample.name hist_name = "" if "abs" in plot.variable: replace_var = plot.variable.replace("abs(", "") replace_var = replace_var.replace(")", "") hist_name = replace_var else: hist_name = plot.variable h = pu.th1f( "h_" + sample.name + "_" + hist_name, "", int(plot.nbins), plot.x_range_min, plot.x_range_max, plot.x_label, plot.y_label, ) h.SetLineColor(sample.color) if "allIchep" in sample.name or "allRuns" in sample.name: h.SetLineStyle(1) else: h.SetLineStyle(2) h.SetFillStyle(0) h.SetLineWidth(3) h.GetYaxis().SetTitleOffset(1.17 * h.GetYaxis().GetTitleOffset()) h.Sumw2 sel = r.TCut("1") cut = region.tcut cut = r.TCut(cut) cmd = "%s>>%s" % (plot.variable, h.GetName()) sample.tree.Draw(cmd, cut * sel, "goff") # normalize h.Scale(1 / h.Integral()) # add overflow pu.add_overflow_to_lastbin(h) leg.AddEntry(h, sample.displayname, "l") histos.append(h) c.Update() is_first = True for h in histos: if is_first: h.Draw("hist") is_first = False else: h.Draw("hist same") leg.Draw() c.Update() outname = plot.name + ".eps" c.SaveAs(outname) out = "./plots/" utils.mv_file_to_dir(outname, out, True) fullname = out + "/" + outname print "%s saved to : %s" % (outname, os.path.abspath(fullname))
def make_ttbar_comp_plots(var, region, samples) : print 50*"-" print "Making ttbar comparison plots, variable: %s"%var.name p = plot.Plot1D() p.initialize("%s"%str(region.name), var.name, "ttbar_comp_%s_%s"%(region.name, var.name)) p.labels(x=var.nice_name, y = "Arb. Units") p.xax(var.bounds[reg.name][0], var.bounds[reg.name][1], var.bounds[reg.name][2]) p.yax(0.1, var.bounds[reg.name][3]) p.doLogY = True p.setRatioCanvas(p.name) # canvas rcan = p.ratioCanvas rcan.canvas.cd() rcan.upper_pad.cd() if p.isLog() : rcan.upper_pad.SetLogy(True) rcan.upper_pad.Update() # axes hax = r.TH1F("axis", "", int(p.nbins), p.x_range_min, p.x_range_max) hax.SetMinimum(p.y_range_min) hax.SetMaximum(10000) hax.GetXaxis().SetTitle(var.nice_name) hax.GetXaxis().SetTitleFont(42) hax.GetXaxis().SetLabelFont(42) hax.GetXaxis().SetLabelSize(0.035) hax.GetXaxis().SetTitleOffset(-999) hax.GetYaxis().SetTitle(p.y_label) hax.GetYaxis().SetTitleFont(42) hax.GetYaxis().SetLabelFont(42) hax.GetYaxis().SetTitleOffset(1.4) hax.GetYaxis().SetLabelOffset(0.013) hax.GetYaxis().SetLabelSize(1.2 * 0.035) hax.GetYaxis().SetTitleSize(0.055 * 0.85) hax.Draw() rcan.upper_pad.Update() # legend leg = pu.default_legend(xl=0.55, yl=0.71, xh=0.93, yh=0.90) # histos histos_tmp = {} display_names = {} samples_for_order = ["nominal", "sherpa", "mgp"] colors = {} for s in samples : h = pu.th1f("h_" + var.name + "_" + str(s.name), "", int(p.nbins), p.x_range_min, p.x_range_max, p.x_label, p.y_label) h.SetLineColor(s.color) h.SetFillStyle(0) h.SetLineWidth(2) h.GetXaxis().SetLabelOffset(-999) h.SetMaximum(10000) h.Sumw2 display_names[s.name] = s.displayname colors[s.name] = s.color lumi_scale = 8.42 # not neeed for normalized distributions weight_str = "eventweight * %s"%lumi_scale cut = "(" + region.tcut + ") * %s"%weight_str cut = r.TCut(cut) sel = r.TCut("1") cmd = "%s>>+%s"%(var.name, h.GetName()) s.tree.Draw(cmd, cut * sel, "goff") #print yield stuffs stat_err = r.Double(0.0) integral = h.IntegralAndError(0,-1,stat_err) print "%s : %.2f +/- %.2f"%(s.name, integral, stat_err) # add overflow pu.add_overflow_to_lastbin(h) # norm to unity h.Scale(1/h.Integral()) histos_tmp[s.name] = h rcan.upper_pad.Update() r.gPad.SetGrid() histos = {} for sname in samples_for_order : for sn, hist in histos_tmp.iteritems() : if sn == sname : histos[sname] = hist leg.AddEntry(hist, display_names[sname], "l") histos["nominal"].Draw("hist") histos["sherpa"].Draw("hist same") histos["mgp"].Draw("hist same") # draw the legend leg.Draw() ############### lower pad rcan.lower_pad.cd() # nom h_nom = histos["nominal"].Clone("nominal") # sherpa h_sherpa = histos["sherpa"].Clone("sherpa") # mgpythia h_mgp = histos["mgp"].Clone("mgp") # y-axis yax = h_sherpa.GetYaxis() yax.SetTitle("Other/Nominal") yax.SetTitleSize(0.1 * 0.83) yax.SetLabelSize(0.1 * 0.81) yax.SetLabelOffset(0.98 * 0.013 * 1.08) yax.SetTitleOffset(0.45 * 1.2) yax.SetLabelFont(42) yax.SetTitleFont(42) yax.SetNdivisions(5) # x-axis xax = h_sherpa.GetXaxis() xax.SetTitleSize(1.0 * 0.14) xax.SetLabelSize(yax.GetLabelSize()) xax.SetLabelOffset(1.15 * 0.02) xax.SetTitleOffset(0.85 * xax.GetTitleOffset()) xax.SetLabelFont(42) xax.SetTitleFont(42) h_nom.GetYaxis().SetRangeUser(0,5) h_sherpa.GetYaxis().SetRangeUser(0,5) h_mgp.GetYaxis().SetRangeUser(0,5) h_nom.SetNdivisions(5) h_sherpa.SetNdivisions(5) h_mgp.SetNdivisions(5) h_sherpa.Divide(h_nom) h_mgp.Divide(h_nom) maxy_ = 5 if "bj_pt[0]" in var.name or "bj_pt[1]" in var.name: maxy_ = 2 elif "bj_pt[2]" in var.name : maxy_ = 3 elif "nBJets" in var.name : maxy_ = 2 elif "nSJets" in var.name : maxy_ = 3 elif "eta" in var.name : maxy_ = 2 elif "dphi_ll" in var.name or "pTll" in var.name : maxy_ = 2 elif "l_pt" in var.name : maxy_ = 2 elif "meff" in var.name or "met" in var.name : maxy_ = 2 elif "sj_pt" in var.name : maxy_ = 2 h_sherpa.GetYaxis().SetRangeUser(0,maxy_) h_mgp.GetYaxis().SetRangeUser(0,maxy_) h_sherpa.SetMarkerStyle(20) h_sherpa.SetMarkerColor(colors["sherpa"]) h_mgp.SetMarkerStyle(20) h_mgp.SetMarkerColor(colors["mgp"]) h_sherpa.Draw("pe") h_mgp.Draw("pe same") rcan.lower_pad.Update() # lines pu.draw_line(p.x_range_min, 1.0, p.x_range_max, 1.0, color=r.kRed, style=2, width=1) # save outname = p.name + ".eps" rcan.canvas.SaveAs(outname) out = "./ttbar_comp_plots/" utils.mv_file_to_dir(outname, out, True) fullname = out + "/" + outname print "%s saved to : %s"%(outname, os.path.abspath(fullname))
b.set_tree() b.Print() tcuts = {} displaynames = {} tcuts["test"] = "l_pt[0]>35" displaynames["test"] = "Dummy Region" testregion = region.Region() testregion.tcut = tcuts["test"] testregion.displayname = displaynames["test"] testregion.Print() c = pu.basic_canvas() c.cd() h1 = pu.th1f("test", "", 25, 0, 200, "p_{T} [GeV]", "Entries") h1.SetLineColor(b.color) h2 = pu.th1f("test2", "", 25, 0, 200, "p_{T} [GeV]", "Entries") h2.SetLineColor(s.color) cmd1 = "l_pt[0]>>%s"%h1.GetName() cmd2 = "l_pt[0]>>%s"%h2.GetName() print "background : %s"%str(b.tree.GetEntries()) print "signal : %s"%str(s.tree.GetEntries()) b.tree.Draw(cmd1, testregion.tcut) s.tree.Draw(cmd2, testregion.tcut) h1.Draw("hist") h2.Draw("hist same") leg = pu.default_legend() leg.AddEntry(h1, b.displayname, "l") leg.AddEntry(h2, s.displayname, "l")
def make_lumi_plot(samples, region): print "make_lumi_plot() Making lumi plot for %s" % region.name lumican = lumiCanvas("lumican_%s" % region.name) lumican.canvas.cd() # only plot those runs with >= 10/pb of data new_samples = [] for s in samples: if s.lumi >= 10: new_samples.append(s) samples = new_samples # only 2015 # new_samples = [] # for s in samples : # if int(s.run_number) < 297730 : new_samples.append(s) # samples = new_samples lumican.pad.cd() h = pu.th1f("h_lumi_" + region.name, "", int(len(samples)), 0, int(len(samples)), "Run Number", "Events/pb^{-1}") # h.SetBinErrorOption(r.TH1.kPoisson) # h.Sumw2() samples = sorted(samples, key=lambda x: x.run_number, reverse=False) maxy = -1 sum_ev = 0.0 lumi_list = [] for ibin, s_ in enumerate(samples): yld = s_.yields[region.name] lumi = s_.lumi lumi_list.append(lumi) norm = float(yld) / float(lumi) sum_ev += norm if norm > maxy: maxy = norm h.SetBinContent(ibin + 1, norm) h.SetBinError(ibin + 1, sqrt(yld) / float(lumi)) h.GetXaxis().SetBinLabel(ibin + 1, "%s" % str(s_.run_number)) avg_norm = float(sum_ev) / len(samples) maxima = {} maxima["srwPreselEE"] = 10.0 maxima["srwPreselMM"] = 10.0 maxima["srwPreselDF"] = 1.8 maxima["srtPreselEE"] = 5.0 maxima["srtPreselMM"] = 5.0 maxima["srtPreselDF"] = 8.0 # h.SetMaximum(maxima[region.name]) h.SetMaximum(2.15 * avg_norm) h.SetMarkerColor(r.TColor.GetColor("#386672")) h.SetMarkerSize(1.5 * h.GetMarkerSize()) h.SetMinimum(0) h.SetFillColor(0) h.SetLineColor(r.kBlack) ## labels h.GetXaxis().LabelsOption("v") h.GetXaxis().SetLabelFont(42) h.GetXaxis().SetLabelOffset(3.2 * h.GetXaxis().GetLabelOffset()) h.GetXaxis().SetLabelSize(1.2 * h.GetXaxis().GetLabelSize()) ## title # x h.GetXaxis().SetTitleSize(1.75 * h.GetXaxis().GetTitleSize()) h.GetXaxis().SetTitleOffset(1.5 * h.GetXaxis().GetTitleOffset()) # y h.GetYaxis().SetTitleOffset(0.5 * h.GetYaxis().GetTitleOffset()) h.GetYaxis().SetTitleSize(1.25 * h.GetYaxis().GetTitleSize()) # draw average norm lumi line pu.draw_line(0, avg_norm, len(samples), avg_norm, color=r.kRed, style=2, width=1) h.Draw("hist e") h.Fit("pol1") lumican.canvas.Update() h.Draw() pu.draw_line(0, avg_norm, len(samples), avg_norm, color=r.kRed, style=2, width=1) ## get periods and lines # period_lines = get_periodlines(samples, h.GetMaximum(), region.name) # for line in period_lines : # line.Draw() pu.draw_text_on_top(region.displayname + " 2015 + 2016 (DS1)") lumican.canvas.Update() lumican.canvas.SaveAs("normlumi_%s.eps" % region.name)
def getSystHistos(plot_, reg, bkg, syst, histname) : var_yields = [] h_up = pu.th1f("h_"+bkg.treename+"_"+histname+"_"+syst.name+"_up","", int(plot_.nbins), plot_.x_range_min, plot_.x_range_max, plot_.x_label, plot_.y_label) h_up.SetFillStyle(0) h_up.SetLineColor(46) h_dn = pu.th1f("h_"+bkg.treename+"_"+histname+"_"+syst.name+"_dn","", int(plot_.nbins), plot_.x_range_min, plot_.x_range_max, plot_.x_label, plot_.y_label) h_dn.SetFillStyle(0) h_dn.SetLineColor(38) if syst.isWeightSys() : #weight_up = "eventweight * pupw_up" #weight_dn = "eventweight * pupw_down" #weight_up = "eventweight * pupw * syst_PILEUPUP" #weight_dn = "eventweight * pupw * syst_PILEUPDOWN" #cut_up = "(" + reg.tcut + ") * " + weight_up + " * " + str(bkg.scale_factor) #cut_dn = "(" + reg.tcut + ") * " + weight_dn + " * " + str(bkg.scale_factor) tmp_up = str(syst.up_name) tmp_dn = str(syst.down_name) tmp_up = tmp_up.replace("syst_","") tmp_up = "syst_" + tmp_up tmp_dn = tmp_dn.replace("syst_","") tmp_dn = "syst_" + tmp_dn syst.up_name = tmp_up syst.down_name = tmp_dn weight_str = "" if "PILEUP" not in syst.name : weight_str = "eventweight" elif "PILEUP" in syst.name : weight_str = "eventweightNOPUPW" syst.up_name = "pupw_up" syst.down_name = "pupw_down" cut_up = "(" + reg.tcut + ") * " + weight_str + " * " + str(syst.up_name) + " * " + str(bkg.scale_factor) cut_dn = "(" + reg.tcut + ") * " + weight_str + " * " + str(syst.down_name) + " * " + str(bkg.scale_factor) cut_up = r.TCut(cut_up) cut_dn = r.TCut(cut_dn) sel = r.TCut("1") cmd_up = "%s>>%s"%(plot_.variable, h_up.GetName()) cmd_dn = "%s>>%s"%(plot_.variable, h_dn.GetName()) syst.tree.Draw(cmd_up, cut_up * sel) syst.tree.Draw(cmd_dn, cut_dn * sel) ## overflow pu.add_overflow_to_lastbin(h_up) pu.add_overflow_to_lastbin(h_dn) var_yields.append(h_up.Integral(0,-1)) var_yields.append(h_dn.Integral(0,-1)) print "up: ",var_yields[0] print "dn: ",var_yields[1] syst.up_histo = h_up syst.down_histo = h_dn elif syst.isKinSys() : cut = "(" + reg.tcut + ") * eventweight * " + str(bkg.scale_factor) cut = r.TCut(cut) sel = r.TCut("1") cmd_up = "%s>>%s"%(plot_.variable, h_up.GetName()) cmd_dn = "%s>>%s"%(plot_.variable, h_dn.GetName()) syst.tree_up.Draw(cmd_up, cut*sel) pu.add_overflow_to_lastbin(h_up) syst.up_histo = h_up var_yields.append(h_up.Integral(0,-1)) if "JER" not in syst.name : # if not syst.isOneSided() or "JER" in syst.name : syst.tree_down.Draw(cmd_dn, cut*sel) pu.add_overflow_to_lastbin(h_dn) syst.down_histo = h_dn var_yields.append(h_dn.Integral(0,-1)) print "up: ", var_yields[0] return var_yields
def make_sys_plot(plot_, region, bkg_list, sys_list) : # canvases rcan = plot_.ratioCanvas rcan.canvas.cd() rcan.upper_pad.cd() if plot_.isLog() : rcan.upper_pad.SetLogy(True) rcan.upper_pad.Update() # stack for MC hax = r.TH1F("axes", "", int(plot_.nbins), plot_.x_range_min, plot_.x_range_max) hax.SetMinimum(plot_.y_range_min) hax.SetMaximum(plot_.y_range_max) hax.GetXaxis().SetTitle(plot_.x_label) hax.GetXaxis().SetTitleFont(42) hax.GetXaxis().SetLabelFont(42) hax.GetXaxis().SetLabelSize(0.035) hax.GetXaxis().SetTitleSize(0.048 * 0.85) hax.GetXaxis().SetTitleOffset(-999) hax.GetXaxis().SetLabelOffset(-999) hax.GetYaxis().SetTitle(plot_.y_label) hax.GetYaxis().SetTitleFont(42) hax.GetYaxis().SetLabelFont(42) hax.GetYaxis().SetTitleOffset(1.4) hax.GetYaxis().SetLabelOffset(0.013) hax.GetYaxis().SetLabelSize(1.2 * 0.035) hax.GetYaxis().SetTitleSize(0.055 * 0.85) hax.Draw() rcan.upper_pad.Update() nom_stack = r.THStack("stack_" + plot_.name + "_nom", "") up_stack = r.THStack("stack_" + plot_.name + "_up", "") down_stack = r.THStack("stack_" + plot_.name + "_down", "") # legend leg = pu.default_legend(xl=0.62, yl=0.68, xh=0.93, yh=0.90) if len(sys_list) > 1 : print "ERROR you should only provide this method one systematic" sys.exit() # loop through background MC and add to stack nom_histos = [] up_histos = [] down_histos = [] syst = sys_list[0] for b in bkg_list : ####################################### ## nominal hist_name = "" if "abs" in plot_.variable : replace_var = plot_.variable.replace("abs(","") replace_var = replace_var.replace(")","") hist_name = replace_var else : hist_name = plot_.variable h = pu.th1f("h_" + b.treename + "_" + hist_name + "_nom", "", int(plot_.nbins), plot_.x_range_min, plot_.x_range_max, plot_.x_label, plot_.y_label) h.SetLineColor(r.kBlack) h.SetLineWidth(2*h.GetLineWidth()) h.SetFillStyle(0) h.GetXaxis().SetLabelOffset(-999) # cut and make the sample wait cut = "(" + region.tcut + ") * eventweight * " + str(b.scale_factor) cut = r.TCut(cut) sel = r.TCut("1") cmd = "%s>>+%s"%(plot_.variable, h.GetName()) b.tree.Draw(cmd, cut * sel, "goff") stat_err = r.Double(0.0) nom_integral = h.IntegralAndError(0,-1,stat_err) print "nom: ",nom_integral # add overflow pu.add_overflow_to_lastbin(h) nom_histos.append(h) rcan.upper_pad.Update() ############################## # fill variation histos for x in b.systList : if x.name == syst.name : syst = x sys_yields = getSystHistos(plot_, region, b, syst, hist_name) syst.up_histo.SetLineColor(46) syst.up_histo.SetFillStyle(0) up_histos.append(syst.up_histo) if "JER" not in syst.name : #if not syst.isOneSided() : syst.down_histo.SetFillStyle(0) syst.down_histo.SetLineColor(38) down_histos.append(syst.down_histo) ## order the histos (not really necessary for this) nom_histos = sorted(nom_histos, key=lambda h: h.Integral(), reverse=False) up_histos = sorted(up_histos, key=lambda h: h.Integral(), reverse=False) if not syst.isOneSided() : down_histos = sorted(down_histos, key=lambda h: h.Integral(), reverse=False) for h in nom_histos : nom_stack.Add(h) for h in up_histos : up_stack.Add(h) #if not syst.isOneSided() : if "JER" not in syst.name : for h in down_histos : down_stack.Add(h) ############################ get the envelopes nom_total = nom_stack.GetStack().Last().Clone("nom_total") nom_total.SetMaximum(plot_.y_range_max) nom_total.SetMinimum(plot_.y_range_min) nom_total.SetLineColor(r.kBlack) nom_total.SetLineWidth(1*nom_total.GetLineWidth()) nom_total.SetFillStyle(0) leg.AddEntry(nom_total, "Nominal", "l") up_total = up_stack.GetStack().Last().Clone("up_total") up_total.SetMaximum(plot_.y_range_max) up_total.SetMinimum(plot_.y_range_min) up_total.SetLineColor(46) up_total.SetLineWidth(1*up_total.GetLineWidth()) up_total.SetFillStyle(0) var_up = "" if "JER" in syst.name : var_up = "Variation" else : var_up = "Up-Variation" leg.AddEntry(up_total, var_up, "l") if "JER" not in syst.name : down_total = down_stack.GetStack().Last().Clone("down_total") down_total.SetMaximum(plot_.y_range_max) down_total.SetMinimum(plot_.y_range_min) down_total.SetLineColor(38) down_total.SetLineWidth(1*down_total.GetLineWidth()) down_total.SetFillStyle(0) leg.AddEntry(down_total, "Down-Variation", "l") ############################# draw! nom_total.Draw("hist") up_total.Draw("hist same") if "JER" not in syst.name : down_total.Draw("hist same") rcan.upper_pad.Update() r.gPad.SetTickx() r.gPad.SetTicky() rcan.upper_pad.Update() ############################ words pu.draw_text(text="#it{ATLAS} Preliminary", x= 0.18, y = 0.85) pu.draw_text(text="13 TeV, 3.2/fb", x=0.18,y=0.8) pu.draw_text(text=region.displayname, x=0.18,y=0.75) pu.draw_text(text=syst.name,x=0.18,y=0.7) rcan.upper_pad.Update() ############################# ratios rcan.lower_pad.cd() up_ratio = up_total.Clone("up_ratio") up_ratio.Divide(nom_total) down_ratio = None if "JER" not in syst.name : down_ratio = down_total.Clone("down_ratio") down_ratio.Divide(nom_total) ## axis for lower pad yax = up_ratio.GetYaxis() yax.SetRangeUser(0,2) yax.SetTitle("Variation/Nominal") yax.SetTitleSize(nom_total.GetYaxis().GetTitleSize()) # yax.SetTitleSize(0.14 * 0.5) yax.SetLabelSize(nom_total.GetYaxis().GetLabelSize()) # yax.SetLabelSize(0.13) yax.SetLabelOffset(1.2 * nom_total.GetYaxis().GetLabelOffset()) # yax.SetLabelOffset(0.98 * 0.013) # yax.SetTitleOffset(0.45) yax.SetTitleOffset(nom_total.GetYaxis().GetTitleOffset()) yax.SetLabelFont(42) yax.SetTitleFont(42) yax.SetNdivisions(5) xax = up_ratio.GetXaxis() xax.SetTitleSize(1.2 * 0.14) xax.SetLabelSize(0.13) xax.SetLabelOffset(1.15*0.02) xax.SetTitleOffset(0.85 * xax.GetTitleOffset()) xax.SetLabelFont(42) xax.SetTitleFont(42) up_ratio.Draw("hist") if down_ratio : down_ratio.Draw("hist same") rcan.lower_pad.Update() ########################### save outname = plot_.name + "_" + syst.name + ".eps" rcan.canvas.SaveAs(outname) out = indir + "/plots/" + outdir utils.mv_file_to_dir(outname, out, True) fullname = out + "/" + outname print "%s saved to : %s"%(outname, os.path.abspath(fullname)) nom_total.Delete() up_total.Delete() if "JER" not in syst.name : down_total.Delete() hax.Delete()
def make_fjvt_plots(higgs, zjets) : # pre-selection regions reg_pre_fjvt, reg_pre_nfjvt = get_pre_regions() regions = [reg_pre_fjvt, reg_pre_nfjvt] # variables nice_names = {} nice_names["mjj"] = "m_{jj} [GeV]" nice_names["deta"] = "|#Delta#eta|" nice_names["centrality"] = "Lepton centrality" nice_names["recoil"] = "f_{recoil}" nice_names["nsjets"] = "Number of jets" nice_names["jpt0"] = "Lead jet p_{T} [GeV]" nice_names["jpt1"] = "Sub-lead jet p_{T} [GeV]" bounds = {} bounds["mjj"] = [100, 0, 3000,1e10] bounds["deta"] = [0.4,0,8,1e10] bounds["centrality"] = [0.4, -2,5,1e10] bounds["recoil"] = [0.1, 0, 5,1e10] bounds["nsjets"] = [1,2,6,1e10] bounds["jpt0"] = [20, 0, 300,1e10] bounds["jpt1"] = [20, 0, 300,1e10] variables = {} variables["mjj"] = { "fjvt" : "mjj_sj", "nfjvt" : "mjj_snpj" } variables["deta"] = { "fjvt" : "deta_sj", "nfjvt" : "deta_snpj" } variables["centrality"] = { "fjvt" : "lep_centrality_sjet", "nfjvt" : "lep_centrality_snpjet" } variables["recoil"] = { "fjvt" : "f_recoil_sjet", "nfjvt" : "f_recoil_snpjet" } variables["nsjets"] = { "fjvt" : "nSJets", "nfjvt" : "nSNPJets" } variables["jpt0"] = { "fjvt" : "sj_pt[0]", "nfjvt" : "snpj_pt[0]" } variables["jpt1"] = { "fjvt" : "sj_pt[1]", "nfjvt" : "snpj_pt[1]" } line_styles = {} line_styles["fjvt"] = 1 line_styles["nfjvt"] = 2 for var in variables.keys() : print "Plotting %s"%var p = plot.Plot1D() p.initialize("fjvt_check_%s"%str(var), str(var), "fjvt_check_%s"%str(var)) p.labels(x=nice_names[var], y = "Arb. Units") p.xax(bounds[var][0], bounds[var][1], bounds[var][2]) p.setRatioCanvas(p.name) # canvas rcan = p.ratioCanvas rcan.upper_pad.cd() # axis hax = r.TH1F("axis", "", int(p.nbins), p.x_range_min, p.x_range_max) hax.SetMinimum(10) hax.GetXaxis().SetTitle(nice_names[var]) hax.Draw() rcan.upper_pad.Update() histos = [] maxy_ = -1 for reg in regions : print " > Region %s"%reg.name if "nfjvt" in reg.name : key = "nfjvt" else : key = "fjvt" for proc in [higgs, zjets] : print " >> %s"%proc.name h = pu.th1f("h_" + var + "_" + str(key) + "_" + proc.name, "", int(p.nbins), p.x_range_min, p.x_range_max, p.x_label, p.y_label) h.SetLineColor(proc.color) h.SetLineStyle(line_styles[key]) h.SetFillStyle(0) h.SetLineWidth(2) h.GetXaxis().SetLabelOffset(-999) h.Sumw2 weight_str = "eventweight" if "higgs" in proc.name : weight_str += " * 1e5" cut = "(" + reg.tcut + ") * " + weight_str cut = r.TCut(cut) sel = r.TCut("1") cmd = "%s>>%s"%(variables[var][key], h.GetName()) proc.tree.Draw(cmd, cut * sel, "goff") pu.add_overflow_to_lastbin(h) stat_err = r.Double(0.0) integral = h.IntegralAndError(0,-1,stat_err) print "%s (%s) : %.2f +/- %.2f"%(str(proc.name), key, integral, stat_err) # normalize #h.Scale(1/h.Integral()) if h.GetMaximum() > maxy_ : maxy_ = 1.2 * h.GetMaximum() histos.append(h) rcan.upper_pad.Update() r.gPad.SetGrid() for h in histos : h.SetMaximum(maxy_) # legend leg = pu.default_legend(xl=0.55, yl=0.71, xh=0.93, yh=0.90) h_higgs_fjvt = None h_higgs_nfjvt = None h_zjets_fjvt = None h_zjets_nfjvt = None for h in histos : if "nfjvt" in h.GetName() : if "higgs" in h.GetName() : h_higgs_nfjvt = h else : h_zjets_nfjvt = h else : if "higgs" in h.GetName() : h_higgs_fjvt = h else : h_zjets_fjvt = h #h_higgs_nfjvt.Scale(h_zjets_nfjvt.Integral()) #h_higgs_fjvt.Scale(h_zjets_fjvt.Integral()) #h_higgs_nfjvt.Scale(h_zjets_nfjvt.Integral()/h_higgs_nfjvt.Integral()) #h_higgs_fjvt.Scale(h_zjets_fjvt.Integral()/h_zjets_fjvt.Integral()) leg.AddEntry(h_higgs_fjvt, "VBF Higgs x1e5 (w/ fJVT)", "l") leg.AddEntry(h_higgs_nfjvt, "VBF Higgs x1e5 (w/out fJVT)", "l") leg.AddEntry(h_zjets_fjvt, "Z+jets (w/ fJVT)", "l") leg.AddEntry(h_zjets_nfjvt, "Z+jets (w/out fJVT)", "l") ## draw h_higgs_fjvt.Draw("hist") h_higgs_nfjvt.Draw("hist same") h_zjets_fjvt.Draw("hist same") h_zjets_nfjvt.Draw("hist same") ## draw legend leg.Draw() r.gPad.SetTickx() r.gPad.SetTicky() ######################## LOWER PAD rcan.lower_pad.cd() # higgses h_h_nfjvt = h_higgs_nfjvt.Clone("higgs_nofjvt") h_h_ratio = h_higgs_fjvt.Clone("higgs_fjvt") h_h_ratio.Divide(h_h_nfjvt) h_h_ratio.GetYaxis().SetRangeUser(0,5) # zjetses h_z_nfjvt = h_zjets_nfjvt.Clone("zjets_nofjvt") h_z_ratio = h_zjets_fjvt.Clone("zjets_fjvt") h_z_ratio.Divide(h_z_nfjvt) h_z_ratio.GetYaxis().SetRangeUser(0,5) # axes haxis = [h_h_ratio, h_z_ratio] for hax in haxis : yax = hax.GetYaxis() yax.SetTitle("fJVT / no fJVT") yax.SetTitleSize(0.1 * 0.83) yax.SetLabelSize(0.1 * 0.81) yax.SetLabelOffset(0.98 * 0.013 * 1.08) yax.SetTitleOffset(0.45 * 1.2) yax.SetLabelFont(42) yax.SetTitleFont(42) yax.SetNdivisions(5) xax = hax.GetXaxis() xax.SetTitleSize(1.0 * 0.14) xax.SetLabelSize(yax.GetLabelSize()) xax.SetLabelOffset(1.15 * 0.02) xax.SetTitleOffset(0.85 * xax.GetTitleOffset()) xax.SetLabelFont(42) xax.SetTitleFont(42) h_h_ratio.Draw("hist") h_z_ratio.Draw("hist same") # save outname = p.name + ".eps" rcan.canvas.SaveAs(outname) out = "./fjvtcheck/" utils.mv_file_to_dir(outname, out, True) fullname = out + outname print "%s saved to : %s"%(outname, os.path.abspath(fullname))
def make_plotsRatio(plot, region, backgrounds) : print "make_plotsRatio Plotting %s"%plot.name # get the canvases rcan = plot.ratioCanvas rcan.canvas.cd() rcan.upper_pad.cd() if plot.isLog() : rcan.upper_pad.SetLogy(True) rcan.upper_pad.Update() # set up the frame hax = r.TH1F("axes", "", int(plot.nbins), plot.x_range_min, plot.x_range_max) hax.SetMinimum(plot.y_range_min) hax.SetMaximum(plot.y_range_max) xax = hax.GetXaxis() xax.SetTitle(plot.x_label) xax.SetTitleFont(42) xax.SetLabelFont(42) xax.SetLabelSize(0.035) xax.SetTitleSize(0.048 * 0.85) xax.SetTitleOffset(-999) xax.SetLabelOffset(-999) yax = hax.GetYaxis() yax.SetTitle(plot.y_label) yax.SetTitleFont(42) yax.SetLabelFont(42) yax.SetTitleOffset(1.4) yax.SetLabelOffset(0.013) yax.SetLabelSize(1.2 * 0.035) yax.SetTitleSize(0.055 * 0.85) hax.Draw() rcan.upper_pad.Update() # legend leg = pu.default_legend(xl=0.65, yl=0.72, xh=0.93, yh=0.90) histos = [] n_drawn = 0 for b in backgrounds : hist_name = "" if "abs" in plot.variable : replace_var = plot.variable.replace("abs(", "") replace_var = replace_var.replace(")", "") hist_name = replace_var else : hist_name = plot.variable h = None h = pu.th1f("h_"+b.treename+"_"+b.name+"_"+hist_name, "", int(plot.nbins), plot.x_range_min, plot.x_range_max, plot.x_label, plot.y_label) h.SetMinimum(0.1) h.SetLineColor(b.color) h.GetXaxis().SetLabelOffset(-999) h.SetLineWidth(2) h.SetFillStyle(0) h.Sumw2() idx = "" if "WW" in b.name or "ww" in b.name : idx = "WW" elif "WZ" in b.name or "wz" in b.name : idx = "WZ" sumw = get_sumw(idx) xsec = get_xsec(idx) lumi = 3300.0 # 3.3/fb weight_str = "eventweight * %s * %s / %s"%(str(xsec), str(lumi), str(sumw)) print "weight = %s"%weight_str cut = "(" + reg.tcut + ") * %s "%weight_str #cut = "(" + reg.tcut + ") * eventweight * " + str(b.scale_factor) cut = r.TCut(cut) sel = r.TCut("1") cmd = "%s>>%s"%(plot.variable, h.GetName()) b.tree.Draw(cmd, cut * sel, "goff") # yield stat_err = r.Double(0.0) integral = h.IntegralAndError(0,-1,stat_err) print "%s: %.2f +/- %.2f"%(b.name, integral, stat_err) # add overflow pu.add_overflow_to_lastbin(h) leg.AddEntry(h, b.displayname, "l") histos.append(h) #rcan.upper_pad.Update() #rcan.canvas.Update() h_WW = None h_WZ = None for h in histos : if "WW" in h.GetName() or "ww" in h.GetName() : h_WW = h rcan.upper_pad.Update() elif "WZ" in h.GetName() or "wz" in h.GetName() : h_WZ = h rcan.upper_pad.Update() else : print "Expecting a histogram with name that has 'WZ/wz' or 'WW/ww' in it" sys.exit() h_WW.Draw() h_WZ.Draw("same")
h_WZ.Scale(1/h_WZ.Integral()) h_WW.Scale(1/h_WW.Integral()) leg.Draw() r.gPad.RedrawAxis() ########################## # Lower Pad ########################## rcan.lower_pad.cd() # h_ratio = h_WW.Clone("h_ratio") h_ratio = pu.th1f("h_ratio_"+plot.name, "", int(plot.nbins), plot.x_range_min, plot.x_range_max, "", "") # y-axis axy = h_ratio.GetYaxis() axy.SetRangeUser(0,2) axy.SetTitle("WZ' / WW") axy.SetTitleSize(0.14) axy.SetLabelSize(0.13) axy.SetLabelOffset(0.98 * 0.013) axy.SetTitleOffset(0.45) axy.SetLabelFont(42) axy.SetTitleFont(42) axy.SetNdivisions(5) # x-axis axx = h_ratio.GetXaxis() axx.SetTitle(plot.x_label)
def make_znRatioPlots(backgrounds, signals, region, plot) : print "make_znRatioPlots Plottings %s"%plot.name # get canvases ratiocan = plot.getCanvas() ratiocan.canvas.cd() # go to the upper-pad ratiocan.upper_pad.cd() ratiocan.upper_pad.Draw() ratiocan.middle_pad.cd() ratiocan.middle_pad.Draw() ratiocan.lower_pad.cd() ratiocan.lower_pad.Draw() ratiocan.canvas.cd() ratiocan.upper_pad.cd() if plot.isLog() : ratiocan.upper_pad.SetLogy(True) ratiocan.upper_pad.Update() # stack for MC backgrounds ratiocan.upper_pad.cd() hax = r.TH1F("axes", "", int(plot.nbins), plot.x_range_min, plot.x_range_max) hax.SetMinimum(plot.y_range_min) hax.SetMaximum(plot.y_range_max) hax.GetXaxis().SetTitle(plot.x_label) hax.GetXaxis().SetTitleFont(42) hax.GetXaxis().SetLabelFont(42) hax.GetXaxis().SetLabelSize(0.035) hax.GetXaxis().SetTitleSize(0.048 * 0.85) hax.GetXaxis().SetTitleOffset(-999) hax.GetXaxis().SetLabelOffset(-999) hax.GetYaxis().SetTitle(plot.y_label) hax.GetYaxis().SetTitleFont(42) hax.GetYaxis().SetLabelFont(42) hax.GetYaxis().SetTitleOffset(1.4) hax.GetYaxis().SetLabelOffset(0.013) hax.GetYaxis().SetLabelSize(1.2 * 0.035) hax.GetYaxis().SetTitleSize(0.055 * 0.85) hax.Draw() ratiocan.upper_pad.Update() stack = r.THStack("stack_"+plot.name, "") # legend leg = pu.default_legend(xl=0.5, yl=0.6, xh=0.93, yh=0.90) #leg = pu.default_legend(xl=0.65, yl=0.72, xh=0.93, yh=0.90) leg.SetNColumns(2) ### loop through the background MC and add to stack histos = [] hist_dict = {} # associate the background with its histogram name hist_name = "" if "abs" in plot.variable : replace_var = plot.variable.replace("abs(","") replace_var = replace_var.replace(")","") hist_name = replace_var elif "MDR_v1_t1_0 - MDR_i1_t1_0" in plot.variable : hist_name = "RATIO" elif "RPT_0/RPZ_0" in plot.variable : hist_name = "RPTZratio" elif "H_11_SS/H_21_SS" in plot.variable : hist_name = "RH11SSH21SS" elif "H_11_SS/H_11_S1" in plot.variable : hist_name = "RH11SSH11S1" elif "xH_11_S1/xH_42_SS" in plot.variable : hist_name = "xH_11_S1_over_xH_42_SS" elif "xH_42_SS_T/xH_42_SS" in plot.variable : hist_name = "xH_42_SS_T_over_xH_42_SS" elif "xH_11_SS/xH_42_SS_T" in plot.variable : hist_name = "xH_11_SS_over_xH_42_SS_T" elif "(xNV[0]-xNV[1])/(xNV[0]+xNV[1])" in plot.variable : hist_name = "n_obs_asy" elif "xH_11_SS/xH_42_SS_T" in plot.variable : hist_name = "xH_11_SSoverxH_42_SS_T" elif "xH_42_SS_T/xH_11_SS" in plot.variable : hist_name = "xH_42_SS_ToverxH_11_SS" else : hist_name = plot.variable for b in backgrounds : h = pu.th1f("h_"+b.treename+"_"+hist_name, "", int(plot.nbins), plot.x_range_min, plot.x_range_max, plot.x_label, plot.y_label) h.SetLineColor(r.kBlack) h.SetFillColor(b.color) h.SetFillStyle(1001) h.Sumw2 # cut and make the sample weighted, applying the scale_factor cut = "(" + reg.tcut + ") * eventweight * " + str(b.scale_factor) cut = r.TCut(cut) sel = r.TCut("1") cmd = "%s>>%s"%(plot.variable, h.GetName()) b.tree.Draw(cmd, cut * sel, "goff") # print the yield +/- stat error stat_error = r.Double(0.0) integral = h.IntegralAndError(0, -1, stat_error) print "%s: %.2f +/- %.2f"%(b.name, integral, stat_error) # add overflow pu.add_overflow_to_lastbin(h) # add to group histos.append(h) hist_dict[h.GetName()] = b.displayname # ratiocan.upper_pad.Update() # order the histograms and add to legend histos = sorted(histos, key = lambda h: h.Integral(), reverse = False) for his in histos : stack.Add(his) histos_leg = sorted(histos, key = lambda h: h.Integral(), reverse = True) for hl in histos_leg : leg.AddEntry(hl, hist_dict[hl.GetName()], "f") #leg.AddEntry(hl, hist_dict[hl.GetName()], "fl") ### total SM histo totalSM = stack.GetStack().Last().Clone("totalSM") ### container for zn pads sig_values = {} ### now plot the signal points sig_histos = [] for s in signals : sig_values[s.name] = {} # { up : [], down : [] } hs = pu.th1f("h_"+s.treename+"_"+hist_name, "", int(plot.nbins), plot.x_range_min, plot.x_range_max, plot.x_label, plot.y_label) hs.SetLineColor(s.color) hs.SetLineStyle(2) hs.SetLineWidth(2) hs.SetFillStyle(0) hs.Sumw2 # cut and make sample weighted, applying the scale_factor cut = "(" + reg.tcut + ") * eventweight *" + str(s.scale_factor) cut = r.TCut(cut) sel = r.TCut("1") cmd = "%s>>%s"%(plot.variable, hs.GetName()) s.tree.Draw(cmd, cut * sel, "goff") # print the yield +/- stat error stat_error = r.Double(0.0) integral = hs.IntegralAndError(0, -1, stat_error) print "%s: %.2f +/- %.2f"%(s.name, integral, stat_error) # add overflow pu.add_overflow_to_lastbin(hs) # add to legend leg.AddEntry(hs, s.displayname, "l") hs.SetMaximum(plot.y_range_max) hs.SetMinimum(plot.y_range_min) sig_histos.append(hs) # ratiocan.upper_pad.Update() # get the zn-per-bin values # "up" : Zn values for lower-cuts (i.e. SR includes everything to the right of the cut) # "down" : Zn values for upper-cuts (i.e. SR includes everything to the left of the cut) if 'zn' in method : sig_values[s.name]['up'], sig_values[s.name]['down'] = get_zn_per_bin(hs, totalSM) # get the total zn for this selection # and attach the the signal point significance, nbkg, nsig, rel_bkgerr = 0, 0, 0, 0 if 'zn' in method : significance, nbkg, nsig, rel_bkgerr = get_zn_for_selection(hs, totalSM) s.sig_val = significance s.n_bkg = nbkg s.n_sig = nsig s.n_bkgerr = rel_bkgerr signame = '' if 'zn' in method : signame = "Zn" print " ++ --------------------------------------- ++ " print " Significance (%s) for selection %s"%(signame, reg.displayname) print "" print " # bkg : %.2f +/- %.2f "%(nbkg, nbkg * rel_bkgerr) for sigpoint in signals : print " # %s: %.2f "%(sigpoint.displayname, sigpoint.n_sig) print " Z --> %.2f"%sigpoint.sig_val print " ++ --------------------------------------- ++ " # if method == "zn" : sys.exit() if method == "zn" or method == "fasimov" : return ### draw MC backgrounds ratiocan.upper_pad.Update() # now draw the stack without the axis stack.Draw("HIST same") ### draw signals for h_sig in sig_histos : h_sig.Draw("same") ratiocan.canvas.Update() leg.Draw() ratiocan.canvas.Update() r.gPad.RedrawAxis() #pu.draw_text_on_top(text=reg.tcut, size = 0.02) pu.draw_text(text="#it{ATLAS} Internal",x=0.18,y=0.83, size = 0.06) pu.draw_text(text="13 TeV, 10/fb", x=0.18,y=0.73, size = 0.06) #pu.draw_text(text="13 TeV, 10 fb^{-1}", x=0.18,y=0.8) ######################### ## now draw zn ### up sig_up_histos = [] sig_down_histos = [] for sig in signals : updown = ['up', 'down'] for dir in updown : zns = sig_values[sig.name][dir] hz = pu.th1f("h_sig_"+dir+"_" + sig.name, "", int(plot.nbins), plot.x_range_min, plot.x_range_max, "","") hz.SetMarkerStyle(20) hz.SetMarkerColor(sig.color) hz.SetMarkerSize(0.3 * hz.GetMarkerSize()) max_y = 2.5 for ibin, zn in enumerate(zns) : if zn > 2.5 : max_y = 4 elif zn > 4 : max_y = 5 hz.SetMaximum(max_y) hz.SetMinimum(0.0) for ibin, zn in enumerate(zns) : hz.SetBinContent(ibin, r.Double(zn)) if 'up' in dir : sig_up_histos.append(hz) elif 'down' in dir : sig_down_histos.append(hz) ratiocan.middle_pad.cd() is_first = True for hzn in sig_up_histos : if is_first : hzn.Draw("p") set_ratio_style(hzn, "mid", "") is_first = False else : hzn.Draw("same p") ratiocan.middle_pad.Update() ratiocan.lower_pad.cd() is_first = True for hzn in sig_down_histos : if is_first : hzn.Draw("p") is_first = False set_ratio_style(hzn, "low", plot.x_label) else : hzn.Draw("same p") ratiocan.lower_pad.Update() #### save outname = plot.name + ".eps" ratiocan.canvas.SaveAs(outname) out = indir + "/plots/" + outdir utils.mv_file_to_dir(outname, out, True) fullname = out + "/" + outname print "%s saved to : %s"%(outname, os.path.abspath(fullname))
def make_threebody_plots(plt, reg, sig) : # get the canvases rcan = plt.ratioCanvas rcan.canvas.cd() rcan.upper_pad.cd() if plt.isLog() : rcan.upper_pad.SetLogy(True) # draw the frame hax = r.TH1F("axes","", int(plt.nbins), plt.x_range_min, plt.x_range_max) hax.SetMinimum(plt.y_range_min) hax.SetMaximum(plt.y_range_max) hax.GetXaxis().SetTitle(plt.x_label) hax.GetXaxis().SetTitleFont(42) hax.GetXaxis().SetLabelFont(42) hax.GetXaxis().SetLabelSize(0.035) hax.GetXaxis().SetTitleSize(0.048*0.85) hax.GetXaxis().SetTitleOffset(-999) hax.GetXaxis().SetLabelOffset(-999) hax.GetYaxis().SetTitle(plt.y_label) hax.GetYaxis().SetTitleFont(42) hax.GetYaxis().SetLabelFont(42) hax.GetYaxis().SetTitleOffset(1.4) hax.GetYaxis().SetLabelOffset(0.013) hax.GetYaxis().SetLabelSize(1.2*0.035) hax.GetYaxis().SetTitleSize(0.055*0.85) hax.Draw("axis") rcan.upper_pad.Update() # legend leg = pu.default_legend(xl=0.6, yl=0.65, xh=0.97, yh=0.90) leg.SetHeader("%s"%sig.displayname) leg.SetNColumns(1) ############################################################# # get histogram for nom, 3-body (Right, Left, Mass-only) ############################################################ h_nom = get_histogram(plt, sig, reg, "nom") h_r = get_histogram(plt, sig, reg, "right") h_l = get_histogram(plt, sig, reg, "left") h_m = get_histogram(plt, sig, reg, "mass") #filetest = r.TFile.Open("/data/uclhc/uci/user/dantrim/ntuples/n0222/may23/mc/Raw/CENTRAL_387947.root") #treetest = filetest.Get("superNt") #c = r.TCanvas("c", "", 768, 768) #c.cd() #htest = r.TH1F("h","", 32, 0, 250) #cut = "(" + reg.tcut + ") * " + "eventweightNOPUPW" #cut = r.TCut(cut) #sel = r.TCut("1") #cmd = "%s>>%s"%("MDR", htest.GetName()) #treetest.Draw(cmd, cut*sel) #c.SaveAs("testing.eps") ############ # hergiw #hf = r.TFile.Open("/data/uclhc/uci/user/dantrim/ntuples/n0222/apr17/mc/Raw/CENTRAL_406010.root") hf = r.TFile.Open("/data/uclhc/uci/user/dantrim/ntuples/n0222/may23/mc/Raw/CENTRAL_406010.root") herwig_250_160_tree = hf.Get("superNt") print "blah ", reg.tcut cut = "(" + reg.tcut + ") * " + "eventweightNOPUPW" cut = r.TCut(cut) sel = r.TCut("1") hh = pu.th1f("h_herwig_" + "_" + sig.name + "_herwig", "", int(plt.nbins), plt.x_range_min, plt.x_range_max, plt.x_label, plt.y_label) hh.SetMinimum(plt.y_range_min) hh.SetMaximum(plt.y_range_max) hh.GetXaxis().SetTitleOffset(-999) hh.GetXaxis().SetLabelOffset(-999) hh.SetLineColor(r.kBlack) hh.SetLineWidth(2) hh.SetLineStyle(2) hh.SetFillStyle(0) cmd = "%s>>%s"%(plt.variable, hh.GetName()) herwig_250_160_tree.Draw(cmd, cut * sel, "goff") histos = [h_nom, h_r, h_l, h_m] # overflows for h in histos: pu.add_overflow_to_lastbin(h) # colors for h in histos : color, name = get_color_from_name(h) h.SetLineColor(color) h.SetLineWidth(2) h.SetFillStyle(0) leg.AddEntry(h, name, "l") # draw histos.append(hh) is_first = True for h in histos : if is_first : is_first = False rcan.upper_pad.cd() h.Draw("hist e") rcan.upper_pad.Update() else : rcan.upper_pad.cd() h.Draw("hist e same") rcan.upper_pad.Update() #hwerwig hh.SetLineColor(r.kRed) hh.SetFillStyle(0) hh.Draw("hist same") leg.AddEntry(hh, "Herwig++", "l") rcan.upper_pad.SetGridx(True) rcan.upper_pad.SetGridy(True) # draw the legend leg.Draw() ################################################ ## ratio ################################################ rcan.lower_pad.cd() h_den = h_nom.Clone("h_den") # y-axis yax = h_den.GetYaxis() yax.SetRangeUser(0,2) yax.SetTitle("Variation/Nominal") yax.SetTitleSize(0.14 * 0.75) yax.SetLabelSize(0.13) yax.SetLabelOffset(0.98 * 0.013) yax.SetTitleOffset(0.48) yax.SetLabelFont(42) yax.SetTitleFont(42) yax.SetNdivisions(5) # x-axis xax = h_den.GetXaxis() xax.SetTitleSize(1.0 * 0.14) xax.SetLabelSize(0.13) xax.SetLabelOffset(1.15*0.02) xax.SetTitleOffset(1.1)#0.2*2) #xax.SetTitleOffset(0.1 * xax.GetTitleOffset()) xax.SetLabelFont(42) xax.SetTitleFont(42) h_den.SetTickLength(0.06) h_den.Draw("AXIS") h_den.SetTitle(plt.x_label) # unity line pu.draw_line(plt.x_range_min, 1.0, plt.x_range_max, 1.0, color=r.kRed, style=2, width=1) # right h_rl = h_r.Clone("h_rl") h_rl.Divide(h_den) h_rl.Draw("hist e same") rcan.lower_pad.Update() # left h_ll = h_l.Clone("h_ll") h_ll.Divide(h_den) h_ll.Draw("hist e same") rcan.lower_pad.Update() # mass h_ml = h_m.Clone("h_ml") h_ml.Divide(h_den) h_ml.Draw("hist e same") rcan.lower_pad.Update() rcan.canvas.SaveAs("test_%s.eps"%plt.variable)
def make_nVtxEffPlot(plt, reg, data, bkgs): print "make_nVtxEffPlot..." if plt.variable != "nVtx": print "make_nVtxEffPlot ERROR You may only provide plots setup to plot nVtx!" print "make_nVtxEffPlot ERROR This plot is configured to plot %s" % plt.variable sys.exit() r.gStyle.SetOptStat(0000) r.gStyle.SetOptFit(0111) # get the canvas c = plt.canvas c.cd() c.SetFrameFillColor(0) c.SetFillColor(0) c.SetLeftMargin(0.14) c.SetRightMargin(0.05) c.SetBottomMargin(1.3 * c.GetBottomMargin()) c.Update() ## stack for MC with selection stack = r.THStack("stack_" + plt.name, "") ## get MC histos with region selection applied histos = [] print "make_nVtxEffPlot Getting histograms with selection applied (%s)" % reg.name for b in bkgs: print " > %s" % b.name hist_name = plt.variable h = pu.th1f( "h_" + b.treename + "_" + hist_name, "", int(plt.nbins), plt.x_range_min, plt.x_range_max, plt.x_label, plt.y_label, ) h.SetLineColor(b.color) h.SetLineColor(r.kBlack) h.SetMarkerSize(1.2 * h.GetMarkerSize()) h.SetMarkerStyle(20) h.SetLineWidth(2) h.SetLineStyle(b.line_style) h.SetFillColor(0) h.Sumw2 weight_str = "" if b.isSignal(): weight_str = "eventweightNOPUPW * susy3BodyRightPol" else: print " **** NOT APPLYING PRW TO MC ***** " weight_str = "eventweightNOPUPW" cut = "(" + reg.tcut + ") * %s *" % weight_str + str(b.scale_factor) cut = r.TCut(cut) sel = r.TCut("1") cmd = "%s>>+%s" % (plt.variable, h.GetName()) b.tree.Draw(cmd, cut * sel) pu.add_overflow_to_lastbin(h) histos.append(h) c.Update() histos = sorted(histos, key=lambda h: h.Integral(), reverse=False) for h in histos: stack.Add(h) ## stack for MC withi NO selection stack_nosel = r.THStack("stack_" + plt.name + "_nosel", "") ## get the MC histos with no selection applied histos_nosel = [] print "make_nVtxEffPlot Getting histograms with NO selection applied (%s)" % reg.name for b in bkgs: print " > %s" % b.name hist_name = plt.variable h = pu.th1f( "h_" + b.treename + "_" + hist_name + "_nosel", "", int(plt.nbins), plt.x_range_min, plt.x_range_max, plt.x_label, plt.y_label, ) h.SetLineColor(b.color) h.SetMarkerStyle(20) h.SetMarkerSize(1.2 * h.GetMarkerSize()) h.SetLineColor(r.kBlack) h.SetLineWidth(2) h.SetLineStyle(b.line_style) h.SetFillColor(0) h.Sumw2 weight_str = "" if b.isSignal(): weight_str = "eventweightNOPUPW * susy3BodyRightPol" else: print " **** NOT APPLYING PRW TO MC ***** " weight_str = "eventweightNOPUPW" # cut = "(" + reg.tcut + ") * %s *"%weight_str + str(b.scale_factor) cut = "1" cut = r.TCut(cut) sel = r.TCut("1") cmd = "%s>>+%s" % (plt.variable, h.GetName()) b.tree.Draw(cmd, cut * sel) pu.add_overflow_to_lastbin(h) histos_nosel.append(h) c.Update() histos_nosel = sorted(histos_nosel, key=lambda h: h.Integral(), reverse=False) for h in histos_nosel: stack_nosel.Add(h) ### total MC with selection totalSM = stack.GetStack().Last().Clone("totalSM") ### total MC with no selection totalSM_nosel = stack_nosel.GetStack().Last().Clone("totalSM_nosel") # c.SetMaximum(5) # c.SetMinimum(0) # c.Update() h_den = totalSM_nosel.Clone("h_den") h_num = totalSM.Clone("h_num") h_num.Divide(h_den) # axes hax = r.TH1F("axes", "", int(plt.nbins), plt.x_range_min, plt.x_range_max) hax.SetMinimum(0) hax.SetMaximum(1.2 * h_num.GetMaximum()) hax.GetXaxis().SetTitle("Number of Primary Vertices") hax.GetXaxis().SetTitleFont(42) hax.GetXaxis().SetLabelFont(42) hax.GetXaxis().SetLabelSize(0.035) hax.GetXaxis().SetTitleSize(0.048 * 0.85) hax.GetYaxis().SetTitle("%s Selection Efficiency" % reg.displayname) hax.GetYaxis().SetTitleFont(42) hax.GetYaxis().SetLabelFont(42) hax.GetYaxis().SetTitleOffset(1.4) hax.GetYaxis().SetLabelOffset(0.013) hax.GetYaxis().SetLabelSize(1.2 * 0.035) hax.GetYaxis().SetTitleSize(0.055 * 0.85) hax.Draw("axis") c.Update() h_num.Draw("p0 e same") h_num.GetXaxis().SetTitle("Number of Primary Vertices") h_num.GetXaxis().SetTitleFont(42) h_num.GetXaxis().SetLabelFont(42) h_num.GetXaxis().SetLabelSize(0.035) h_num.GetXaxis().SetTitleSize(0.048 * 0.85) h_num.GetYaxis().SetTitle("%s Selection Efficiency" % reg.displayname) h_num.GetYaxis().SetTitleFont(42) h_num.GetYaxis().SetLabelFont(42) h_num.GetYaxis().SetTitleOffset(1.35) h_num.GetYaxis().SetLabelOffset(0.013) h_num.GetYaxis().SetLabelSize(1.2 * 0.035) h_num.GetYaxis().SetTitleSize(0.055 * 0.85) c.Update() h_num.Fit("pol1") r.gStyle.SetOptFit(0111) c.Update() h_num.Draw() # ps = r.gStyle.GetListOfFunctions().FindObject("stats"); # ps.SetX1NDC(0.15); # ps.SetX2NDC(0.6); # c.Modified(); # c.Update(); r.gStyle.SetStatX(0.58) r.gStyle.SetStatY(0.85) c.Update() c.SaveAs("eff_nVtx_%s.eps" % reg.name)