Esempio n. 1
0
 def read(self, variables, weights, cut, files=None):
     if files is None:
         files = self.files
     return read_files(filenames=files,
                       branches=variables + weights,
                       cut=cut,
                       treename=self.tree_name)
Esempio n. 2
0
def draw(order):
    if order == 'nlo':
        f = f_nlo
        weightstr = tTIMES('normalizedWeight', nlo_corrections[args.process])
    else:
        f = f_lo
        weightstr = 'normalizedWeight'
    cutstr = tAND(selections[args.selection], proc_cuts[args.process])

    h = hbase.Clone('h_' + order)
    xarr = read_files([f], [ptstr, weightstr], cutstr, treename='Events')
    draw_hist(h, xarr, [ptstr], weightstr)
    print order, h.Integral(), cutstr

    return h
Esempio n. 3
0
            branches.setdefault(cat + '_hbb1', []).extend(
                [add_idx(x.replace('[]', '%i' % i), 1) for i in xrange(5)])
        elif x.endswith('[0]'):
            branches.setdefault(cat + '_hbb0', []).append(x)
        elif x.endswith('[1]'):
            branches.setdefault(cat + '_hbb1', []).append(x)
        else:
            branches.setdefault(cat + '_hbb0', []).append(add_idx(x, 0))
            branches.setdefault(cat + '_hbb1', []).append(add_idx(x, 1))

cut = 'hbbm>0'
all_branches = [cut]
for _, v in branches.iteritems():
    all_branches += v

xarr = read_files(filenames=[infile], branches=all_branches, cut=cut)

# flatten them
flattened = {}
for b in all_branches:
    #    flattened[b] = np.concatenate(xarr[b])
    flattened[b] = xarr[b].astype(float)

# now merge some
data = {}
for cat in branches:
    if cat.startswith('input'):
        data[cat] = np.vstack([flattened[b] for b in branches[cat]]).T
        data['shape' + cat.replace('inputs', '')] = data[cat].shape
    else:
        for b in branches[cat]:
Esempio n. 4
0
 def read(self, variables, weights, cut):
     return read_files(filenames = self.__files, 
                       branches = variables+weights, 
                       cut = cut, 
                       treename = self.tree_name)