Exemple #1
0
    # Plots
    for var, histos in variables.iteritems():
        histos = histos[0]          # drop metadata
        fig = Figure()              # one figure per variable
        canvas = FigureCanvasPdf(fig)
        axes = fig.add_subplot(111) # row, col, id (121+j, when plotting both)
        axes.grid(axis='y')
        if title:
            if bkgeff:
                axes.set_title('Background rejection efficiency')
            else:
                axes.set_title('Signal selection efficiency')
        axes.set_ylim(0, 3.5)
        axes.set_ylabel('Efficiency (w/ offset)')
        axes.set_xlim(*variables[var][1])
        axes.set_xlabel(variables[var][2])
        axes.xaxis.set_label_coords(0.9,-0.05)
        for k, cut in enumerate(mva_cuts):
            if not histos[k].GetEntries(): continue
            x, y, yerr = th12errorbar(histos[k], yerr=True, asym=True)
            axes.errorbar(x, y, yerr=yerr, xerr=None, fmt='none',
                          label='{}>{}'.format(classifier, cut))
        axes.legend(fontsize=10, numpoints=1, frameon=False, ncol=ncuts,
                    handler_map={mpl.lines.Line2D: HandlerErrorbar()})

        if doprint: pp.savefig(fig) # pp.savefig() for current fig

    if doprint: pp.close()

Exemple #2
0
axes = fig.add_subplot(111)
if options.title:
    if eff and sgf:
        axes.set_title('Efficiency & significance')
    else:
        axes.set_title('Efficiency' if eff else 'Significance')
axes.grid()
axes.set_xlabel(cltitle[classifier])
axes.set_xlim(clrange[0], clrange[1])
axes.set_ylabel('Sig. sel./Bkg. rej. efficiency' if eff else 'Significance')
if eff and sgf:
    axes2 = axes.twinx()
    axes2.set_ylabel('Significance')

for hist in [hist_s, hist_b]:
    x, y, yerr = th12errorbar(hist, yerr=True)
    col = 'blue' if 'Signal' in hist.GetTitle() else 'red'
    axes.errorbar(x, y, yerr=yerr, xerr=None, fmt='none', ecolor=col,
                  label=hist.GetTitle())
axes.legend(fontsize=10, numpoints=1, frameon=False, ncol=2,  # sig & bkg
            handler_map={mpl.lines.Line2D: HandlerErrorbar()})

if sgf:
    x, y, yerr = th12errorbar(hsigma, yerr=True)
    axes2.errorbar(x, y, yerr=yerr, xerr=None, fmt='none', ecolor='black',
                   label=hist.GetTitle())

# annotations
if classifier == 'BDTGResponse_1':
    axes.plot([0.3, 0.3], [0, 1], color='black', linewidth=2)
    axes.text(0.35, 0.3, 'Old working pt ($\geq 0.3$)',
Exemple #3
0
axes = fig.add_subplot(111)
if options.title:
    if eff and sgf:
        axes.set_title('Efficiency & significance')
    else:
        axes.set_title('Efficiency' if eff else 'Significance')
axes.grid()
axes.set_xlabel(cltitle[classifier])
axes.set_xlim(clrange[0], clrange[1])
axes.set_ylabel('Sig. sel./Bkg. rej. efficiency' if eff else 'Significance')
if eff and sgf:
    axes2 = axes.twinx()
    axes2.set_ylabel('Significance')

for hist in [hist_s, hist_b]:
    x, y, yerr = th12errorbar(hist, yerr=True)
    col = 'blue' if 'Signal' in hist.GetTitle() else 'red'
    axes.errorbar(x,
                  y,
                  yerr=yerr,
                  xerr=None,
                  fmt='none',
                  ecolor=col,
                  label=hist.GetTitle())
axes.legend(
    fontsize=10,
    numpoints=1,
    frameon=False,
    ncol=2,  # sig & bkg
    handler_map={mpl.lines.Line2D: HandlerErrorbar()})