Ejemplo n.º 1
0
def efficiency_uncertainty(sample, selection, prong, category):

    category = category.replace(
            'tau_numberOfVertices', 'number_of_good_vertices')

    #total = sample.events(Cut('trueTau1_nProng==%d' % prong) & category)
    total = sample.events(Cut('tau1_numTrack==%d' % prong) & category)

    passing_high = 0.
    passing_low = 0.
    cut = Cut('tau1_numTrack==%d' % prong) & category
    for weight, event in sample.iter(cut):
        pt = event.tau1_fourvect.Pt()
        high_score, low_score = uncertainty(
                event.tau1_BDTJetScore,
                pt,
                event.tau1_numTrack,
                event.number_of_good_vertices)
        selection_cut = selection.Eval(pt)
        if high_score > selection_cut:
            passing_high += weight
        if low_score > selection_cut:
            passing_low += weight
    return passing_high / total, passing_low / total
Ejemplo n.º 2
0
import numpy as np
from matplotlib import pyplot as plt
from tauid_uncertainty import efficiency, efficiency_uncertainty

pt = 40000

for prong in tauid.PRONGS:
    loose = selection('loose', prong, 3).Eval(pt)
    medium = selection('medium', prong, 3).Eval(pt)
    tight = selection('tight', prong, 3).Eval(pt)
    scores = np.linspace(0.5, 1., 1000, endpoint=True)
    high = []
    low = []
    for score in scores:
        high_score, low_score = tauid.uncertainty(score, pt, prong, 3)
        high.append(high_score - score)
        low.append(low_score - score)
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.fill_between(scores, low, high, facecolor='yellow', linewidth=0)
    ax.vlines([loose, medium, tight], [-.5, -.5, -.5], [.5, .5, .5],
              color='k',
              linestyles='--')
    ax.axhline(0., 0., 1.)
    ax.set_xlim(scores[0], scores[-1])
    ax.set_ylim(min(low) * 1.2, max(high) * 1.2)

    # working point labels
    for wp, loc in (('loose', loose), ('medium', medium), ('tight', tight)):
        plt.text(loc + 0.005,
Ejemplo n.º 3
0
import numpy as np
from matplotlib import pyplot as plt
from tauid_uncertainty import efficiency, efficiency_uncertainty


pt = 40000

for prong in tauid.PRONGS:
    loose = selection('loose', prong, 3).Eval(pt)
    medium = selection('medium', prong, 3).Eval(pt)
    tight = selection('tight', prong, 3).Eval(pt)
    scores = np.linspace(0.5, 1., 1000, endpoint=True)
    high = []
    low = []
    for score in scores:
        high_score, low_score = tauid.uncertainty(score, pt, prong, 3)
        high.append(high_score - score)
        low.append(low_score - score)
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.fill_between(scores, low, high, facecolor='yellow', linewidth=0)
    ax.vlines([loose, medium, tight], [-.5, -.5, -.5], [.5, .5, .5], color='k',
            linestyles='--')
    ax.axhline(0., 0., 1.)
    ax.set_xlim(scores[0], scores[-1])
    ax.set_ylim(min(low)*1.2, max(high)*1.2)

    # working point labels
    for wp, loc in (('loose', loose), ('medium', medium), ('tight', tight)):
        plt.text(loc+0.005, ax.get_ylim()[1] / 2., wp,
            ha='left', va='center', color='black', rotation=90)