I am trying to write a code that has multiple pdf’s and want to be able to fit them to data and plot the background model along with plot. Including the appropriate snippet:
I do not see where you created the data Python object. Python is assuming it is a string, which does not have the method for plotting. Maybe you meant data_RooDataSet.plotOn(frame)?
you still need a way to get a hold of the Python object later, as it’s not created automatically
# not quite sure if this is what you want, but something similar to what's below
bkg_exp_pdf = ROOT.RooDataSet( "bkg_exp_pdf", "bkg_exp_pdf", ROOT.RooArgSet( w.var( "tp_mass" ) ) )
bkg_exp_pdf.plotOn(frame)
That is, the name given to the factory does not create the Python object by itself, you have to create it.
That is also why you needed data_RooDataSet before instead of just data, since Python didn’t know about the object named data, since you had created it with the other name. Hope that helps.