import ROOT
ROOT.gInterpreter.ProcessLine(
'auto x = RooRealVar("x", "x", -3, 3); auto myerf = RooFit::bindFunction("erf", TMath::Erf, x)'
)
x = ROOT.x
erf = ROOT.myerf
erf.Print()
frame1 = x.frame(Title="TMath.Erf bound as ROOT.RooFit function")
erf.plotOn(frame1)
ROOT.gInterpreter.ProcessLine(
'auto x2 = RooRealVar("x2", "x2", 0, 0.999);\
auto a = RooRealVar("a", "a", 5, 0, 10);\
auto b = RooRealVar("b", "b", 5, 0, 10);\
auto beta = RooFit::bindPdf("beta", ROOT::Math::beta_pdf, x2, a, b)'
)
x2 = ROOT.x2
a = ROOT.a
b = ROOT.b
beta = ROOT.beta
beta.Print()
data = beta.generate({x2}, 10000)
beta.fitTo(data)
frame2 = x2.frame(Title="ROOT.Math.Beta bound as ROOT.RooFit pdf")
data.plotOn(frame2)
beta.plotOn(frame2)
fa1 = ROOT.TF1("fa1", "sin(x)/x", 0, 10)
x3 = ROOT.RooRealVar("x3", "x3", 0.01, 20)
rfa1 = ROOT.RooFit.bindFunction(fa1, x3)
rfa1.Print()
frame3 = x3.frame(Title="TF1 bound as ROOT.RooFit function")
rfa1.plotOn(frame3)
c = ROOT.TCanvas("rf105_funcbinding", "rf105_funcbinding", 1200, 400)
c.Divide(3)
c.cd(1)
ROOT.gPad.SetLeftMargin(0.15)
frame1.GetYaxis().SetTitleOffset(1.6)
frame1.Draw()
c.cd(2)
ROOT.gPad.SetLeftMargin(0.15)
frame2.GetYaxis().SetTitleOffset(1.6)
frame2.Draw()
c.cd(3)
ROOT.gPad.SetLeftMargin(0.15)
frame3.GetYaxis().SetTitleOffset(1.6)
frame3.Draw()
c.SaveAs("rf105_funcbinding.png")