PyROOT: Finding local minima/maxima in a TGraph


Please read tips for efficient and successful posting and posting code

ROOT Version: ROOT 6.18/04
Platform: Debian GNU/Linux 10 (buster)
Compiler: /interpreter Python 3.6.9 [GCC 7.3.0] on linux

Hello,

I am aiming at finding the coordinates of the local minima and maxima of a TGraph.

Found this post :

How can I translate the answer by @moneta into PyROOT?

Thanks for looking into it!


Hi,

This should work (note the graph is just a dummy):

import ROOT

xmin = 0
xmax = 10

graph = ROOT.TGraph()

def myfun(x, p):
    return graph.Eval(x[0])

f = ROOT.TF1("f", myfun, xmin, xmax, 0)

Here you can find more examples of using Python callables to construct TFX objects:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.