sPlot in RooFit with a non-RooRealVar parameter

Dear RooFit experts

I want to do a sPlot with a RooFomularVar parameter:

RooFormulaVar nBkgc=new RooFormulaVar(“nBkgc”, “nBkgc”, "@00.048",

sData = new RooStats::SPlot(“sData”,“An SPlot”,
*t_t_pData, MassPdf, RooArgList( *nSig, *nBkg ,*nBkgc) );

But the sPlot need a RooRealVar:

Exception: SPlot::SPlot(sData) input argument nBkgc is not of type RooRealVar

What can I do?

Thank you


One solution could be to prepare a new dataset with the nBkgc variable added and then open/import this new dataset with nBkgc declared as a RooRealVar. As an intermediate step you might have to save the dataset/tree (use RooAbsData::tree()) to file and import back. That may not be the best solution but it should work.


– Gregory

Dear Gregory,

Thank you for your reply.

I don’t quite understand your method.

In my opinion, the nBkgc is the fit parameter of the Masspdf.

It may have some relationship with the Masspdf, which is used by sPlot.

If we can store it in a new DataSet, I think we can also store it with a new RooRealVar.

Copuld you please explain more?



Well you’re right; I didn’t realise nBkgc is a fit parameter and not an observable variable and then my trick will not be applicable to your issue.

– Gregory