コード例 #1
0
def makePlots(variables, cuts, total_weight, sample_dict, hist_dict, qcd_from_same_sign, w_qcd_mssm_method, mt_cut, friend_func, dc_postfix, make_plots=True, create_trees=False):
    ams_dict = {}
    sample_names = set()
    for cut in cuts:
        cfg_main = HistogramCfg(name=cut.name, var=None, cfgs=sample_dict['all_samples'], cut=cut.cut, lumi=int_lumi, weight=total_weight)
    
        cfg_main.vars = variables
        HISTS = CreateHists(cfg_main)

        plots = HISTS.createHistograms(cfg_main, verbose=False, friend_func=friend_func)
        #plots.legendPos = 'right'
        for variable in variables:
        # for plot in plots.itervalues():
            plot = plots[variable.name]
#             plot.Group('data_obs', ['data_2017B_e', 'data_2017C_e', 'data_2017D_e', 'data_2017E_e', 'data_2017F_e'])
#             plot.Group('single t', ['ST_tW_at_5f_incD_e', 'ST_tW_t_5f_incD_e'])
#             plot.Group('Diboson' , ['WZTo3LNu_e', 'ZZTo4L_e', 'WWTo2L2Nu_e'])
#             plot.Group('Triboson', ['ZZZ_e', 'WWW_e', 'WGGJets_e'])
#             plot.Group('ttV'     , ['TTZToLLNuNu_e', 'TTWJetsToLNu_e'])
#             plot.Group('DY'      , ['DYJets_M5T50_e', 'DYJets_M50_x_e', 'DYJets_M50_e'])
            createDefaultGroups(plot)
            if make_plots:
                HistDrawer.draw(plot, plot_dir = '/eos/user/m/manzoni/HNL/plots/'+cut.name)#plot_dir='plots/'+cut.name)
    
    print '\nOptimisation results:'
    all_vals = ams_dict.items()
    for sample_name in sample_names:
        vals = [v for v in all_vals if sample_name + '_' in v[0]]
        vals.sort(key=itemgetter(1))
        for key, item in vals:
            print item, key

        print '\nBy variable'
        for variable in variables:
            name = variable.name
            print '\nResults for variable', name
            for key, item in vals:
                if key.startswith(name + '__'):
                    print item, key
コード例 #2
0
ファイル: plot_cfg_HNL_mu.py プロジェクト: mschoene/HNL
def makePlots(variables,
              cuts,
              total_weight,
              sample_dict,
              hist_dict,
              qcd_from_same_sign,
              w_qcd_mssm_method,
              mt_cut,
              friend_func,
              dc_postfix,
              make_plots=True,
              create_trees=False):
    ams_dict = {}
    sample_names = set()
    for cut in cuts:
        cfg_main = HistogramCfg(name=cut.name,
                                var=None,
                                cfgs=sample_dict['all_samples'],
                                cut=cut.cut,
                                lumi=int_lumi,
                                weight=total_weight)
        # cfg_main = HistogramCfg(name=cut.name, var=None, cfgs=sample_dict['samples_essential'], cut=cut.cut, lumi=int_lumi, weight=total_weight)

        cfg_main.vars = variables
        HISTS = CreateHists(cfg_main)

        plots = HISTS.createHistograms(cfg_main,
                                       verbose=False,
                                       friend_func=friend_func)
        #plots.legendPos = 'right'
        for variable in variables:
            # for plot in plots.itervalues():
            plot = plots[variable.name]
            plot.Group('data_obs', [
                'data_2017B', 'data_2017C', 'data_2017D', 'data_2017E',
                'data_2017F'
            ])
            plot.Group('single t', ['ST_tW_at_5f_incD', 'ST_tW_t_5f_incD'])
            #            plot.Group('Diboson', ['WZTo3LNu', 'ZZTo4L', 'WWTo2L2Nu'])
            plot.Group('Diboson', ['WZTo3LNu', 'WWTo2L2Nu'])
            plot.Group('Triboson', ['ZZZ', 'WWW', 'WGGJets,WWZ,WZZ'])
            plot.Group('ttV', ['TTZToLLNuNu', 'TTWJetsToLNu'])
            plot.Group('QCD', [
                'QCD_pt_15to20_mu', 'QCD_pt_20to30_mu', 'QCD_pt_30to50_mu',
                'QCD_pt_50to80_mu', 'QCD_pt_80to120_mu'
            ])
            plot.Group(
                'WJets',
                ['W1JetsToLNu', 'W2JetsToLNu', 'W3JetsToLNu', 'W4JetsToLNu'])
            #            plot.Group('DY', ['DYJetsToLL_M10to50', 'DYJets_ext'])
            plot.Group('DYJetsToLL_M10to50',
                       ['DYJetsToLL_M10to50', 'DYJetsToLL_M10to50_ext'])
            createDefaultGroups(plot)
            if make_plots:
                HistDrawer.draw(plot,
                                channel=channel_name,
                                plot_dir=plotDir +
                                cut.name)  #plot_dir='plots/'+cut.name)

    print '\nOptimisation results:'
    all_vals = ams_dict.items()
    for sample_name in sample_names:
        vals = [v for v in all_vals if sample_name + '_' in v[0]]
        vals.sort(key=itemgetter(1))
        for key, item in vals:
            print item, key

        print '\nBy variable'
        for variable in variables:
            name = variable.name
            print '\nResults for variable', name
            for key, item in vals:
                if key.startswith(name + '__'):
                    print item, key
コード例 #3
0
ファイル: plot_cfg_hn3l.py プロジェクト: mschoene/HNL
def makePlots(plotDir,
              channel_name,
              variables,
              cuts,
              total_weight,
              sample_dict,
              hist_dict,
              qcd_from_same_sign,
              w_qcd_mssm_method,
              mt_cut,
              friend_func,
              dc_postfix,
              make_plots=True,
              create_trees=False,
              multiprocess=True):
    ams_dict = {}
    sample_names = set()
    for cut in cuts:
        cutDir = plotDir + cut.name
        if not os.path.exists(cutDir):
            os.mkdir(cutDir)
            print "Directory ", cutDir, "Created "
        else:
            print "Directory ", cutDir, "already exists, overwriting it!"
            shutil.rmtree(cutDir)
            os.mkdir(cutDir)

        cfg_main = HistogramCfg(name=cut.name,
                                var=None,
                                cfgs=sample_dict['working_samples'],
                                cut=cut.cut,
                                lumi=int_lumi,
                                weight=total_weight)

        cfg_main.vars = variables

        HISTS = CreateHists(cfg_main)

        plots = HISTS.createHistograms(cfg_main,
                                       verbose=False,
                                       friend_func=friend_func,
                                       multiprocess=multiprocess)
        #plots.legendPos = 'right'
        for variable in variables:
            # for plot in plots.itervalues():
            plot = plots[variable.name]

            if channel_name == "e#mu#mu":
                plot.Group('data_obs', [
                    'data_2017B', 'data_2017C', 'data_2017D', 'data_2017E',
                    'data_2017F'
                ])
                plot.Group('single t', [
                    'ST_tW_inc', 'STbar_tW_inc', 'ST_sch_lep', 'STbar_tch_inc',
                    'ST_tch_inc'
                ])
                plot.Group('Diboson', ['WZTo3LNu', 'ZZTo4L', 'WWTo2L2Nu'])
                plot.Group('Triboson', ['ZZZ', 'WWW', 'WGGJets', 'WZZ', 'WWZ'])
                plot.Group('ttV',
                           ['TTZToLL_M10', 'TTWJetsToLNu', 'TTZToLL_M1to10'])
                plot.Group('DY',
                           ['DYJets_ext', 'DYJets', 'DYJetsToLL_M10to50'])
                plot.Group('QCD', [
                    'QCD_pt_15to20_em', 'QCD_pt_20to30_em', 'QCD_pt_30to50_em',
                    'QCD_pt_50to80_em', 'QCD_pt_120to170_em',
                    'QCD_pt_300toInf_em', 'QCD_pt_20to30_bcToE',
                    'QCD_pt_30to80_bcToE', 'QCD_pt_80to170_bcToE',
                    'QCD_pt_170to250_bcToE', 'QCD_pt_250toInf_bcToE'
                ])
                plot.Group('WJets', [
                    'W1JetsToLNu', 'W2JetsToLNu', 'W3JetsToLNu', 'W4JetsToLNu'
                ])

            if channel_name == "#mu#mu#mu":
                plot.Group('data_obs', [
                    'data_2017B', 'data_2017C', 'data_2017D', 'data_2017E',
                    'data_2017F'
                ])
                plot.Group('Diboson', ['WZTo3LNu', 'ZZTo4L'])
                # plot.Group('ttV', ['TTWJetsToLNu'])
                plot.Group('DY', ['DYJets_ext', 'DYBB', 'DYJetsToLL_M10to50'])
                # plot.Group('Conversions',['Conversion_DYBB','Conversion_DYJetsToLL_M10to50'])
                plot.Group('Conversions', [
                    'Conversion_DYBB', 'Conversion_DYJetsToLL_M10to50',
                    'Conversion_WJetsToLNu'
                ])
                plot.Group('QCD', [
                    'QCD_pt_15to20_mu', 'QCD_pt_20to30_mu', 'QCD_pt_30to50_mu',
                    'QCD_pt_50to80_mu', 'QCD_pt_80to120_mu'
                ])
                plot.Group('WJets', [
                    'W1JetsToLNu', 'W2JetsToLNu', 'W3JetsToLNu', 'W4JetsToLNu'
                ])
            # createDefaultGroups(plot)
            if make_plots:
                HistDrawer.draw(plot,
                                channel=channel_name,
                                plot_dir=plotDir + cut.name)

    print '\nOptimisation results:'

    all_vals = ams_dict.items()
    for sample_name in sample_names:
        vals = [v for v in all_vals if sample_name + '_' in v[0]]
        vals.sort(key=itemgetter(1))
        for key, item in vals:
            print item, key

        print '\nBy variable'
        for variable in variables:
            name = variable.name
            print '\nResults for variable', name
            for key, item in vals:
                if key.startswith(name + '__'):
                    print item, key