3 import rootpy.ROOT
as ROOT
5 from rootpy.plotting
import Hist
8 def __new__(cls, tree, expression, selection='', options='', hist=None, create_hist=False, **kwargs):
9 obj = tree.Draw(expression, selection, options, hist, create_hist, **kwargs)
11 v1.SetSize(obj.entries)
12 obj._raw_data = np.fromiter(v1, np.float)
18 x.fill_array(y.get_raw_data())
19 x._raw_data = np.append(self._raw_data, y._raw_data)
22 return y.__add__(self)
23 def refill(self, bins=100, range=None, inplace=False):
28 range = (self.lowerbound(), self.upperbound())
29 self_ = Hist(bins, *range)
30 raw_data = self._raw_data
31 self_.fill_array(raw_data)
32 self_._raw_data = raw_data
33 self_.__class__ = UnbinnedHist
35 def unbinned_hist(tree, expression, selection='', options='', hist=None, create_hist=False, **kwargs):
36 obj =
UnbinnedHist(tree, expression, selection, options, hist, create_hist, **kwargs)
37 obj.__class__ = UnbinnedHist
39 def group_eqbin(hist_list, bins=100, range=None, inplace=True):
41 lowerbound =
min(hist.lowerbound()
for hist
in hist_list)
42 upperbound =
max(hist.upperbound()
for hist
in hist_list)
43 range = (lowerbound, upperbound)
44 hist_list = [hist.refill(bins, range, inplace)
for hist
in hist_list]