I’m trying to minimize a PDF using RooFit by running a binned likelihood fit and plotting the NLL with respect to each parameter. However, when running the fit, some variables show strange behavior, such as “EA”.
I have generated some toy data (x, costheta) and then performed the fit on it.
Could you please suggest a solution to this issue? Below is the code I have used: Rootfit_Corrected.cc (5.6 KB)
P.S. The PDF implementation is correct, as I checked the obtained shape!
Hi @Mustaphaa,
I’m having a bit of trouble understanding the issue. Would you mind providing a little more detail?
I’ll add our expert @jonas in the loop.
Basically, my PDF has six parameters. When I run the fit and plot the NLL against the parameters, some of them show a weird behavior where I can’t see the minimum.
For example, the parameter “EA” shows the following behavior:
there are two problem other problems with your script. First is a C++ mistake:
RooDataSet* data = genpdf->generate((x,costheta),500000); # wrong!
It should be with curly braces:
RooDataSet* data = genpdf->generate({x,costheta},500000);
With the round braces, you are using the C++ comma operator in the expression of the first argument to “generate”, which evaluates to the last operand. So you are only generating “costheta”. This will definitely make things wrong!
The second problem is that your fit doesn’t converge. That’s because of numerical problems, which can be alleviated using RooFit::Offset(true) in your createNLL() call (more about what this does in the documentation).
With these two changes, the plot seems to look correct: