Defining a RooGenericPdf from a RooAddition (or any RooAbsReal)

Dear ROOT & stat expert,

I am currently trying to build a generic model that is a sum of linear functions, each defining a subpart of the full model. To avoid discontinuities in the model I define each linear function as a RooFormulaVar (using factory(“expr::”)), which avoid to get each piece separately normalized to 1

Defining every functions and summing them altogether works well, but this create a RooAddition which I want to convert into a PDF. Is there a proper way to do so ? I thought of TFn binding but there are too many parameters to use it I believe (at least 30 parameters)

I tried to do something like :
convert_pdf = workspace.factory(“EXPR::{nam}_Pdf(’{nam}_Func(x,{others})’,x,{others})”.format(nam=name, others=’, '.join(edge_names)) )

but it seems that I forgot or overlooked something, as I get this error :
Error in RooFormula::Compile: Bad numerical expression : “bB_Func(x,bB_0,bB_1,bB_2,bB_3,bB_4,bB_5,bB_6,bB_7,bB_8,bB_9,bB_10,bB_11,bB_12,bB_13,bB_14,bB_15,bB_16,bB_17,bB_18,bB_19,bB_20,bB_21,bB_22,bB_23,bB_24,bB_25,bB_26,bB_27,bB_28,bB_29,bB_30)”
[#0] ERROR:InputArguments – RooFormula::RooFormula(bB_Pdf): compile error

Would one of you have an idea ? Pretty sure it’s a very basic problem but haven’t found anything on that yet

Kind regards,


If you want to convert the sum of many functions in a RooAbsPdf you can also try to use the RooRealSumPdf class.