Exemplo n.º 1
0
def do_rocs(args):

    dcData = []
    with open(args.dataCollection,'rb') as f:
        while True:
            try:
                o = pickle.load(f)
            except:
                break
            dcData += [o]
    
    treePredName = 'tree'
    treeBaseName = dcData[6].treename
    truthMap = dcData[6].reducedtruthmap
    truthOrder = dcData[6].reducedtruthclasses
    n = len(truthMap)
    
    tfileMapFile = '{}/tree_association.txt'.format(args.predictionDir)


    for x in truthOrder:
        sig_bg = [(x,y) for y in truthOrder if x!=y]
        names = ['{} vs {}'.format(x,y) for x,y in sig_bg]
        probs = ['prob_{}'.format(x) for x,y in sig_bg]
        truths = [x for x,y in sig_bg]
        vetos = [y for x,y in sig_bg]


        makeROCs_async(tfileMapFile,
                       name_list=names,
                       probabilities_list=probs,
                       truths_list=truths,
                       vetos_list=vetos,
                       colors_list='auto',
                       outpdffile='ROC_{}.pdf'.format(x),
                       cuts='jet_pt>30',
                       cmsstyle=False,
                       firstcomment='',
                       secondcomment='',
                       invalidlist='',
                       extralegend=None,
                       logY=True,
                       individual=False,
                       xaxis="efficiency",
                       nbins=200,
                       treename=treeBaseName)
Exemplo n.º 2
0

makeROCs_async(intextfile=args.inputFile, 
               name_list=['E = [10, 30] GeV',
                          'E = [30, 50] GeV',
                          'E = [50, 70] GeV',
                          'E = [70, 200] GeV'], 
               probabilities_list='prob_isSignal', 
               truths_list='isSignal',
               vetos_list='!isSignal',
                    colors_list='auto', 
                    outpdffile=args.outputDir+'/energy_roc.pdf', 
                    #background has true_energy==0 and cuts are also applied to background 
                    cuts=['((true_energy>10 && true_energy<=30) || !isSignal)',
                          '((true_energy>30 && true_energy<=50) || !isSignal)',
                          '((true_energy>50 && true_energy<=70) || !isSignal)',
                          '((true_energy>70 && true_energy<=200) || !isSignal)'], 
                    cmsstyle=False, 
                    firstcomment='',
                    secondcomment='',
                    invalidlist='',
                    extralegend=None, #['solid?udsg','hatched?c'])
                    logY=True,
                    individual=False,
                    xaxis="Signal efficiency",
                    yaxis="Rate [kHz]",
                    nbins=500,
                    treename='tree',
                    yscales=normalisation,
                    no_friend_tree=True)

exit()
Exemplo n.º 3
0
    probs.append('prob_' + t)
    all += t + '+'
    for t2 in truthclasses:
        if t == t2: continue
        veto += t2 + '+'
    veto = veto[0:-1]
    vetos.append(veto)

all = all[0:-1]

##exit()
#for c in truthclasses:
makeROCs_async(intextfile=infile,
               name_list=legs,
               probabilities_list=probs,
               truths_list=truthclasses,
               vetos_list=vetos,
               colors_list='auto,dashed',
               outpdffile=outdir + 'ROC_against_all.pdf',
               cuts='true_energy>5')
#, cmsstyle,
#firstcomment,
#secondcomment,
#invalidlist,
#extralegend,
#logY)

for part in truthclasses:
    for compare in truthclasses:
        if part == compare: continue

        makeROCs_async(
Exemplo n.º 4
0
parser = ArgumentParser('Apply a model to a (test) sample and create friend trees to inject it inthe original ntuple')
parser.add_argument('inputDir')
args = parser.parse_args()

infile=args.inputDir+'/tree_association.txt'
outdir=args.inputDir+'/'



makeROCs_async(intextfile=infile, 
                       name_list=          ['cut based', 'DNN'], 
                       probabilities_list= ['prob_isTau', '1 - demetraIsolation/(demetraIsolation+1)'],
                       truths_list=        'isTau', 
                       vetos_list=         'isNoTau', 
                       colors_list='auto,dashed', 
                       outpdffile=outdir+'ROC_ID_only_dscompare.pdf', 
                       cuts=['isRecTau && recTau_pt>20'],
                       treename='tree',
                       invalidlist='isRecTau<0.5',
                       firstcomment='rec #tau jet p_{T}>20 GeV')



makeROCs_async(intextfile=infile, 
                       name_list=          ['ROC'], 
                       probabilities_list= 'prob_isTau', 
                       truths_list=        'isTau', 
                       vetos_list=         'isNoTau', 
                       colors_list='auto,dashed', 
                       outpdffile=outdir+'ROC_ID_only_all.pdf', 
Exemplo n.º 5
0
#               colors_list,
#               outpdffile,
#               cuts='',
#               cmsstyle=False,
#               firstcomment='',
#               secondcomment='',
#               invalidlist='',
#               extralegend=None,
#               logY=True,
#               individual=False,
#               xaxis="",
#               nbins=200)

makeROCs_async('tree_association.txt',
               name_list=['B vs light', 'B vs. C'],
               probabilities_list=['prob_isB', 'prob_isB'],
               truths_list=['isB', 'isB'],
               vetos_list=['isUDSG', 'isC'],
               colors_list='auto',
               outpdffile='ROC.pdf',
               cuts='jet_pt>30',
               cmsstyle=False,
               firstcomment='',
               secondcomment='',
               invalidlist='',
               extralegend=None,
               logY=True,
               individual=False,
               xaxis="b efficiency",
               nbins=200)