# Is variable constraint supported?

Dear RooFit users and experts,

I am scanning an invariant mass spectrum using a background+signal model. I would like to introduce a nuisance parameter modelling the amount of spurious signal events induced by an imperfect background model. Assuming the spurious signal is equally present across the entire spectrum, I could construct my model as follows:

``````RooWorkspace* wksp = new RooWorkspace("wksp")
//The background model
wksp->factory("Exponential::bkgModel(x[0.,10.],k[-15.,-100.,0.])")
//The signal model
wksp->factory("BreitWigner::sigModel(x,m[0.5,0.,10.],w[0.1,0.0,10])");
//The gaussian constraint on spurSigSize
wksp->factory("Gaussian::ssConstraint(spurSigSize[0.,-1000.,1000.],0.,10.)");
//The constrained bkg+sig model
wksp->factory("PROD::bkgPlusSigModel(SUM::freeModel(bkgN[500.,0.,1000.]*bkgModel, sum::sigSize(sigN[0.,-1000,1000],spurSigSize)*sigModel),ssConstraint)");
``````

As I understand it, the factory interface will interpret the two numbers `0,10` in the Gaussian constructor as `RooConst` objects, and this indeed works for me. Now, my question is: what if the constraint on `spurSigSize` is tighter at certain signal pole masses? Then the width of the constraint gaussian should be variable:

``````wksp->factory("Gaussian::ssConstraint(spurSigSize[0.,-1000.,1000.],0.,spurSigSpread[10,0,20])");
``````

So I could change the constraint at a whim using `wksp->var("spurSigSpread")->setVal(15)`.
But will RooFit still interpret the last argument as a `RooConst`? If not, is there some other way to implement a variable constraint?

The only alternative I see is to create a new constraint pdf (and hence a new background+signal model) for each pole mass, but this seems rather tedious, especially when scanning a large range of signal hypotheses.

Well this was a big misunderstanding! For the books, I thought `RooConst` referred to a Roo-Constraint , not a Roo-Constant. Since I had never used this class before, I inferred its meaning from the RooFit tutorial on constraints. Anyways, I hope the lines above are helpful for someone. Of course one can use `RooRealVar` arguments to construct a variable constraint, but a “variable RooConst” is a contradiction in terms.

Just a comment. You can define a variable as a RooConst or called RooRealVar->setConstant(true).
For the fitting the two things are equivalent.

Lorenzo

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