Exemple #1
0
    # var : [histograms, var-range, matplotlib title, ROOT title]
    'time': [[], (0, 15), 'time [ps]', 'time [ps]'],
    'terr': [[], (0, 0.12), 'time error ($\delta t$) [ps]', 'time error (#delta t) [ps]'],
    'lab0_MM': [[], (4700, 5700), r'$B_{s}$ mass [MeV]', 'B_{s} mass [MeV]']
}


## make efficiency histograms
from ROOT import TH1D, TCanvas
tmp = TCanvas('c', '', 400, 400)          # temporary canvas
from utils import scan_range, make_varefffn, colours
from rplot.utils import th1offset
for var in variables:
    htemp = TH1D('htemp', '', 100, *variables[var][1])
    # iterates over mva_cuts, returns list of efficiency histograms
    variables[var][0] = scan_range(make_varefffn(htemp, refcut),
                                   mva_cuts, classifier, tree, var)
    del htemp

    # aesthetics
    for j in xrange(len(mva_cuts)):
        heff = variables[var][0][j]
        if j > 0: th1offset(heff, j)
        heff.SetYTitle('Efficiency (w/ offset)')
        heff.SetXTitle(variables[var][3])
        heff.SetLineColor(colours(j))
        heff.SetMarkerColor(colours(j))
        heff.SetMarkerSize(0.2)
        heff.SetMaximum(3.5)
        heff.SetMinimum(0)
        heff.SetStats(False)
del tmp
Exemple #2
0
    nevts_passed += [
        lambda tree, cut: tree.GetEntries('{}&&{}'.format(region1, cut.ge)),
        lambda tree, cut: tree.GetEntries('{}&&{}'.format(region2, cut.ge)),
        lambda tree, cut: tree.GetEntries('{}&&{}'.format(region3, cut.ge))
    ]

from numpy import linspace, array, isnan
if classifier == 'BDTB':
    clrange = (-0.3, 0.3)
else:
    clrange = (-1.0, 1.0)
cuts = linspace(clrange[0], clrange[1], 101)

# significance, signal selection and background rejection efficiency
from utils import scan_range
res = array(scan_range(nevts_passed, cuts, classifier, tree))

# NOTE: filter runtime warning due to NaNs.  These entries are
# filtered away before filling the histograms.  They occur due to 0
# efficiency for very large classifier cuts.
import warnings
warnings.filterwarnings(action='ignore', category=RuntimeWarning,
                        message='invalid value encountered in divide.*')

from math import sqrt
if istmva:
    if eff:
        # sel_s/tot_s, 1-sel_b/tot_s
        effs = array([0, 1]) + res / array([nsig, -nbkg])
        eff_s, eff_b = effs[:, 0], effs[:, 1]
Exemple #3
0
    nevts_passed += [
        lambda tree, cut: tree.GetEntries('{}&&{}'.format(region1, cut.ge)),
        lambda tree, cut: tree.GetEntries('{}&&{}'.format(region2, cut.ge)),
        lambda tree, cut: tree.GetEntries('{}&&{}'.format(region3, cut.ge))
    ]

from numpy import linspace, array, isnan
if classifier == 'BDTB':
    clrange = (-0.3, 0.3)
else:
    clrange = (-1.0, 1.0)
cuts = linspace(clrange[0], clrange[1], 101)

# significance, signal selection and background rejection efficiency
from utils import scan_range
res = array(scan_range(nevts_passed, cuts, classifier, tree))

# NOTE: filter runtime warning due to NaNs.  These entries are
# filtered away before filling the histograms.  They occur due to 0
# efficiency for very large classifier cuts.
import warnings
warnings.filterwarnings(action='ignore',
                        category=RuntimeWarning,
                        message='invalid value encountered in divide.*')

from math import sqrt
if istmva:
    if eff:
        # sel_s/tot_s, 1-sel_b/tot_s
        effs = array([0, 1]) + res / array([nsig, -nbkg])
        eff_s, eff_b = effs[:, 0], effs[:, 1]