# Linear combination of RooRealVar as a pdf parameter

Dear experts,

Is it possible to define a linear combination of RooRealVar and pass that as the parameter of a pdf? To be more specific, I was thinking about a log-likelihood miminization like the following:

// These are the parameters to be minimized.
RooRealVar param1(“param1”,“param1”,0,-1000,1000)
RooRealVar param2(“param2”,“param2”,0,-1000,1000)
RooRealVar param3(“param3”,“param3”,0,-1000,1000)
RooRealVar param4(“param4”,“param4”,0,-1000,1000)

// Combine these in a linear combination.
RooRealVar lin_comb = aparam1 + bparam2 + cparam3 + dparam4;

RooRealVar x(“obs”,“obs”,0,100);

// Pass that linear combination as the mean of the Poisson PDF
RooPoisson model(“poisPdf”,“poisPdf”,x, lin_comb);

RooDataSet* data = some data.

RooAbsReal* nll = model.createNLL(*data, NumCPU(2));
RooMinuit roomin(*nll);

Thank you very much.

Kind regards,

Pim

Hi Pim,

there are multiple ways, but a simple one is RooFormulaVar

``````RooFormulaVar formula("formula",
"0.1 * param1 + 0.2 * param2 + ...",
RooArgSet(param1, param2, ...));
``````

will do. Variables in the formula are identified by the name you give as first argument.

Thanks!

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