Beispiel #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
Beispiel #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
Beispiel #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)
Beispiel #4
0
from mva.samples import Higgs
from mva.analysis import Analysis
from mva.categories import Category_VBF
from rootpy.plotting import Hist, Canvas
from rootpy.plotting.utils import draw

ana = Analysis(2012)
clf = ana.get_clf(Category_VBF, load=True)
h = Higgs(2012, mode='gg', systematics=True)
sample = h.get_histfactory_sample(Hist(clf.binning(2012),
                                       color='red',
                                       fillstyle='hollow',
                                       drawstyle='hist',
                                       linewidth=2),
                                  clf,
                                  Category_VBF,
                                  'OS_ISOL',
                                  systematics=True,
                                  mva=True)
hsys = sample.GetHistoSys('QCDscale_ggH3in')

nom = sample.hist.Clone(shallow=True,
                        drawstyle='hist',
                        color='red',
                        fillstyle='hollow',
                        linewidth=2)
up = hsys.high.Clone(shallow=True,
                     drawstyle='hist',
                     color='red',
                     linestyle='dashed',
                     fillstyle='hollow',
Beispiel #5
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()),
Beispiel #6
0
from mva.samples import Higgs
from mva.analysis import Analysis
from mva.categories import Category_VBF
from rootpy.plotting import Hist, Canvas
from rootpy.plotting.utils import draw

ana = Analysis(2012)
clf = ana.get_clf(Category_VBF, load=True)
h = Higgs(2012, mode='gg', systematics=True)
sample = h.get_histfactory_sample(
    Hist(clf.binning(2012), color='red',
         fillstyle='hollow', drawstyle='hist',
         linewidth=2),
    clf, Category_VBF, 'OS_ISOL',
    systematics=True, mva=True)
hsys = sample.GetHistoSys('QCDscale_ggH3in')

nom = sample.hist.Clone(shallow=True, drawstyle='hist', color='red', fillstyle='hollow', linewidth=2)
up = hsys.high.Clone(shallow=True, drawstyle='hist', color='red', linestyle='dashed', fillstyle='hollow', linewidth=2)
dn = hsys.low.Clone(shallow=True, drawstyle='hist', color='red', linestyle='dotted', fillstyle='hollow', linewidth=2)

canvas = Canvas()
draw([nom, up, dn])
canvas.SaveAs('test_ggH3in.png')