Hello,
I am trying to plot NLL and ProfileLL. I have Extended Maximum Likelihood Model(Nsig * gauss + Nbkg* poly) and then I multiplied my model with Constraints(gauss pdf basically) and fit data with constraint model. But while ploting NLL and ProfileLL i am getting warning messages that “Second derivative zero for parameter1 , MNHESS FAILS AND WILL RETURN DIAGONAL MATRIX.” and then i got some weird matrix.

Also i noticed that if i do fitting with model without constraints terms, then i don’t get these messages. I don’t know what is going wrong when i added constraint terms.

I have attached my code and also some message’s screenshots. I shall be very thankful, if someone could help me with this.

There is a fundamental problem with your model. You have your Gaussians for the constraints, but you leave the parameters of the constaints floating in the fit (offset_mean, offset_sigma, sigma_mean, sigma_sigma, eff_mean, and eff_sigma). This is not how constraints work usually. Normally, the constraint parameters are fixed by auxiliary measurements and you can use RooConst (see example in this tutorial). Having the parameters of the constraint distributions floating means no constraints at all, so you get a weird fit.

Let me also direct your attention to this warning:

[#1] INFO::Minization -- RooProdPdf::getConstraints(model) omitting term
err_err as constraint term as it does not share any parameters with the
other pds in product. To force inclusion in likelihood, add an explicit
Constrain() argument for the target parameter.

I think that’s why you get the errors for parameter1 (err in your case). You have your err_eff Gaussian that is not used in any other component of the model, and all its parameters are floating. That’s not meaningful at all

To summarize:

You have fix the parameters of the constraint distributions

You should remove the eff_err component from the model, because the eff parameter is not used in neither the signal nor the background component (or maybe your were missing some component of your model for which you intended to use the eff parameter?)

I hope this gives you come ideas to fix your fit! Please let me know if you have any further questions or if something was unclear.

Thank you very much for your help. I did changes that you recommended and it worked But i still have a question.

I fixed all the parameters of constraints and remove efficiency constraint at the moment but i’m confused with this post RooStats: Change of Constraint does not change Profile Likelihood Plot . As my work is somehow similar to that and in this post moneta recommended to stay “sigma” parameter floating.

Should i also leave “sigma” floating and also parameter “mean” ?

you were fixing too many parameters here, so now I’m gonna recommend you the same as @moneta in that other post

I was saying that the variables defining the constraint distributions need to be fixed, which are offset_mean, offset_sigma, sigma_mean, and sigma_sigma.

But you should not fix the parameters of your signal model, which are offset, mean, and sigma. otherwise you have a fit with zero parameters.

Also, it appears to me that your mean and offset parameters are completely redundant: they are only used for the mean_offset sum, so they are 100 % correlated. However, your constraint applies to the offset parameter, so I think you want to un-fix the offset parameter, but keep the mean parameter fixed. It doesn’t make sense to have a constraint on a parameter that is anyway fixed.

Otherwise, the value of offset will just converge to the mean of its constraint distribution and only the mean parameter will be used to fit the data. Then it would be just an unconstrained fit.

So in conclusion: you need to un-fix offset and sigma now to get a meaningful model for fitting, and fix mean. If I guess your intentions right of wanting to constrain both the mean and sigma of the signal Gaussian.

I hope this helps, please let me know if something is unclear of if you have further questions!
Jonas