26 Find peaks in a list of data by looking at first derivative
30 Initialise the peak finder
32 self.
fit = ROOT.TF1(
"fit",
"[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x", 0., 1.)
35 return [data[i+1]-data[i]
for i, x
in enumerate(data[1:])]
39 Find the error on the peak estimation based on a linear fit to the
47 for peak
in peak_list:
48 x_min = max(peak-delta_index, 0)
49 x_max = min(peak+delta_index+1, len(derivative))
50 x_list = range(x_min, x_max)
51 y_list = derivative[x_min:x_max]
52 graph = ROOT.TGraph(len(x_list))
54 self.fit.SetParameter(i, 0.)
56 self.fit.FixParameter(i, 0.)
57 self.fit.SetRange(min(y_list), max(y_list))
58 for i, x
in enumerate(x_list):
60 graph.SetPoint(i, y, x)
61 graph.Fit(self.
fit,
"NO")
64 canvas = common.make_root_canvas(
"derivatives")
67 hist, graph = common.make_root_graph(
"name", x_list,
"", y_list,
"")
69 graph.SetMarkerStyle(6)
73 canvas = common.make_root_canvas(
"values")
76 hist, graph = common.make_root_graph(
"name", x_list,
"", data[x_min:x_max],
"")
78 graph.SetMarkerStyle(6)
81 peak_with_errors.append([self.fit.GetParameter(0),
82 self.fit.GetParError(0)])
83 return peak_with_errors
88 Find peaks in the data
92 for i, x
in enumerate(derivative[1:]):
93 if derivative[i] > 0.
and derivative[i+1] < 0.:
def find_peak_errors_derivative
Find the error on the peak estimation based on a linear fit to the derivative.
def find_peaks
Find peaks in the data.
def __init__
Initialise the peak finder.
Find peaks in a list of data by looking at first derivative.
Deprecated accessor to xboa.common module.