12from ctypes
import c_double
23def DrawSmooth(pad, title, xt, yt):
25 vFrame = ROOT.gPad.DrawFrame(0, 0, 15, 150)
26 vFrame.SetTitle(title)
27 vFrame.SetTitleSize(0.2)
30 grxy.SetMarkerColor(ROOT.kBlue)
31 grxy.SetMarkerStyle(21)
32 grxy.SetMarkerSize(0.5)
34 grin.SetMarkerColor(ROOT.kRed)
35 grin.SetMarkerStyle(5)
36 grin.SetMarkerSize(0.7)
43x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 6.0, 6.0, 8.0, 9.0, 10.0])
44y = np.array([1.0, 4.0, 9.0, 16.0, 25.0, 25.0, 36.0, 49.0, 64.0, 81.0, 100.0])
46grxy = ROOT.TGraph(n, x, y)
50xout = np.array([1.2, 1.7, 2.5, 3.2, 4.4, 5.2, 5.7, 6.5, 7.6, 8.3, 9.7, 10.4, 11.3, 13])
53vC1 = ROOT.TCanvas(
"vC1",
"square", 200, 10, 700, 700)
57grin = ROOT.TGraph(n, x, y)
59gs = ROOT.TGraphSmooth(
"normal")
60grout = gs.Approx(grin,
"linear")
61DrawSmooth(1,
"Approx: ties = mean",
"X-axis",
"Y-axis")
65grin = ROOT.TGraph(n, x, y)
67grout = gs.Approx(grin,
"linear", 14, xout, 0, 130)
68DrawSmooth(2,
"Approx: ties = mean",
"",
"")
75 grout.GetPoint(k, vXout, vYout)
76 print(f
"k= {k} vXout[k]= {vXout.value} vYout[k]= {vYout.value}")
79grin = ROOT.TGraph(n, x, y)
82grout = gs.Approx(grin,
"constant", 50, 0, 0, 0, 1, 0.5,
"min")
83DrawSmooth(3,
"Approx: ties = min",
"",
"")
86grin = ROOT.TGraph(n, x, y)
88grout = gs.Approx(grin,
"linear", 14, xout, 0, 0, 2, 0,
"max")
89DrawSmooth(4,
"Approx: ties = max",
"",
"")