Esempio n. 1
0
def eff_plots_single(d_sample, vars_to_compare, var_dict):
    '''Adapted from Olena's code - can possibly merge it with efficiency_plots
    '''
    if not vars_to_compare:
        return

    hists = []
    histseta = []

    for index, var_name in enumerate(vars_to_compare):
        hdict = var_dict[var_name]
        if varyLooseId and 'IsolationMVA' in var_name:
            loose_id = 'tau_decayModeFindingOldDMs > 0.5 && ' + findLooseId(
                var_name)

        for _, rdict in sorted(d_sample.items(),
                               key=lambda item: item[1]["index"]):
            tree = rdict['tree']
            if 'leaves' not in rdict:
                rdict['leaves'] = [
                    leaf.GetName() for leaf in tree.GetListOfLeaves()
                ]
            used_vars = word_finder(hdict['var'])
            if not set(used_vars).issubset(rdict['leaves']):
                warnings.warn(var_name + ' is missing in input file ' +
                              rdict['file'].GetName())
                return
            num_sel = reco_cut
            den_sel = '1'
            discriminators = {"loose_id": den_sel}
            if 'against' in var_name:
                den_sel = gen_cut + ' && ' + loose_id

            for mvaIDname, sel in discriminators.items():
                dprint("\n\tmvaIDname:", mvaIDname, "hdict['var']:",
                       hdict['var'])

                hists.append(
                    makeEffPlotsVars(tree=tree,
                                     varx='tau_genpt',
                                     numeratorAddSelection=num_sel + '&&' +
                                     hdict['var'],
                                     baseSelection=sel,
                                     binning=ptPlotsBinning,
                                     xtitle=options_dict[runtype].xlabel,
                                     header=var_name + mvaIDname,
                                     addon=var_name + mvaIDname,
                                     marker=rdict['marker'],
                                     col=int(colors[index])))

                shiftAlongX(hists[-1], len(vars_to_compare), index)

                histseta.append(
                    makeEffPlotsVars(tree=tree,
                                     varx='tau_geneta',
                                     numeratorAddSelection=num_sel + '&&' +
                                     hdict['var'],
                                     baseSelection=sel,
                                     binning=etaPlotsBinning,
                                     xtitle=options_dict[runtype].xlabel_eta,
                                     header=var_name + mvaIDname,
                                     addon=var_name + mvaIDname,
                                     marker=rdict['marker'],
                                     col=int(colors[index])))

                shiftAlongX(histseta[-1], len(vars_to_compare), index)

    overlay(graphs=hists,
            header=vars_to_compare[0],
            addon=hdict['title'],
            runtype=runtype,
            tlabel=options_dict[runtype].tlabel,
            comparePerReleaseSuffix="_comparePerRelease")

    overlay(graphs=histseta,
            header=vars_to_compare[0] + '_eta',
            addon=hdict['title'] + '_eta',
            runtype=runtype,
            tlabel=options_dict[runtype].tlabel,
            comparePerReleaseSuffix="_comparePerRelease")
Esempio n. 2
0
    globaldebug = args.debug
    maxEvents = args.maxEvents
    RelVal = args.release
    globalTag = args.globalTag
    exact = args.exact
    useRecoJets = args.useRecoJets
    storageSite = args.storageSite
    localdir = args.localdir
    tauCollection = args.tauCollection
    mvaid = args.mvaid
    no_anti_lepton = args.noAntiLepton
    if len(localdir) > 1 and localdir[-1] != "/":
        localdir += "/"
    inputfiles = args.inputfiles

    dprint('Running with')
    dprint('runtype', runtype)
    dprint('RelVal', RelVal)
    dprint('globalTag', globalTag)
    dprint('storageSite', storageSite)

    filelist = inputfiles
    events = Events(filelist)
    print len(filelist), "files will be analyzed:", filelist, '\nEvents will be analyzed: %i' % maxEvents

    # +++++++ Output file +++++++++
    outputFileName = args.outputFileName
    print "outputFileName:", outputFileName

    out_file = ROOT.TFile(outputFileName, 'recreate')