def draw_hists(hists, field, category, textsize=22, logy=False, unit_area=False): xtitle = get_xtitle(field) c = Canvas() c.SetGridx() c.SetGridy() c.SetLogy(logy) if not isinstance(hists, (list, tuple)): hists = [hists] if unit_area: for h in hists: if h.integral() != 0: h /= h.integral() hists[0].xaxis.title = xtitle hists[0].yaxis.title = 'Arbitrary Unit' y_max = get_ymax(hists) hists[0].yaxis.SetRangeUser(0., 1.05 * y_max) hists[0].Draw('HIST') colors = [ 'black', 'red', 'orange', 'blue', 'green', 'purple', 'yellow', 'pink', ] if len(hists) > len(colors): colors = len(hists) * colors for hist, col in zip(hists, colors): hist.color = col hist.color = col hist.fillstyle = 'hollow' hist.markersize = 0 hist.linewidth = 2 hist.linestyle = 'solid' hist.drawstyle = 'hist E0' hist.legendstyle = 'l' hist.Draw('SAMEHIST') label = ROOT.TLatex(c.GetLeftMargin() + 0.04, 0.9, category.label) label.SetNDC() label.SetTextFont(43) label.SetTextSize(textsize) label.Draw() leg = Legend(hists, pad=c, textsize=20) # textsize=20, leftmargin=0.6, topmargin=0.6) leg.Draw('same') return c
def draw_efficiency(eff_s, rej_b, field, category, textsize=22): xtitle = get_xtitle(field) c = Canvas() c.SetGridx() c.SetGridy() eff_s.painted_graph.yaxis.SetRangeUser(0, 1.10) eff_s.painted_graph.yaxis.title = 'Efficiency' eff_s.painted_graph.xaxis.title = xtitle eff_s.painted_graph.Draw('AP') rej_b.color = 'red' rej_b.markerstyle = 'square' rej_b.painted_graph.Draw('sameP') right_axis = ROOT.TGaxis(ROOT.gPad.GetUxmax(), ROOT.gPad.GetUymin(), ROOT.gPad.GetUxmax(), ROOT.gPad.GetUymax(), 0, 1.10, 510, "+L") right_axis.SetLineColor(ROOT.kRed) right_axis.SetLabelColor(ROOT.kRed) right_axis.SetTextColor(ROOT.kRed) right_axis.SetTitle('Rejection = 1 - #epsilon_{B}') right_axis.Draw('same') ROOT.gStyle.SetPadTickY(0) ROOT.gPad.Update() ROOT.gStyle.SetPadTickY(1) label = ROOT.TLatex(c.GetLeftMargin() + 0.04, 0.9, category.label) label.SetNDC() label.SetTextFont(43) label.SetTextSize(textsize) label.Draw() leg = Legend([eff_s, rej_b], pad=c) # textsize=20, leftmargin=0.6, topmargin=0.6) leg.Draw('same') return c
def __prepare_canvas(canvas_args): style = gStyle style.SetOptStat(0) canvas = Canvas(**canvas_args) canvas.SetGridx(True) canvas.SetGridy(True) canvas.title = "" return canvas, style
def draw_efficiencies(effs, field, category, textsize=22): xtitle = get_xtitle(field) c = Canvas() c.SetGridx() c.SetGridy() if not isinstance(effs, (list, tuple)): effs = [effs] h = Hist(10, effs[0].painted_graph.xaxis.min, effs[0].painted_graph.xaxis.max) h.yaxis.SetRangeUser(0.0, 1.1) h.Draw('HIST') h.yaxis.title = 'Efficiency' h.xaxis.title = xtitle colors = [ 'black', 'red', 'orange', 'blue', 'green', 'purple', 'yellow', 'pink', ] if len(effs) > len(colors): colors = len(effs) * colors for eff, col in zip(effs, colors): eff.color = col eff.color = col eff.painted_graph.legendstyle = 'l' eff.painted_graph.Draw('SAMEP') label = ROOT.TLatex(c.GetLeftMargin() + 0.04, 0.9, category.label) label.SetNDC() label.SetTextFont(43) label.SetTextSize(textsize) label.Draw() leg = Legend(effs, pad=c, textsize=20) # textsize=20, leftmargin=0.6, topmargin=0.6) leg.Draw('same') return c