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 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
else: expr = expr.format( var_info['name'], h.name, (var_info['bins'], var_info['range'][0], var_info['range'][1])) print expr tree.Draw(expr, cut, var_info['style']) h = asrootpy(ROOT.gPad.GetPrimitive(h.name)) h.xaxis.title = get_label(var_info) h.yaxis.title = 'Number of Events' if h.integral() != 0: h /= h.integral() h.SetLineWidth(2) h.yaxis.SetRangeUser(0, 0.5) if 'binlabels' in var_info.keys(): for ib, lab in enumerate(var_info['binlabels']): h.xaxis.SetBinLabel(ib + 1, lab) c = Canvas() # c.SetLogy() c.SetTopMargin(0.08) h.Draw('HIST') label = ROOT.TLatex( c.GetLeftMargin() + 0.05, 1 - c.GetTopMargin() + 0.02, '{0}H #rightarrow #tau#tau (m_{{H}} = {1} GeV) - Hist Integral = {2}'.format( get_dir_mode(d), get_dir_mass(d), h.Integral())) label.SetNDC() label.SetTextSize(20) label.Draw('same') c.SaveAs('./plots/{0}_mass{1}_mode{2}.png'.format( key, get_dir_mass(d), get_dir_mode(d)))