RooBernstein in python

Dear experts,

I am trying to create a second order Bernstein pdf in my workspace and start with creating RooRealVar, followed by using the factory tool of workspace “w”. " tp_mass " is my variable of choice
Here is the code snippet:

    bern2_p0 = ROOT.RooRealVar("bern2_p0","bern2_p0",0.3,-10,10)
    bern2_p1 = ROOT.RooRealVar("bern2_p1","bern2_p1",0.2,-10,10)
    bern2_p2 = ROOT.RooRealVar("bern2_p2","bern2_p2",0.1,-10,10)

   w.factory( "Bernstein:bkg_bern_pdf(tp_mass,{bern2_p0,bern2_p1,bern2_p2})")


This throws me the error -
ERROR:ObjectHandling – RooFactoryWSTool::createArg() ERROR constructing RooBernstein::bkg_bern_pdf: RooAbsArg named bern2_p0 not found

I was able to create exponential and gaussian pdf’s:

w.factory( "Exponential:bkg_pdf(tp_mass, a[-0.5,-2,-0.2])"  )
w.factory( "Gaussian:sig_pdf(tp_mass, mass[125, 110, 130], sigma[4, 2, 10])")

What is the procedure to create Bernstein pdf’s in python with RooFit?

Thanks in advance,
Tanvi

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

Hi! Just in case this is useful to someone, here is the answer.

You need to create the variables inside the RooWorkspace with the factory language:

w.factory("bern2_p0[0.3,-10,10]")
w.factory("bern2_p1[0.2,-10,10]")
w.factory("bern2_p2[0.1,-10,10]")

w.factory( "Bernstein:bkg_bern_pdf(tp_mass,{bern2_p0,bern2_p1,bern2_p2})")

If you create RooRealVars like this, they are independent of the workspace, so the workspace rightfully can’t find them.