示例#1
0
 def make_ohist(idx, mask, d):
     if (idx, mask) not in d:
         h = utils.NH1(bins=np.linspace(-3,3,20))
         d[(idx,mask)] = h
     else:
         h = d[(idx,mask)]
     h.fill_array(o[m[mask],idx], w[m[mask]])
     h.scale()
     return h
示例#2
0
 def __init__(self, name, binning, fn, classes=[0, 1], 
              weight_fn=None, cut_fn=None, xlabel=None, ylabel=None):
     self._fn = fn
     self._weight_fn = weight_fn
     self._cut_fn = cut_fn
     self.name = name
     self._bins = binning
     self.hists = {c:utils.NH1(binning) for c in classes}
     self.xlabel = xlabel
     self.ylabel = ylabel
     self.classes = classes
示例#3
0
 def __init__(self,
              name,
              binning,
              fns,
              weight_fn=None,
              xlabel=None,
              ylabel=None):
     self._fns = fns
     self._weight_fn = weight_fn
     self.name = name
     self._bins = binning
     self.hists = {x: utils.NH1(binning) for x in fns}
     self.xlabel = xlabel
     self.ylabel = ylabel
示例#4
0
def plot(binning, fn, samples, outpath, xlabel=None, ylabel=None):
    hists = {}
    for s in samples:
        h = utils.NH1(binning)
        if type(fn) == int:
            h.fill_array(s.X[s.vidx, fn], weights=s.W[s.vidx])
        else:
            h.fill_array(fn(s), weights=s.W[s.vidx])
        h.scale()
        hists[s.name] = h

    p = utils.Plotter()
    for i, s in enumerate(samples):
        p.add_hist(hists[s.name], s.name, i)

    _make_parent(outpath)

    p.plot(xlabel=xlabel, ylabel=ylabel, output=outpath)
    p.plot(xlabel=xlabel, ylabel=ylabel, output=outpath + '_logy', logy=True)
    p.clear()
    return hists