Hi @Marco1224!
There is no interface in RooFit to directly do this, but you can use ROOT::Math to help you out. There is this ROOT::Math::Functor
class that wraps functions with array inputs, and then RooFit has a class to wrap such functors.
Example:
double myfunction(double const *x, double const *p) {
return x[0] * p[0] * p[1] * p[2] * p[3];
}
RooRealVar x0{"x0", "x0", 1., 0., 10.};
RooRealVar p0{"p0", "p0", 1., 0., 10.};
RooRealVar p1{"p1", "p1", 2., 0., 10.};
RooRealVar p2{"p2", "p2", 3., 0., 10.};
RooRealVar p3{"p3", "p3", 4., 0., 10.};
RooArgList argList{x0, p0, p1, p2, p3};
// The Functor wraps a fuction that only takes one array,
// so you have to pack both arrays into one.
ROOT::Math::Functor functor{
[](double const *x){ return myfunction(x, x + 1); },
1 + 4 // the length of the concatenated array
};
// Wrapping a ROOT::Math::Functor in RooFit is easy
RooFunctorBinding rooFunc{"roo_func", "roo_func", functor, argList};
Just make sure the ROOT::Math::Functor
doesn’t get destroyed before the RooFunctorBinding, because the binding only owns a pointer to the functor, which you have to manage yourself.
I hope this helps you with your work!
Cheers,
Jonas