Set positive definite for PiecewiseInterpolation object

I’m new to RooFit and trying to make sure a “morphed signal model” created by PiecewiseInterpolation be positive definite. The model is created by calling

w.factory("PiecewiseInterpolation::pi_sig(hf_sig,hf_sig_dn,hf_sig_up,alpha[-5,5])");

where hf_sif, hf_sig_dn and hf_sig_up are the three different HistFunc signal templates for the nominal, -1sigma and +1sigma value of the systematic uncertainty parameter alpha. Now upon calling

w.function("pi_sig")->setPositiveDefinite(kTRUE);

I get the error message

Error: Can't call RooAbsReal::setPositiveDefinite(kTRUE) in current scope ex13.C:43:
Possible candidates are...
(in RooAbsReal)
(in RooAbsArg)
(in RooPrintable)
Error: non class,struct,union object function("pi_sig") used with . or -> ex13.C:43:

If I instead do

PiecewiseInterpolation* pisig = (PiecewiseInterpolation*)w.function("pi_sig");
pisig->setPositiveDefinite();

this works fine. This appears strange to me - I created the object by calling w.factory(“PiecewiseInterpolation…”) so why aren’t the member functions of this class available to this object?

Hi,

setPositiveDefine is a member function of the PieceWiseInterpolation class and not RooAbsReal which is a base class for PieceWiseInterpolation. The RooWorkspace::function(“name”) method return a pointer to RooAbsReal so you need to dynamic cast it to PieceWiseInterpolation.

Best Regards

Lorenzo