if len(inputs) < 1 : parser.error("provide at least one input")
inputs = [f  for i in inputs for f in glob.glob(i if i.endswith(ext) else i+'/*'+ext)]
inputdir = os.path.dirname(inputs[0])
verbose  = options.verbose
debug    = options.debug
outdir   = options.outdir if options.outdir else inputdir+'/plotsTightProbability/'
tag      = guessMonthDayTag(inputs[0])

if verbose :
    print "Options:"
    print '\n'.join([str(inputs)]
                    + ["%s : %s" % (o, eval(o))
                       for o in ['inputdir', 'outdir', 'tag', 'verbose', 'debug',]])
if not os.path.isdir(outdir) :
    os.mkdir(outdir)
    if verbose : print "created directory '%s'"%outdir

allGroups = datasets.allGroups(datasets.datasets)
allSamples = datasets.allDatasets(datasets.datasets)
for f in inputs :
    group  = next((g for g in allGroups if g in f), None)
    sample = next((s for s in allSamples if s in f), None)
    label = "%s %s"%(group if group else '', sample if sample else '')
    processFile(f, outdir, label)

# allDatasets = [d for d in datasets if not d.placeholder]
# filenamesByGroup = collections.defaultdict(list)
# rootfiles = filter(os.path.isfile, glob.glob(inputdir + "*.root"))
# rootfiles = [rf for rf in rootfiles if tag in rf]

outdir = options.outdir if options.outdir else inputdir + '/plotsTightProbability/'
tag = guessMonthDayTag(inputs[0])

if verbose:
    print "Options:"
    print '\n'.join([str(inputs)] + [
        "%s : %s" % (o, eval(o)) for o in [
            'inputdir',
            'outdir',
            'tag',
            'verbose',
            'debug',
        ]
    ])
if not os.path.isdir(outdir):
    os.mkdir(outdir)
    if verbose: print "created directory '%s'" % outdir

allGroups = datasets.allGroups(datasets.datasets)
allSamples = datasets.allDatasets(datasets.datasets)
for f in inputs:
    group = next((g for g in allGroups if g in f), None)
    sample = next((s for s in allSamples if s in f), None)
    label = "%s %s" % (group if group else '', sample if sample else '')
    processFile(f, outdir, label)

# allDatasets = [d for d in datasets if not d.placeholder]
# filenamesByGroup = collections.defaultdict(list)
# rootfiles = filter(os.path.isfile, glob.glob(inputdir + "*.root"))
# rootfiles = [rf for rf in rootfiles if tag in rf]
Example #3
0
    "multijet": r.kGray,
    "fake": r.kGray,  # just another name for the same thing
    "heavyflavor": r.kViolet + 1,
}
markers = {
    "ttbar": r.kFullTriangleDown,
    "zjets": r.kOpenSquare,
    "wjets": r.kFullTriangleUp,
    "diboson": r.kFullDiamond,
    "singletop": r.kOpenCross,
    "multijet": r.kFullCross,
    "fake": r.kFullCircle,  # just another name for the same thing
    "heavyflavor": r.kFullSquare,
}

allGroups, allDatasets, datasets = allGroups(datasets), allDatasets(datasets), activeDatasets(datasets)


def fastSamplesFromFilenames(filenames=[], verbose=False):
    """Assume a list of filenames with some common prefix (basepath)
    and suffix (tag): strip away the prefix&suffix, and return a list
    of Dataset objects obtained by matching the name to the dataset
    """
    prefix = utils.commonPrefix(filenames)
    suffix = utils.commonSuffix(filenames)
    if verbose:
        print "fastSamplesFromFilenames: prefix '%s' suffix '%s'" % (prefix, suffix)
    if not prefix or not suffix:
        print "fastSamplesFromFilenames: warning prefix '%s' suffix '%s'" % (prefix, suffix)
    filenames = [f.replace(prefix, "").replace(suffix, "") for f in filenames]
    dsets = dict([(d.name, d) for d in datasets])
from datasets import datasets, allGroups, allDatasets, activeDatasets
import ROOT as r
r.gROOT.SetBatch(1)

colors = {
    'ttbar': r.kRed + 1,
    'zjets': r.kOrange - 2,
    'wjets': r.kBlue - 2,
    'diboson': r.kSpring + 2,
    'singletop': r.kAzure - 4,
    'multijet': r.kGray,
    'fake': r.kGray,  # just another name for the same thing
    'heavyflavor': r.kViolet + 1
}

allGroups, allDatasets, datasets = allGroups(datasets), allDatasets(
    datasets), activeDatasets(datasets)


def guessGroupFromFilename(filename=''):
    "Guess group from filename, either merged or un-merged"
    print 'guessGroupFromFilename obsolete, use guessSampleFromFilename'
    group = next((g for g in allGroups if any(e in filename
                                              for e in [g + '_', g + '.'])),
                 None)
    group = group if group else next(
        (d.group for d in datasets
         if d.name + '.' in filename or d.name + '_' in filename), None)
    return group


def guessSampleFromFilename(filename=''):