I’m trying to use Roofit to fit to a data set I have which can be modelled as a correlated, bivariate gauss. I am quite keen to use bindpdf(TF2* func, RooAbsReal& x, RooAbsReal& y). This is because in reality a bivariate gaussian is just the starting point, and I am using a more complicated, numerical function for modelling our calibration data later. For this I have bound a C++ function to a TF2, hence I am keen to use the TF2 binding rather than (say) the pre-existing RooFit functions or a functional string as outlined in rf103. I’ve read through the manual, rf 103 and rf 105 and I cannot work out how to do this, as ultimately I have x,y and (at least) 6 fit parameters.
The alternative i can see would be to bind the C++ function directly, but as far as I can tell this is limited to 4 parameters (“RooCFunction4Binding.h”).
I’ve clearly missed something, so any help on how to do this would be much obliged!
Thanks in advance,
I managed to solve my problem. Fortunately I could express several of the parts of the more complicated fit using the RooFit Pdfs and multiplying to a 4 parameter bound function that represented the parts that could not. Still, somehow, if one could bind a C++ function with an arbitrary number of parameters, it would be useful - though maybe you can and I just don’t understand how to do this!
n.b One issue I had is that I could not seem to convolve using a RooFormulVar. I am trying to find the anti-correlation angle between two variables (x [phonon] and y [light]). To do this I fit an expected distribution in a rotated plane, using a rotation angle theta, giving a new xprime and yprime. However, this left the observables as RooFormulaVar and not RooRealVar, so I could not use the inbuilt convolution functions, or at least I could not see how to.
There is no standard templated solution for binding functions with >4 parameters.
I could make it of course, but each #parameters requires its own template class
as the number of template parameters can not be variable itself.
It should be relatively easy to write one yourself though. If you have the source code
of your C++ function, one can just embed in a empty RooAbsPdf class that you can
make with RooClassFactory::makePdf() [ see roofit tutorial macro 104 for an example of that ]
If you have a pointer to a function it can also be done relatively easily by copying its inputs
and output forth and back from the RooRealVars that represent these in RooFit. The templated
classes look a bit complicated because they provide a generic templated solution, but if you
write it for a specific function it is straightforward
Concerning your comment on convolutions: this should in principle be possible with RooFFTConvPdf. Have a look at tutorial macro rf210, which convolutes in an angle theta, but represents the output in cos(theta).
Hi there Wouter,
Thanks for getting back to me. Regarding the convolution, I wish to convolve in xprime, which is a function of two observables x and y (as it is a rotation). It seemed to me that tutorial 210 was for a convolution of two functions of psi, a roorealvar, whereas my two functions are of xprime, a rooformulavar. Xprime is not a simple function of x but of x and y, and I could not see how this translates to the tutorial macro.