Fix PDF returned by some function


For now, I have some function which can return one PDF. For example,

RooAbsPdf* myPdf = some_function();

How do I fix this pdf (called myPdf) if I don’t know any information of parameters inside “myPdf” ? Namely, can any member function or tricky method do

myPdf -> “fix()” ?


Dear Youying,

By ‘fix’ you mean fixing parameters?
Can you please provide a detailed example of what you want achieve?

G Ganis

Hi Ganis,

Yes, ‘fix’ means “fix all parameters inside this pdf returned by some function” to avoid these parameters floating. Because some pdf returned by some function can not be fixed by using


can any other idea achieve this if we don’t use “setConstant()” ?



param1.setConstant(kTrue) should fix the parameter of your PDF. If it does not work it means the reference you have to the RooRealVar points to a copy of the one stored in the PDF.
A possible solution is in this case to retrieve it directly from the pdf, by doing for example

auto vars = pdf->getVariables(); auto p = (RooRealVar*) vars->find(param1.getName() ); p->setConstant(kTrue); delete vars;



Thank you very much, Lorenzo!


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