PDF minimization

Dear ROOT experts,

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!

best regards,

Hi @Mustaphaa,

From what I can see, there are 2 typos in your snippet, frameDA should be replaced with frameEA. Let me know if that fixes your problem.

Cheers,
Dev

Hi @devajith,

Oh yeah, that was a typo because i was changing the name for each parameter separately. However, the issue I’m facing is still there.

best,

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.

Cheers,
Dev

Hi @devajith

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:

but other parameters like “EV” shows a better behavior:

So I’m not quite understanding the reason behind this. Is it due to the range of param being considered or something else?

best

Hi @Mustaphaa,

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:

Dear @jonas

Thank you very much for the suggested solution!

Best,
Mustapha