Пример #1
0
         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']),
             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)
 output_path = os.path.join(os.getcwd(), 'data', 'Results',
                            'compareTauID', args.year,
                            reco_names[args.includeReco], d,
Пример #2
0
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}
        list_of_eff = {}
        for fk in filtered_key_names: #algo
            list_of_eff[fk] = {}
Пример #3
0
    ROC_integrals = []
    for iname, mname in enumerate(mnames):
        progress(iname, len(mnames))
        ROCs[mname] = ROOT.TMVA.ROCCurve(mva_output[mname], class_id, weight)
        ROC_integrals.append(ROCs[mname].GetROCIntegral())
        ROC_curve = ROCs[mname].GetROCCurve()
        ROC_curve = fillRandGraph(ROC_curve, 10)
        extra_text = [
            extraTextFormat("AUC: " + str(ROCs[mname].GetROCIntegral()))
        ]
        p = Plot(signal_hist=[ROC_curve],
                 tex_names=[mname],
                 name='roc_' + mname,
                 extra_text=extra_text)
        p.drawGraph(output_dir=out_file_name.rsplit('/', 1)[0] + '/kBDT/plots',
                    draw_style="AP")

    print 'Making pdf'
    mnames = sortByOtherList(mnames, ROC_integrals)
    mnames.reverse()
    pdf = FPDF()
    for mname in mnames:
        pdf.add_page()
        pdf.image(
            os.path.join(
                out_file_name.rsplit('/', 1)[0], 'kBDT', 'plots',
                'roc_' + mname + '.png'), 50., 50., 100., 100.)
        pdf.image(
            os.path.join(
                out_file_name.rsplit('/', 1)[0], 'kBDT', 'plots',
                'overtrain_' + mname + '.png'), 50., 150., 100., 100.)