3 from array
import array
6 def list2hist(xs, ys, name="anonymous", title=""):
8 Create a ROOT.TH1I with xs as bins (low edges) and ys as their content
9 name and title will be used for the new histogram
11 h = ROOT.TH1I(name, title, len(xs), array(
'd', xs))
12 for i, y
in enumerate(ys):
13 h.SetBinContent(i+1, y)
19 Read points from histogram h into two lists (x and y coordinates)
20 Format is chosen such that matplotlib.pyplot.step() can be used for plotting
21 hence (x, y) == (low edges, contents)
23 tmp = ((h.GetBinLowEdge(i+1), h.GetBinContent(i+1))
for i
in range(h.GetNbinsX()))
30 Evaluate the TF1 tf for all values in xs, return list of y values
32 return [tf.Eval(x)
for x
in xs]