Very quick implementation of spline in RooFit, using ROOT TSpline. It supports splines of order 3 or 5. It also support interpolation in the log-space (x or y), for example exp(spline({x0}, {log y0})), useful when you have something (as xsections) that is more similar to exponentials than polynomials.
import ROOT
ROOT.gROOT.ProcessLine('.L RooSpline.cxx+')
def build_spline(name, title, x, x0, y0, order=3, logx=False, logy=False):
x0vector = ROOT.vector("double")()
y0vector = ROOT.vector("double")()
for xx in x0:
x0vector.push_back(xx)
for yy in y0:
y0vector.push_back(yy)
return ROOT.RooSpline(name, title, x, x0vector, y0vector, order, logx, logy)
x = ROOT.RooRealVar('x', 'x', 0, 5)
spline = build_spline("myspline", "my spline", x, [1, 2, 3], [10, 20, 50])
frame = x.frame()
spline.plotOn(frame)