def createVariables(mode):
    # Taken from Variables.py; can get subset with e.g. getVars(['mt', 'mvis'])
    # variables = taumu_vars
    # variables = getVars(['_norm_', 'mt', 'mvis', 'l1_pt', 'l2_pt', 'l1_eta', 'l2_eta', 'n_vertices', 'n_jets', 'n_bjets'])

    variables = []
    if mode in ['sm', 'pog']:
        # MVA training variables, and others
        variables += getVars(['mt', 'l2_mt', 'n_jets', 'met_pt', 'pthiggs', 'l2_pt', 'l1_pt','mvis', 'l1_eta', 'l2_eta', 'pzeta_disc', 'jet1_pt', 'jet1_eta', 'n_vertices', 'rho', 'dil_pt', 'l2_byIsolationMVArun2v1DBoldDMwLTraw', 'l2_byCombinedIsolationDeltaBetaCorrRaw3Hits', 'l2_byIsolationMVArun2v1DBoldDMwLTraw_zoom',
            'l2_nc_ratio', 'l2_pt_weighted_dr_iso', 'l2_pt_weighted_dr_signal', 'l2_pt_weighted_dphi_strip', 'l2_pt_weighted_deta_strip', 'l2_flightLength', 'l2_flightLengthSig', 'l2_dxy_Sig', 'l2_ip3d', 'l2_ip3d_Sig', 'l2_e_over_h', 'l2_n_photons', ])#  'svfit_transverse_mass',  'delta_phi_l1_l2', 'delta_eta_l1_l2', 'pt_l1l2', 'delta_phi_j1_met',

        # variables = taumu_vars

    if mode == 'cp':
        variables = getVars(['l2_nc_ratio'])

    if mode == 'mssm_signal':
        variables = [
            VariableCfg(name='svfit_transverse_mass', binning=binning_mssm, unit='GeV', xtitle='m_{T,SVFit}'),
            VariableCfg(name='svfit_mass', binning=binning_mssm, unit='GeV', xtitle='m_{SVFit}'),
            VariableCfg(name='mvis', binning=binning_mssm, unit='GeV', xtitle='m_{vis}'),
        ]

    if mode == 'iso':
        variables = getVars(['mt', 'l1_pt', 'l2_pt', 'l1_eta', 'l2_eta'])

    return variables
def getVariables(mode):
    # Taken from Variables.py, can get subset with e.g. getVars(['mt', 'mvis'])
    # variables = tautau_vars
    if mode == 'control':
        variables = getVars([
            '_norm_', 'mvis', 'mt2', 'l1_pt', 'l2_pt', 'delta_phi_l1_l2',
            'delta_eta_l1_l2', 'met_pt', 'mt_total', 'mt_total_mssm', 'mt_sum',
            'pzeta_met', 'l2_mt', 'mt', 'pzeta_vis', 'pzeta_disc', 'pthiggs',
            'jet1_pt', 'n_jets', 'dil_pt',
            'l1_byCombinedIsolationDeltaBetaCorrRaw3Hits',
            'l1_byIsolationMVArun2v1DBoldDMwLTraw', 'l1_dz_sig', 'l1_log_dz',
            'l1_dxy_sig', 'l1_log_dxy', 'l1_decayMode', 'l1_chargedIsoPtSum',
            'l1_neutralIsoPtSum', 'l1_puCorrPtSum',
            'l1_photonPtSumOutsideSignalCone', 'l1_zImpact', 'l1_jet_charge',
            'l1_jet_pt_div_l1_pt'
        ],
                            channel='tautau')
    if mode == 'mssm':
        variables = getVars([
            'mt_total', 'mt_total_mssm', 'mt_total_mssm_fine', 'mvis_extended',
            'l1_pt', 'dil_pt'
        ],
                            channel='tautau')
    # variables += [
    #     VariableCfg(name='mt2', binning={'nbinsx':15, 'xmin':0., 'xmax':150.}, unit='GeV', xtitle='m_{T2}')
    # ]
    if mode == 'mva':
        variables += getVars(['_norm_'])
        variables += [
            VariableCfg(name='mva1',
                        binning={
                            'nbinsx': 10,
                            'xmin': 0.,
                            'xmax': 1.
                        },
                        unit='',
                        xtitle='Stau MVA')
        ]

    if mode == 'susy':
        variables = getVars([
            'l1_pt', '_norm_', 'l2_pt', 'mt2', 'mt', 'mt_leg2',
            'mt_total_mssm', 'min_delta_phi_tau1tau2_met'
        ],
                            channel='tautau')

    return variables
Beispiel #3
0
samples_mc, samples_data, samples, all_samples, sampleDict = createSampleLists(
    analysis_dir=analysis_dir)

samples_mc_w = [s for s in samples_mc if fnmatch.fnmatch(s.name, 'W*Jet*')]
samples_mc_tt = [s for s in samples_mc if fnmatch.fnmatch(s.name, 'TT*')]

samples = samples_mc_w + samples_mc_tt

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

variables += [
    VariableCfg(name='l2_jet_pt',
                binning=array(
                    [20., 30., 40., 50., 60., 70., 80., 90., 100., 150.,
                     200.]),
                unit='GeV',
                xtitle='tau jet p_{T}'),
    VariableCfg(name='l2_pt',
                binning=array(
                    [20., 25., 30., 35., 40., 50., 60., 80., 120., 200.]),
                unit='GeV',
                xtitle='tau p_{T}'),
    VariableCfg(name='l2_jet_pt_div_l2_pt',
                drawname='l2_jet_pt/l2_pt',
                binning=array(
                    [0., 0.5, 0.8, 1.0, 1.1, 1.2, 1.5, 2.0, 3.0, 4.0]),
                unit=None,
                xtitle='tau p_{T}'),
]
def createVariables(mode):
    # Taken from Variables.py; can get subset with e.g. getVars(['mt', 'mvis'])
    # variables = taumu_vars
    # variables = getVars(['_norm_', 'mt', 'mvis', 'l1_pt', 'l2_pt', 'l1_eta', 'l2_eta', 'n_vertices', 'n_jets', 'n_bjets'])

    variables = []
    if mode == 'sm':
        variables = [
            # VariableCfg(name='mva', binning={'nbinsx':20, 'xmin':0., 'xmax':1.}, unit='', xtitle='s_{BDT}'),
            VariableCfg(name='svfit_mass',
                        binning={
                            'nbinsx': 20,
                            'xmin': 50.,
                            'xmax': 250
                        },
                        unit='GeV',
                        xtitle='m_{SVFit}'),
            VariableCfg(name='mva0',
                        binning={
                            'nbinsx': 20,
                            'xmin': 0.,
                            'xmax': 1.0001
                        },
                        unit='',
                        xtitle='s_{BDT} (BG)'),
            VariableCfg(name='mva1',
                        binning={
                            'nbinsx': 20,
                            'xmin': 0.,
                            'xmax': 1.0001
                        },
                        unit='',
                        xtitle='s_{BDT} (ZTT)'),
            VariableCfg(name='mva2',
                        binning=binning_mva2,
                        unit='',
                        xtitle='s_{BDT} (Higgs)'),
            # VariableCfg(name='mva2div1', drawname='mva2/(mva1+mva2)', binning={'nbinsx':20, 'xmin':0., 'xmax':1.0001}, unit='', xtitle='s_{BDT}^{Higgs}/s_{BDT}^{ZTT}'),
            VariableCfg(name='mva2div1',
                        drawname='mva2/(mva1+mva2)',
                        binning=binning_mva,
                        unit='',
                        xtitle='s_{BDT}^{Higgs}/s_{BDT}^{ZTT}'),
        ]

        # MVA training variables
        variables += getVars([
            'mt', 'n_jets', 'met_pt', 'pthiggs', 'vbf_mjj', 'vbf_deta',
            'vbf_n_central', 'l2_pt', 'l1_pt', 'svfit_transverse_mass',
            'delta_phi_l1_l2', 'delta_eta_l1_l2', 'mvis'
        ])

    if mode == 'cp':
        variables = getVars(['l2_nc_ratio'])

    if mode == 'mssm_signal':
        variables = [
            VariableCfg(name='svfit_transverse_mass',
                        binning=binning_mssm,
                        unit='GeV',
                        xtitle='m_{T,SVFit}'),
            VariableCfg(name='svfit_mass',
                        binning=binning_mssm,
                        unit='GeV',
                        xtitle='m_{SVFit}'),
            VariableCfg(name='mvis',
                        binning=binning_mssm,
                        unit='GeV',
                        xtitle='m_{vis}'),
        ]

    if mode == 'iso':
        variables = getVars(['mt', 'l1_pt', 'l2_pt', 'l1_eta', 'l2_eta'])

    return variables
def createSamples(mode, analysis_dir, total_weight, qcd_from_same_sign,
                  w_qcd_mssm_method, r_qcd_os_ss):
    hist_dict = {}
    sample_dict = {}

    samples_mc, samples_data, samples, all_samples, sampleDict = createSampleLists(
        analysis_dir=analysis_dir)

    if mode == 'mssm_control' or not 'mssm' in mode:
        all_samples = [
            s for s in all_samples
            if not 'ggH' in s.name and not 'bbH' in s.name
        ]

    sample_dict['all_samples'] = all_samples

    if qcd_from_same_sign and not w_qcd_mssm_method:
        samples_qcdfromss = [s for s in all_samples if s.name != 'QCD']
        samples_ss = copy.deepcopy(samples_qcdfromss)

        samples_ss = [s for s in samples_ss if not s.is_signal]

        for sample in samples_ss:
            if sample.name != 'data_obs':
                # Subtract background from data
                sample.scale = -1.

        qcd = HistogramCfg(name='QCD',
                           var=None,
                           cfgs=samples_ss,
                           cut=None,
                           total_scale=r_qcd_os_ss,
                           lumi=int_lumi,
                           weight=total_weight)

        samples_qcdfromss.append(qcd)
        sample_dict['samples_qcdfromss'] = samples_qcdfromss

    if w_qcd_mssm_method:
        w_names = ['W', 'W1Jets', 'W2Jets', 'W3Jets', 'W4Jets']
        samples_non_w = [
            s for s in all_samples
            if s.name != 'QCD' and s.name not in w_names and not s.is_signal
        ]
        samples_non_w_ss = copy.deepcopy(samples_non_w)

        samples_signal = [s for s in all_samples if s.is_signal]

        samples_w = copy.deepcopy(
            [s for s in all_samples if s.name in w_names])
        samples_w_ss = copy.deepcopy(samples_w)

        # To calculate OS/SS ratio in inclusive W selection
        samples_w_incl_os = copy.deepcopy(samples_w)
        samples_w_incl_ss = copy.deepcopy(samples_w)

        # To calculate W scale factor
        samples_w_highmt_os = copy.deepcopy(samples_w)

        # Build a high MT region: OS - non-W/QCD OS - (SS - non-W/QCD SS)
        samples_non_w_highmt_os = copy.deepcopy(samples_non_w)
        samples_non_w_highmt_ss = copy.deepcopy(samples_non_w)

        for sample in samples_non_w_highmt_os:
            if sample.name != 'data_obs':
                # Subtract background from data
                sample.scale = -1.

        for sample in samples_non_w_highmt_ss:
            if sample.name != 'data_obs':
                sample.scale = -1.

        for sample in samples_non_w_ss:
            if sample.name != 'data_obs':
                sample.scale = -1.

        var_norm = VariableCfg(name='_norm_',
                               drawname='1.',
                               binning={
                                   'nbinsx': 5,
                                   'xmin': -1.5,
                                   'xmax': 3.5
                               },
                               unit='',
                               xtitle='Normalisation')

        hist_dict['stacknow_highmt_os'] = HistogramCfg(
            name='HighMTOS',
            var=var_norm,
            cfgs=samples_non_w_highmt_os,
            cut=None,
            lumi=int_lumi,
            weight=total_weight)
        hist_dict['stacknow_highmt_ss'] = HistogramCfg(
            name='HighMTSS',
            var=var_norm,
            cfgs=samples_non_w_highmt_ss,
            cut=None,
            lumi=int_lumi,
            weight=total_weight)

        hist_dict['wjets_incl_os'] = HistogramCfg(name='WInclOS',
                                                  var=var_norm,
                                                  cfgs=samples_w_incl_os,
                                                  cut=None,
                                                  lumi=int_lumi,
                                                  weight=total_weight)
        hist_dict['wjets_incl_ss'] = HistogramCfg(name='WInclSS',
                                                  var=var_norm,
                                                  cfgs=samples_w_incl_ss,
                                                  cut=None,
                                                  lumi=int_lumi,
                                                  weight=total_weight)

        hist_dict['wjets_highmt_os'] = HistogramCfg(name='WHighMTOS',
                                                    var=var_norm,
                                                    cfgs=samples_w_highmt_os,
                                                    cut=None,
                                                    lumi=int_lumi,
                                                    weight=total_weight)

        hist_dict['wjets'] = HistogramCfg(name='W',
                                          var=None,
                                          cfgs=samples_w,
                                          cut=None,
                                          lumi=int_lumi,
                                          weight=total_weight)
        hist_dict['wjets_ss'] = HistogramCfg(name='WSS',
                                             var=None,
                                             cfgs=samples_w_ss,
                                             cut=None,
                                             lumi=int_lumi,
                                             weight=total_weight)

        hist_dict['qcd'] = HistogramCfg(name='QCD',
                                        var=None,
                                        cfgs=samples_non_w_ss +
                                        [hist_dict['wjets_ss']],
                                        cut=None,
                                        total_scale=r_qcd_os_ss,
                                        lumi=int_lumi,
                                        weight=total_weight)

        sample_dict['samples_mssm_method'] = samples_non_w + [
            hist_dict['wjets'], hist_dict['qcd']
        ] + samples_signal

    return sample_dict, hist_dict
Beispiel #6
0
samples_mc, samples_data, samples, all_samples, sampleDict = createSampleLists(
    analysis_dir,
    channel='mm',
    ztt_cut='(l1_gen_match == 4 && l2_gen_match == 4)',
    zl_cut='(l1_gen_match == 2 && l2_gen_match == 2)',
    zj_cut=
    '(l1_gen_match != l2_gen_match || (l1_gen_match != 4 && l1_gen_match != 2))',
    data2016G=data2016G)

# Taken from Variables.py, can get subset with e.g. getVars(['mt', 'mvis'])
# variables = mumu_vars
variables = getVars(['tau1_eta'])  #'tau1_pt',
variables += [
    VariableCfg(name='jet1_pt',
                binning=array(
                    [30., 40., 50., 60., 80., 100., 120., 160., 200., 350.]),
                unit='GeV',
                xtitle='jet p_{T}'),
    VariableCfg(name='tau1_pt',
                binning=array(
                    [30., 35., 40., 45., 50., 60., 80., 100., 140., 200.]),
                unit='GeV',
                xtitle='tau p_{T}'),
    VariableCfg(name='jet1_eta',
                binning={
                    'nbinsx': 25,
                    'xmin': -2.5,
                    'xmax': 2.5
                },
                unit='',
                xtitle='jet #eta'),
Beispiel #7
0
int_lumi = 2110.
pt1 = 19
# pt1 = 40
pt2 = 20

inc_cut = '!veto_dilepton && !veto_thirdlepton && !veto_otherlepton && l2_againstMuon3>1.5 && l2_againstElectronMVA5>0.5 && l2_pt>{pt2} && l2_decayModeFinding && l1_pt>{pt1}'.format(
    pt1=pt1, pt2=pt2)

vars_tau = [
    VariableCfg(
        name='l2_byCombinedIsolationDeltaBetaCorrRaw3Hits',
        drawname=
        'l2_byCombinedIsolationDeltaBetaCorrRaw3Hits + 100 * (l2_photonPtSumOutsideSignalCone/l2_pt>0.1)',
        binning={
            'nbinsx': 10000,
            'xmin': 0.,
            'xmax': 150.
        },
        unit='GeV',
        xtitle='db corr. 3-hit iso'),
    VariableCfg(
        name='l2_byPileupWeightedIsolationRaw3Hits',
        drawname=
        'l2_byPileupWeightedIsolationRaw3Hits + 100 * (l2_photonPtSumOutsideSignalCone/l2_pt>0.1)',
        binning={
            'nbinsx': 10000,
            'xmin': 0.,
            'xmax': 150.
        },
        unit='GeV',
Beispiel #8
0
            # Subtract background from data
            sample.scale = -1.

    for sample in samples_non_w_highmt_ss:
        if sample.name != 'data_obs':
            sample.scale = -1.

    for sample in samples_non_w_ss:
        if sample.name != 'data_obs':
            sample.scale = -1.

    var_norm = VariableCfg(name='_norm_',
                           drawname='1.',
                           binning={
                               'nbinsx': 5,
                               'xmin': -1.5,
                               'xmax': 3.5
                           },
                           unit='',
                           xtitle='Normalisation')

    stacknow_highmt_os = HistogramCfg(name='HighMTOS',
                                      var=var_norm,
                                      cfgs=samples_non_w_highmt_os,
                                      cut=inc_cut,
                                      lumi=int_lumi,
                                      weight=total_weight)
    stacknow_highmt_ss = HistogramCfg(name='HighMTSS',
                                      var=var_norm,
                                      cfgs=samples_non_w_highmt_ss,
                                      cut=inc_cut,
def createQCDWHistograms(samples,
                         hist_dict,
                         int_lumi,
                         weight,
                         r_qcd_os_ss=1.17):
    w_names = ['W', 'W1Jets', 'W2Jets', 'W3Jets', 'W4Jets']
    samples_non_w = [
        s for s in samples
        if s.name != 'QCD' and s.name not in w_names and not s.is_signal
    ]
    samples_non_w_ss = deepcopy(samples_non_w)

    samples_signal = [s for s in samples if s.is_signal]

    samples_w = deepcopy([s for s in samples if s.name in w_names])
    samples_w_ss = deepcopy(samples_w)

    # To calculate OS/SS ratio in inclusive W selection
    samples_w_incl_os = deepcopy(samples_w)
    samples_w_incl_ss = deepcopy(samples_w)

    # To calculate W scale factor
    samples_w_highmt_os = deepcopy(samples_w)

    # Build a high MT region: OS - non-W/QCD OS - (SS - non-W/QCD SS)
    samples_non_w_highmt_os = deepcopy(samples_non_w)
    samples_non_w_highmt_ss = deepcopy(samples_non_w)

    for sample in samples_non_w_highmt_os:
        if sample.name != 'data_obs':
            # Subtract background from data
            sample.scale = -1.

    for sample in samples_non_w_highmt_ss:
        if sample.name != 'data_obs':
            sample.scale = -1.

    for sample in samples_non_w_ss:
        if sample.name != 'data_obs':
            sample.scale = -1.

    var_norm = VariableCfg(name='_norm_',
                           drawname='1.',
                           binning={
                               'nbinsx': 5,
                               'xmin': -1.5,
                               'xmax': 3.5
                           },
                           unit='',
                           xtitle='Normalisation')

    hist_dict['stacknow_highmt_os'] = HistogramCfg(
        name='HighMTOS',
        var=var_norm,
        cfgs=samples_non_w_highmt_os,
        cut=None,
        lumi=int_lumi,
        weight=weight)
    hist_dict['stacknow_highmt_ss'] = HistogramCfg(
        name='HighMTSS',
        var=var_norm,
        cfgs=samples_non_w_highmt_ss,
        cut=None,
        lumi=int_lumi,
        weight=weight)

    hist_dict['wjets_incl_os'] = HistogramCfg(name='WInclOS',
                                              var=var_norm,
                                              cfgs=samples_w_incl_os,
                                              cut=None,
                                              lumi=int_lumi,
                                              weight=weight)
    hist_dict['wjets_incl_ss'] = HistogramCfg(name='WInclSS',
                                              var=var_norm,
                                              cfgs=samples_w_incl_ss,
                                              cut=None,
                                              lumi=int_lumi,
                                              weight=weight)

    hist_dict['wjets_highmt_os'] = HistogramCfg(name='WHighMTOS',
                                                var=var_norm,
                                                cfgs=samples_w_highmt_os,
                                                cut=None,
                                                lumi=int_lumi,
                                                weight=weight)

    hist_dict['wjets'] = HistogramCfg(name='W',
                                      var=None,
                                      cfgs=samples_w,
                                      cut=None,
                                      lumi=int_lumi,
                                      weight=weight)
    hist_dict['wjets_ss'] = HistogramCfg(name='WSS',
                                         var=None,
                                         cfgs=samples_w_ss,
                                         cut=None,
                                         lumi=int_lumi,
                                         weight=weight)

    hist_dict['qcd'] = HistogramCfg(name='QCD',
                                    var=None,
                                    cfgs=samples_non_w_ss +
                                    [hist_dict['wjets_ss']],
                                    cut=None,
                                    total_scale=r_qcd_os_ss,
                                    lumi=int_lumi,
                                    weight=weight)

    return samples_non_w + [hist_dict['wjets'], hist_dict['qcd']
                            ] + samples_signal
Beispiel #10
0
    qcd = HistogramCfg(name='QCD', var=None, cfgs=samples_ss, cut=inc_cut, lumi=int_lumi)

    samples_qcdfromss.append(qcd)

# Taken from Variables.py, can get subset with e.g. getVars(['mt', 'mvis'])
variables = all_vars
variables = getVars(['_norm_', 'mt', 'met_pt', 'mvis', 'l1_pt', 'l2_pt', 'l1_eta', 'l2_eta', 'n_vertices', 'n_jets', 'n_bjets'])

# variables = getVars(['_norm_', 'mt', 'mvis', 'n_vertices'])

# variables = getVars(['_norm_', 'met_pt', 'met_phi'])

# variables = getVars(['_norm_'])
variables = [
    VariableCfg(name='mvis', binning={'nbinsx':35, 'xmin':0, 'xmax':350}, unit='GeV', xtitle='m_{vis}')
]

# variables += getVars(['_norm_'])

for cut_name in cuts:
    if qcd_from_same_sign and not 'SS' in cut_name :
        cfg_example = HistogramCfg(name=cut_name, var=None, cfgs=samples_qcdfromss, cut=inc_cut, lumi=int_lumi, weight=total_weight)
    else:
        cfg_example = HistogramCfg(name=cut_name, 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')
qcd_from_same_sign = False

# -> Command line
analysis_dir = '/data1/steggema/TauFRPU'
data_dir = analysis_dir

samples_mc, samples_data, samples, all_samples, sampleDict = createSampleLists(analysis_dir=analysis_dir, channel='tau_fr')

samples_mc_w = [s for s in samples_mc if fnmatch.fnmatch(s.name, 'W*Jet*')]
samples_mc_tt = [s for s in samples_mc if fnmatch.fnmatch(s.name, 'TT*')]

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

variables += [
    VariableCfg(name='muon_pt', binning={'nbinsx':40, 'xmin':0., 'xmax':100.}, unit='GeV', xtitle='muon p_{T}'),
    VariableCfg(name='tau_pt', binning={'nbinsx':40, 'xmin':0., 'xmax':100.}, unit='GeV', xtitle='tau p_{T}'),
    VariableCfg(name='jet_pt', binning=array([20., 30., 40., 50., 60., 70., 80., 90., 100., 150., 200.]), unit='GeV', xtitle='tau jet p_{T}'),
    VariableCfg(name='tau_pt', binning=array([20., 25., 30., 35., 40., 50., 60., 80., 120., 200.]), unit='GeV', xtitle='tau p_{T}'),
]

# variables += [v for v in all_vars if 'dxy' in v.name or 'dz' in v.name]

# variables = getVars(['_norm_', 'tau_pt', 'tau_eta', 'tau_mass', 'tau_decayMode', 'mvis', 'mt', 'delta_r_l1_l2', 'tau_gen_pdgId', 'tau_mt'])
# variables = all_vars

for cut_name in cuts:
    cfg_tight = HistogramCfg(name='tight', var=None, cfgs=samples_mc_w, cut=inc_cut, lumi=int_lumi, weight=total_weight + ' * ((tau_gen_match == 6))')
    cfg_loose = HistogramCfg(name='loose', var=None, cfgs=samples_mc_w, cut=inc_cut, lumi=int_lumi, weight=total_weight + ' * ((tau_gen_match == 6))')

    cfg_data_tight = HistogramCfg(name='tight_data', var=None, cfgs=samples_mc_tt, cut=inc_cut, lumi=int_lumi, weight=total_weight + ' * ((tau_gen_match == 6))')
Beispiel #12
0
variables = getVars([
    'mvis', 'mt2', 'l1_pt', 'l2_pt', 'delta_phi_l1_l2', 'delta_eta_l1_l2',
    'met_pt', 'mt_total', 'mt_sum', 'pzeta_met', 'l2_mt', 'mt', 'pzeta_vis',
    'pzeta_disc', 'pthiggs', 'jet1_pt', 'n_jets', 'pt_l1l2'
])  #, 'l1_pt',  '_norm_', ])
# variables += [
#     VariableCfg(name='mt2', binning={'nbinsx':15, 'xmin':0., 'xmax':150.}, unit='GeV', xtitle='m_{T2}')
# ]
if mode == 'mva':
    variables += getVars(['_norm_'])
    variables += [
        VariableCfg(name='mva1',
                    binning={
                        'nbinsx': 10,
                        'xmin': 0.,
                        'xmax': 1.
                    },
                    unit='',
                    xtitle='Stau MVA')
    ]

ams_dict = {}
sample_names = set()

for cut in cuts:
    isSS = 'SS' in cut.name
    all_samples_qcd = qcd_estimation(
        cut.cut & iso_sideband_cut &
        (charge_cut if not isSS else ~charge_cut),  # shape sideband
        cut.cut & iso_cut & (~charge_cut),  # norm sideband 1
        cut.cut & iso_sideband_cut & (~charge_cut),  # norm sideband 2
tree_prod_name = 'H2TauTauTreeProducerTauMu'
data_dir = analysis_dir

samples_mc, samples_data, samples, all_samples, sampleDict = createSampleLists(
    analysis_dir=analysis_dir)

samples_mc_w = [s for s in samples_mc if fnmatch.fnmatch(s.name, 'W*Jet*')]
samples_mc_tt = [s for s in samples_mc if fnmatch.fnmatch(s.name, 'TT*')]

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

variables += [
    VariableCfg(name='l2_jet_pt',
                binning=array(
                    [20., 30., 40., 50., 60., 70., 80., 90., 100., 150.,
                     200.]),
                unit='GeV',
                xtitle='tau jet p_{T}'),
    VariableCfg(name='l2_pt',
                binning=array(
                    [20., 25., 30., 35., 40., 50., 60., 80., 120., 200.]),
                unit='GeV',
                xtitle='tau p_{T}'),
]

# variables += [v for v in all_vars if 'dxy' in v.name or 'dz' in v.name]

# variables = getVars(['_norm_', 'l2_pt', 'l2_eta', 'l2_mass', 'l2_decayMode', 'mvis', 'mt', 'delta_r_l1_l2', 'l2_gen_pdgId', 'l2_mt'])
# variables = all_vars

for cut_name in cuts:
Beispiel #14
0
from CMGTools.H2TauTau.proto.plotter.PlotConfigs import VariableCfg

from CMGTools.H2TauTau.proto.plotter.binning import binning_svfitMass

all_vars = [    
    VariableCfg(name='mvis', binning=binning_svfitMass, unit='GeV', xtitle='m_{vis}'),
    VariableCfg(name='mt', binning={'nbinsx':20, 'xmin':0., 'xmax':200.}, unit='GeV', xtitle='m_{T}'),
    VariableCfg(name='mt_leg2', binning={'nbinsx':20, 'xmin':0., 'xmax':300.}, unit='GeV', xtitle='m_{T} #tau'),
    VariableCfg(name='n_vertices', binning={'nbinsx':51, 'xmin':-0.5, 'xmax':50.5}, unit=None, xtitle='N_{vertices}'),
    VariableCfg(name='n_jets', binning={'nbinsx':12, 'xmin':-0.5, 'xmax':11.5}, unit=None, xtitle='N_{jets}'),
    VariableCfg(name='n_jets_20', binning={'nbinsx':12, 'xmin':-0.5, 'xmax':11.5}, unit=None, xtitle='N_{jets} (20 GeV)'),
    VariableCfg(name='n_bjets', binning={'nbinsx':12, 'xmin':-0.5, 'xmax':11.5}, unit=None, xtitle='N_{b jets}'),
    VariableCfg(name='met_phi', binning={'nbinsx':12, 'xmin':-3.141593, 'xmax':3.141593}, unit=None, xtitle='E_{T}^{miss} #Phi'),
    VariableCfg(name='met_pt', binning={'nbinsx':12, 'xmin':0., 'xmax':200.}, unit='GeV', xtitle='E_{T}^{miss}'),
    VariableCfg(name='delta_eta_l1_l2', binning={'nbinsx':12, 'xmin':0, 'xmax':4.5}, unit=None, xtitle='#Delta#eta(#tau, #mu)'),
    VariableCfg(name='delta_r_l1_l2', binning={'nbinsx':12, 'xmin':0, 'xmax':4.5}, unit=None, xtitle='#Delta R(#tau, #mu)'),
    VariableCfg(name='vbf_mjj', binning={'nbinsx':40, 'xmin':0, 'xmax':1000.}, unit='GeV', xtitle='m_{jj}'),
    VariableCfg(name='vbf_deta', binning={'nbinsx':40, 'xmin':-7., 'xmax':7.}, unit=None, xtitle='#Delta#eta (VBF)'),
    VariableCfg(name='jet1_pt', binning={'nbinsx':40, 'xmin':0., 'xmax':400.}, unit='GeV', xtitle='jet 1 p_{T}'),
    VariableCfg(name='jet2_pt', binning={'nbinsx':40, 'xmin':0., 'xmax':400.}, unit='GeV', xtitle='jet 2 p_{T}'),
    VariableCfg(name='jet1_eta', binning={'nbinsx':40, 'xmin':-5., 'xmax':5.}, unit=None, xtitle='jet 1 #eta'),
    VariableCfg(name='jet2_eta', binning={'nbinsx':40, 'xmin':-5., 'xmax':5.}, unit=None, xtitle='jet 2 #eta'),
    VariableCfg(name='l1_pt', binning={'nbinsx':40, 'xmin':0., 'xmax':400.}, unit='GeV', xtitle='muon p_{T}'),
    VariableCfg(name='l2_pt', binning={'nbinsx':40, 'xmin':0., 'xmax':400.}, unit='GeV', xtitle='tau p_{T}'),
    VariableCfg(name='l1_eta', binning={'nbinsx':20, 'xmin':-2.5, 'xmax':2.5}, unit=None, xtitle='muon #eta'),
    VariableCfg(name='l2_eta', binning={'nbinsx':20, 'xmin':-2.5, 'xmax':2.5}, unit=None, xtitle='tau #eta'),
    VariableCfg(name='l2_decayMode', binning={'nbinsx':12, 'xmin':-0.5, 'xmax':11.5}, unit=None, xtitle='tau decay mode'),
    VariableCfg(name='l2_mass', binning={'nbinsx':15, 'xmin':0., 'xmax':3.}, unit='GeV', xtitle='tau mass'),
]

dict_all_vars = {}
        XSection: sampleDict['WWTo1L1Nu2Q'].xsec,
        SumWeights: sampleDict['WWTo1L1Nu2Q'].sumweights
    },
    #{Name:'ZZTo4L'      , DirName:'ZZTo4L'           , XSection:sampleDict['ZZTo4L'].xsec      , SumWeights:sampleDict['ZZTo4L'].sumweights      }   ,
]

non_fakes = [
    'ZTT', 'ZL', 'W_L', 'TT_L', 'T_tWch_L', 'TBar_tWch_L', 'ZZTo2L2Q_L',
    'WZTo3L_L', 'WZTo2L2Q_L', 'WZTo1L3Nu_L', 'WZTo1L1Nu2Q_L', 'VVTo2L2Nu_L',
    'WWTo1L1Nu2Q_L'
]

## Variables to use
variables = [
    #VariableCfg(name='mvis_stdbins', binning={}, unit='GeV', xtitle='m_{vis}'),
    VariableCfg(name='mvis_vs_mt', binning={}, unit='GeV', xtitle='m_{T}'),
]

## Define  selections
global_selections = ["{SIGN}Iso_Medium", "{SIGN}MT40_Iso_Medium"]

backgrounds = ['VV', 'TT', 'QCD', 'W', 'ZJ']

shifts = {
    'Nom':  # no shift
    {},
    'WStat':  # stat shifts
    {
        'W': 1.
    },
    'QCDStat':  # stat shifts
Beispiel #16
0
    samples_non_w_highmt_ss = copy.deepcopy(samples_non_w)

    for sample in samples_non_w_highmt_os:
        if sample.name != 'data_obs':
            # Subtract background from data
            sample.scale = -1.

    for sample in samples_non_w_highmt_ss:
        if sample.name != 'data_obs':
            sample.scale = -1.

    var_norm = VariableCfg(name='_norm_',
                           drawname='1.',
                           binning={
                               'nbinsx': 5,
                               'xmin': -1.5,
                               'xmax': 3.5
                           },
                           unit='',
                           xtitle='Normalisation')

    stacknow_highmt_os = HistogramCfg(name='HighMTOS',
                                      var=var_norm,
                                      cfgs=samples_non_w_highmt_os,
                                      cut=inc_cut,
                                      lumi=int_lumi,
                                      weight=total_weight)
    stacknow_highmt_ss = HistogramCfg(name='HighMTSS',
                                      var=var_norm,
                                      cfgs=samples_non_w_highmt_ss,
                                      cut=inc_cut,
Beispiel #17
0
cut_names = [cut for cut in cuts]
# for cut in cut_names:
#     cuts[cut+'_plus'] = cuts[cut] + ' && muon_charge==1'
#     cuts[cut+'_minus'] = cuts[cut] + ' && muon_charge==-1'

qcd_from_same_sign = False

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

variables = [
    VariableCfg(name='jet_pt',
                binning=array([
                    20., 30., 40., 50., 60., 80., 100., 120., 140., 160., 180.,
                    200., 250., 300., 350.
                ]),
                unit='GeV',
                xtitle='jet p_{T}'),
    VariableCfg(name='tau_pt',
                binning=array([
                    20., 30., 40., 50., 60., 80., 100., 120., 140., 160., 180.,
                    200., 250., 300., 350.
                ]),
                unit='GeV',
                xtitle='tau p_{T}'),
    VariableCfg(name='jet_eta',
                binning={
                    'nbinsx': 25,
                    'xmin': -2.5,
                    'xmax': 2.5