示例#1
0
print 'Getting things ready to start the event loop'

#Initialize histograms
from HNL.Tools.ROC import ROC
from HNL.Tools.efficiency import Efficiency
list_of_roc = []
list_of_var_hist = {'efficiency': {}, 'fakerate': {}}
for algo in algos:

    algo_wp = algos[algo]

    tot_name = output_name + '/' + sample.name + '_' + algo + '-ROC-' + str(
        args.flavor) + '_' + args.subJob + '.root'
    makeDirIfNeeded(tot_name)
    list_of_roc.append(ROC(algo, tot_name, working_points=algo_wp))

    #Efficiency histograms for variables
    var_hist = {
        'pt': [
            lambda c: c.pt_l,
            np.arange(0., 210., 10.),
            ('p_T^{#tau}(offline) [GeV]', 'Efficiency')
        ],
        'eta': [
            lambda c: c.eta_l,
            np.arange(-2.5, 3., 0.5),
            ('#eta^{#tau}(offline) [GeV]', 'Efficiency')
        ]
    }
示例#2
0
for mf in merge_files:
    if "Results" in mf: continue
    merge(mf)

input_signal = glob.glob(os.getcwd()+'/data/compareLightLeptonId/'+args.signal+'/*ROC-'+args.flavor+'.root')
bkgr_prefix = os.getcwd()+'/data/compareLightLeptonId/'+args.bkgr

from HNL.Plotting.plot import Plot

output_dir = makePathTimeStamped(os.getcwd()+'/data/Results/compareLightLeptonId/ROC/'+args.signal+'-'+args.bkgr)
curves = []
ordered_f_names = []
for f_path in input_signal:
    f_name = f_path.rsplit('/', 1)[1].split('.')[0]
    ordered_f_names.append(f_name)
    roc_curve = ROC(f_name.split('-')[0], 1., '', f_path, misid_path =bkgr_prefix + '/'+f_name+'.root')
    curves.append(roc_curve.returnGraph())
p = Plot(curves, ordered_f_names, args.signal+'_'+args.flavor, 'efficiency', 'misid', y_log=True)
p.drawGraph(output_dir = output_dir)
       
from HNL.Tools.efficiency import Efficiency
from HNL.Tools.helpers import rootFileContent
from ROOT import TFile
var = ['pt', 'eta']
inputFiles = {'efficiency' : glob.glob(os.getcwd()+'/data/compareLightLeptonId/'+args.signal+'/efficiency-'+str(args.flavor)+'.root'), 'fakerate': glob.glob(os.getcwd()+'/data/compareLightLeptonId/'+args.bkgr+'/fakerate-'+str(args.flavor)+'.root')}
for eff_name in ['efficiency', 'fakerate']:
    for f in inputFiles[eff_name]:
        print f
        rf = TFile(f)
        key_names = [k[0] for k in rootFileContent(rf)]
        filtered_key_names = {fk.rsplit('-', 1)[0].split('/')[-1] for fk in key_names}
示例#3
0
list_of_var_hist = {'efficiency': {}, 'fakerate': {}}
var_roc = lambda c, i: c.algo_wps[i]

for discr in args.discriminators:
    #
    # ROC curves
    #
    list_of_roc[discr] = {}
    for algo in algos[discr]:
        algo_bins = np.arange(0., len(algos[discr][algo]) + 1., 1)
        out_path = output_name(
            discr, algo,
            'all') + '/' + sample.name + '_ROC' + subjobAppendix + '.root'
        if discr != 'iso' or not args.makeCombinations:
            list_of_roc[discr][algo] = ROC(algo,
                                           out_path,
                                           working_points=algos[discr][algo])
        else:
            list_of_roc[discr][algo] = {}
            for ele_wp in algos['ele'][linkIsoToLep('ele', algo)]:
                list_of_roc[discr][algo][ele_wp] = {}
                for mu_wp in algos['mu'][linkIsoToLep('mu', algo)]:
                    list_of_roc[discr][algo][ele_wp][mu_wp] = ROC(
                        '-'.join([algo, str(ele_wp),
                                  str(mu_wp)]),
                        out_path,
                        working_points=algos[discr][algo])
    #
    #Efficiency histograms for variables
    #
    var_hist = {
示例#4
0
文件: plotTauID.py 项目: gmestdac/HNL
                          algo, 'all', 'ROC.root')
 rf = TFile(signal_path)
 key_names = [k[0] for k in rootFileContent(rf)]
 ele_wp[algo] = {
     k.split('/')[1].split('-')[1]
     for k in key_names if algo in k
 }
 mu_wp[algo] = {
     k.split('/')[1].split('-')[2]
     for k in key_names if algo in k
 }
 rf.Close()
 for ewp in ele_wp[algo]:
     for mwp in mu_wp[algo]:
         roc_curve = ROC('-'.join([algo, ewp, mwp]),
                         signal_path,
                         misid_path=bkgr_path)
         p = Plot(roc_curve.returnGraph(),
                  algo,
                  '-'.join([algo, ewp, mwp]),
                  'efficiency',
                  'misid',
                  y_log=True,
                  extra_text=extra_text)
         output_path = os.path.join(
             os.getcwd(), 'data', 'Results', 'compareTauID',
             reco_names[args.includeReco], d,
             signal_name + '-' + bkgr_name, algo)
         p.drawGraph(output_dir=output_path)
 curves.append(
     ROC('-'.join([algo, 'None', 'None']),
示例#5
0
 if d == 'iso' and args.makeCombinations:
     ele_wp = {}
     mu_wp = {}
     curves = []
     ordered_names = []
     for algo in algos:
         signal_path = os.path.join(ip, algo, 'all','ROC.root')
         bkgr_path = os.path.join(input_paths['background'][d][0], algo, 'all','ROC.root')
         rf = TFile(signal_path)
         key_names = [k[0] for k in rootFileContent(rf)]
         ele_wp[algo] = {k.split('/')[1].split('-')[1] for k in key_names if algo in k}
         mu_wp[algo] = {k.split('/')[1].split('-')[2] for k in key_names if algo in k}
         rf.Close()
         for ewp in ele_wp[algo]:
             for mwp in mu_wp[algo]:
                 roc_curve = ROC('-'.join([algo, ewp, mwp]), signal_path , misid_path = bkgr_path)
                 p = Plot(roc_curve.returnGraph(), algo, '-'.join([algo, ewp, mwp]), 'efficiency', 'misid', y_log=True, extra_text = extra_text)
                 if args.isTest:
                     output_path = os.path.join(os.getcwd(), 'data', 'testArea', 'Results', 'compareTauID', reco_names[args.includeReco], d, signal_name+'-'+bkgr_name, algo)
                 else:
                     output_path = os.path.join(os.getcwd(), 'data', 'Results', 'compareTauID', reco_names[args.includeReco], d, signal_name+'-'+bkgr_name, algo)
                 p.drawGraph(output_dir = output_path)
         curves.append(ROC('-'.join([algo, 'None', 'None']), signal_path , misid_path = bkgr_path).returnGraph()) 
         ordered_names.append(algo)
     p = Plot(curves, ordered_names, 'ROC', 'efficiency', 'misid', y_log=True, extra_text = extra_text)
     if args.isTest:
         output_path = os.path.join(os.getcwd(), 'data', 'testArea', 'Results', 'compareTauID', args.year, reco_names[args.includeReco], d, signal_name+'-'+bkgr_name)
     else:
         output_path = os.path.join(os.getcwd(), 'data', 'Results', 'compareTauID', args.year, reco_names[args.includeReco], d, signal_name+'-'+bkgr_name)
     p.drawGraph(output_dir = output_path)
 else: