Esempio n. 1
0
def test_clf_events():
    for year in 2011, 2012:
        higgs = Higgs(year, mass=125)
        analysis = Analysis(year)
        analysis.normalize(Category_Preselection)
        qcd = analysis.qcd
        for sample in (qcd, higgs):
            for category in (Category_VBF, Category_Boosted):
                yield check_sample_category, analysis, sample, category
Esempio n. 2
0
def test_samples():
    for year in 2011, 2012:
        analysis = Analysis(year)
        analysis.normalize(Category_Preselection)
        for sample in analysis.backgrounds + [analysis.higgs_125]:
            for category in (Category_VBF, Category_Boosted):
                for region in ('OS_ISOL', 'OS', 'nOS_ISOL'):
                    if not isinstance(sample, QCD):
                        yield check_partition, sample, category, region
                    yield check_events, analysis, sample, category, region
Esempio n. 3
0
def test_norm():

    ss = Analysis(
        year=2012,
        systematics=False,
        use_embedding=True,
        qcd_shape_region='SS_TRK')

    nos = Analysis(
        year=2012,
        systematics=False,
        use_embedding=True,
        qcd_shape_region='nOS')

    ss.normalize(Category_Preselection, 'TRACK')
    nos.normalize(Category_Preselection, 'TRACK')

    qcd_ss = ss.qcd.events(Category_Preselection, 'OS_TRK')
    qcd_nos = nos.qcd.events(Category_Preselection, 'OS_TRK')

    # check that nOS and SS QCD models have the same number of events
    # up to two places after the decimal
    assert_almost_equal(qcd_ss, qcd_nos, places=2)
Esempio n. 4
0
from rootpy.plotting import Hist
from mva.analysis import Analysis
from mva.categories import Category_VBF
from nose.tools import assert_equal, assert_almost_equal
try:
    from nose.tools import assert_multi_line_equal
except ImportError:
    assert_multi_line_equal = assert_equal
else:
    assert_multi_line_equal.im_class.maxDiff = None


analysis = Analysis(year=2012, systematics=True, use_embedding=True)
analysis.normalize(Category_VBF)


def test_draw():

    for sample in analysis.backgrounds:
        print sample.name

        hist = Hist(30, 0, 250)
        hist_array = hist.Clone()
        field_hist = {'mmc1_mass': hist_array}

        sample.draw_into(hist, 'mmc1_mass', Category_VBF, 'OS_TRK')
        sample.draw_array(field_hist, Category_VBF, 'OS_TRK')

        assert_almost_equal(hist.Integral(), hist_array.Integral(), places=3)

        assert_equal(sorted(hist.systematics.keys()),