Esempio n. 1
0
        print 'High MT W+jets estimated yield', yield_estimation
        print 'High MT W+jets MC yield', yield_w_highmt_os

        w_sf = yield_estimation / yield_w_highmt_os

        print 'W+jets scale factor:', w_sf, '\n'

        wjets.total_scale = w_sf
        wjets_ss.total_scale = -w_sf

        import pdb
        pdb.set_trace()

    for variable in variables:
        cfg_main.var = variable
        if qcd_from_same_sign:
            qcd.var = variable  # Can put into function but we will not want it by default if we take normalisations from e.g. high MT
        if w_qcd_mssm_method:
            wjets.var = variable  # Can put into function but we will not want it by default if we take normalisations from e.g. high MT
            qcd.var = variable
            wjets_ss.var = variable

        if variable.name in ['svfit_mass', 'svfit_transverse_mass']:
            if cut.name in ['inclusive', 'nobtag']:
                variable.binning = binning_mssm
            elif cut.name in ['btag']:
                variable.binning = binning_mssm_btag

        plot = createHistogram(cfg_main, verbose=False)
        createDefaultGroups(plot)
Esempio n. 2
0
        if sample.name != 'Data':
            # Subtract background from data
            sample.scale = -1.

    qcd = HistogramCfg(name='QCD', var=None, cfgs=samples_ss, cut=inc_cut, lumi=40.0)

    samples.append(qcd)

# Taken from Variables.py, can get subset with e.g. getVars(['mt', 'mvis'])
variables = all_vars

cfg_example = HistogramCfg(name='example', var=None, cfgs=samples, cut=inc_cut, lumi=40.0)


for cut_name in cuts:
    cfg_example.cut = cuts[cut_name]
    if qcd_from_same_sign and 'OS' in cut_name:
        qcd.cut = cuts[cut_name].replace('l1_charge != l2_charge', 'l1_charge == l2_charge')

    for variable in variables:
        cfg_example.var = variable
        if qcd_from_same_sign:
            qcd.var = variable # Can put into function but we will not want it by default if we take normalisations from e.g. high MT
        
        plot = createHistogram(cfg_example, verbose=True)
        plot.Group('Diboson', ['ZZ', 'WZ', 'WW'])
        plot.Group('Single t', ['T_tWch', 'TBar_tWch', 'TToLeptons_sch', 'TToLeptons_tch'])
        plot.Group('ZLL', ['Ztt_ZL', 'Ztt_ZJ'], style=plot.Hist('Ztt_ZL').style)
        HistDrawer.draw(plot, plot_dir='plots/'+cut_name)

Esempio n. 3
0
        name='loose_data',
        var=None,
        cfgs=samples,
        cut=inc_cut,
        lumi=int_lumi,
        weight=total_weight + ' * ((genmet_pt < 0.) - (l2_gen_match == 5))')

    cfg_tight.cut = cuts[cut_name]
    cfg_loose.cut = cuts[cut_name].replace(
        'l2_byCombinedIsolationDeltaBetaCorrRaw3Hits<1.5', '1.')
    cfg_data_tight.cut = cuts[cut_name]
    cfg_data_loose.cut = cuts[cut_name].replace(
        'l2_byCombinedIsolationDeltaBetaCorrRaw3Hits<1.5', '1.')

    for variable in variables:
        cfg_tight.var = variable
        cfg_loose.var = variable
        cfg_data_tight.var = variable
        cfg_data_loose.var = variable

        plot_tight = createHistogram(cfg_tight, verbose=False)
        plot_loose = createHistogram(cfg_loose, verbose=False)
        plot_data_tight = createHistogram(cfg_data_tight,
                                          verbose=False,
                                          all_stack=True)
        plot_data_loose = createHistogram(cfg_data_loose,
                                          verbose=False,
                                          all_stack=True)
        for plot in [plot_tight, plot_loose, plot_data_tight, plot_data_loose]:
            plot.Group('VV', ['ZZ', 'WZ', 'WW', 'T_tWch', 'TBar_tWch'])
            out_dir = 'fakeplots/' + cut_name if plot is plot_tight else 'fakeplots/loose' + cut_name
                                   var=None,
                                   cfgs=samples_qcdfromss,
                                   cut=inc_cut,
                                   lumi=int_lumi,
                                   weight=total_weight)
    else:
        cfg_example = HistogramCfg(name='example',
                                   var=None,
                                   cfgs=samples,
                                   cut=inc_cut,
                                   lumi=int_lumi,
                                   weight=total_weight)

    cfg_example.cut = cuts[cut_name]
    if qcd_from_same_sign and not 'SS' in cut_name:
        qcd.cut = cuts[cut_name].replace('l1_charge != l2_charge',
                                         'l1_charge == l2_charge')

    for variable in variables:
        cfg_example.var = variable
        if qcd_from_same_sign:
            qcd.var = variable  # Can put into function but we will not want it by default if we take normalisations from e.g. high MT

        plot = createHistogram(cfg_example, verbose=True)
        plot.Group('VV', ['ZZ', 'WZ', 'WW', 'T_tWch', 'TBar_tWch'])
        # plot.Group('Single t', ['T_tWch', 'TBar_tWch', 'TToLeptons_sch', 'TToLeptons_tch'])
        # plot.Group('ZLL', ['Ztt_ZL', 'Ztt_ZJ'], style=plot.Hist('Ztt_ZL').style)
        HistDrawer.draw(plot, plot_dir='plots/RemoveLowMET_' + cut_name)

        plot.WriteDataCard(filename='datacard_mvis.root', dir='mt_' + cut_name)
Esempio n. 5
0
    SampleCfg(name='WJetsToLNu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WJetsToLNu.xSection, sumweights=WJetsToLNu.nGenEvents),
    SampleCfg(name='TTJets', dir_name='TTLep_pow', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TT_pow.xSection, sumweights=TT_pow.nGenEvents),
    SampleCfg(name='T_tWch', dir_name='T_tWch', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=T_tWch.xSection, sumweights=T_tWch.nGenEvents),
    SampleCfg(name='TBar_tWch', dir_name='TBar_tWch', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TBar_tWch.xSection, sumweights=TBar_tWch.nGenEvents),
    SampleCfg(name='TToLeptons_tch', dir_name='TToLeptons_tch', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TToLeptons_tch.xSection, sumweights=TBar_tWch.nGenEvents),
    SampleCfg(name='TToLeptons_sch', dir_name='TToLeptons_sch', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=TToLeptons_sch.xSection, sumweights=TToLeptons_sch.nGenEvents),
    SampleCfg(name='ZZ', dir_name='ZZp8', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=ZZp8.xSection, sumweights=ZZp8.nGenEvents),
    SampleCfg(name='WZ', dir_name='WZp8', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WZp8.xSection, sumweights=WZp8.nGenEvents),
    SampleCfg(name='WW', dir_name='WWTo2L2Nu', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=WWTo2L2Nu.xSection, sumweights=WWTo2L2Nu.nGenEvents),
    SampleCfg(name='QCD', dir_name='QCD_Mu15', ana_dir=analysis_dir, tree_prod_name=tree_prod_name, xsec=QCD_Mu15.xSection),
    SampleCfg(name='Data', dir_name='SingleMuon_Run2015B', ana_dir=data_dir, tree_prod_name=tree_prod_name, is_data=True),
]
# -> Can add cross sections for samples either explicitly, or from file, or from cfg

for sample in samples:
    setSumWeights(sample)

# Taken from Variables.py, can get subset with e.g. getVars(['mt', 'mvis'])
variables = all_vars

cfg_example = HistogramCfg(name='example', var=None, cfgs=samples, cut=example_cut, lumi=40.0)

for variable in variables:
    cfg_example.var = variable
    plot = createHistogram(cfg_example)
    plot.Group('Diboson', ['ZZ', 'WZ', 'WW'])
    plot.Group('Single t', ['T_tWch', 'TBar_tWch', 'TToLeptons_sch', 'TToLeptons_tch'])
    HistDrawer.draw(plot)
    # HistDrawer.drawRatio(plot)

Esempio n. 6
0
                      cut=inc_cut,
                      lumi=int_lumi,
                      weight='1.')

for var_set in var_sets:
    print 'Variable set', var_set.name

    cfg_signal.cut += var_set.cut_s
    cfg_bg.cut += var_set.cut_b

    rocs = []
    sig_eff = None
    bg_eff = None
    for i_var, var in enumerate(var_set.vars):
        print '  variable:', var
        cfg_signal.var = var
        cfg_bg.var = var

        plot_signal = createHistogram(cfg_signal, verbose=False)
        plot_bg = createHistogram(cfg_bg, verbose=False)

        h_signal = plot_signal.GetStack().totalHist.weighted
        h_bg = plot_bg.GetStack().totalHist.weighted

        print 'Working point at cut 1.5:'

        if not sig_eff and not bg_eff:
            sig_eff = h_signal.Integral(
                0, h_signal.FindBin(1.5)) / h_signal.Integral(
                    0,
                    h_signal.GetNbinsX() + 1)