Exemplo n.º 1
0
                                                   or sname.endswith('Down')):
            samples.pop(sname)
            try:
                signals.remove(sname)
            except ValueError:
                pass

    cuts = {}
    with open('cuts.py') as cutsfile:
        exec(cutsfile)

    nuisances = {}
    with open('nuisances.py') as nuisancesfile:
        exec(nuisancesfile)

    subsamplemap = dict(utils.flatten_samples(samples))
    for sname in signals:
        for sub in list(subsamplemap[sname]):
            if obsname not in sub:
                samples.pop(sub)
                subsamplemap[sname].remove(sub)

    for cut in cuts.keys():
        if obsname not in cut:
            cuts.pop(cut)

    categorymap = dict(utils.flatten_cuts(cuts))

    nuisances_original = copy.deepcopy(nuisances)
    utils.update_nuisances_with_subsamples(nuisances, subsamplemap.items())
    utils.update_nuisances_with_categories(nuisances, categorymap.items())
Exemplo n.º 2
0
    if os.path.exists(opt.variablesFile):
        handle = open(opt.variablesFile, 'r')
        exec(handle)
        handle.close()

    nuisances = {}
    if opt.nuisancesFile == None:
        print " Please provide the nuisances structure if you want to add nuisances "
    elif os.path.exists(opt.nuisancesFile):
        handle = open(opt.nuisancesFile, 'r')
        exec(handle)
        handle.close()

    import LatinoAnalysis.ShapeAnalysis.utils as utils

    subsamplesmap = utils.flatten_samples(samples)
    categoriesmap = utils.flatten_cuts(cuts)

    utils.update_variables_with_categories(variables, categoriesmap)
    utils.update_nuisances_with_subsamples(nuisances, subsamplesmap)
    utils.update_nuisances_with_categories(nuisances, categoriesmap)

    # check if only one cut or only one variable
    # is requested, and filter th elist of cuts and variables
    # using this piece of information

    if opt.onlyVariable != None:
        list_to_remove = []
        for variableName, variable in variables.iteritems():
            if variableName != opt.onlyVariable:
                list_to_remove.append(variableName)