TF1::GetExpFormula equivalent in RooFit?

I’ve been searching for an equivalent for TF1::GetExpFormula in RooFit but did not find any.
Is it possible to get a string out of a RooFit pdf (generic, abs, Chebychev, Bernstein, etc.), moreover, is it possible to expand the string like it is done via option “P” in GetExpFormula ?
I have tried it via TF1* f=(TF1*)pdf->asTF(…); TString formula = f->GetExpFormula(); with/without the “P” option but it is returning an empty string.
This should be possible for analytical functions which can be explicitly written as a string (even the Bernstein’s and the Chebychev’s etc, not only user-defined generic pdf’s which are constructed from strings), no ?
Any help would be appreciated !


I agree that it would be nice to have this, but it is not trivial to have. The functions in RooFit are implemented not via an expression but via C++ code, and it is not trivial to extract a formula expressions from code which can be very complicated.
The functionality is available in TF1 only from functions wich are built from a TFormula (i.e. an expression string representing the function) and not from code.
For this reason the TF1 you are getting from RooFit are based on code (i.e. on the RooAbsPdf or RooAbsReal implementations) and cannot be converted easy in a string.

Best Regards


Hi Lorenzo,
Thanks for the prompt reply.
What about RooGenericPdf where you can construct the non-normalized pdf from a string expression ?
For more complex pdf’s e.g. Chebychev, I agree it is much more difficult but it is more on the variable definition side rather than on the pdf itself, no ?

For a RooGenericPdf, the expression is available via RooGenericPdf::formula.GetExpFormula().
For the other classes (e.g. RooChebychev, RoOPolynomial, etc…) one would need to implement it.