PDF does not support extended maximum likelihood

Dear all,
I am facing some issues while trying to fit a distribution using RooFFTConvPdf. I am trying to convolve a parabola (exhibiting a maximum) defined using RooGenericPdf with Gassian. The snippet of code I used is as follows:

RooRealVar a("a", "a", -0.15,-0.18,-0.13);  // Lower end point of the parabola
RooRealVar b("b", "b", 0.15,0.10,0.17); // Upper end point of the parabola
RooRealVar eps("eps", "eps", 0.68,0.01,2); // Relative heights of the lower and upper peak

RooGenericPdf step_func("step_func", "(@0 >= @1 && @0 <= @2) ? 1.0 : 0.0", RooArgList(dE,a,b));

RooRealVar sigma("sigma", "sigma", 0.02,0.015,0.025);
RooRealVar mean("mean", "mean", -0.21,-0.23,-0.19);

// Create the parabolic function
RooGenericPdf parabola("parabola", "parabola", "((dE - a)*(dE - b)) * (((1-eps)/(b-a))*dE + ((b*eps -a)/(b-a)))", RooArgList(dE, a, b, eps));

// Multiply the parabola with the step function to limit the range
RooProdPdf limited_parabola("limited_parabola", "Limited Parabolic Function",
                            RooArgList(parabola, step_func));

//Create the Gaussian resolution function
RooGaussModel gauss("gauss", "Gaussian resolution model", dE, mean , sigma);

//convolution
RooFFTConvPdf par_gauss{"par_gauss", "par_gauss", dE, limited_parabola,gauss};

But the fit fails giving the following errors:

[#0] ERROR:InputArguments -- par_gauss: this PDF does not support extended maximum likelihood
RooAbsMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (-inf) to force MIGRAD to back out of this region. Error log follows.
Parameter values: 	a=-0.173084	b=0.15	eps=0.68	mean=-0.21	sigma=0.02
RooNLLVar::nll_par_gauss_data[ parameters=(a,b,eps,mean,sigma) ]
     function value is NAN @ parameters=(a = -0.173084 +/- 0,b = 0.15 +/- 0,eps = 0.68 +/- 0,mean = -0.21 +/- 0,sigma = 0.02 +/- 0)
RooGenericPdf::parabola[ actualVars=(dE,a,b,eps) formula="((x[0] - x[1])*(x[0] - x[2])) * (((1-x[3])/(x[2]-x[1]))*x[0] + ((x[2]*x[3] -x[1])/(x[2]-x[1])))" ]
     p.d.f value is less than zero (-0.009623), trying to recover @ actualVars=(dE = -0.124994,a = -0.173084 +/- 0,b = 0.15 +/- 0,eps = 0.68 +/- 0)
     p.d.f value is less than zero (-0.016116), trying to recover @ actualVars=(dE = -0.0832243,a = -0.173084 +/- 0,b = 0.15 +/- 0,eps = 0.68 +/- 0)
     p.d.f value is less than zero (-0.003291), trying to recover @ actualVars=(dE = -0.157701,a = -0.173084 +/- 0,b = 0.15 +/- 0,eps = 0.68 +/- 0)
     p.d.f value is less than zero (-0.003980), trying to recover @ actualVars=(dE = -0.154366,a = -0.173084 +/- 0,b = 0.15 +/- 0,eps = 0.68 +/- 0)
     p.d.f value is less than zero (-0.003930), trying to recover @ actualVars=(dE = -0.154605,a = -0.173084 +/- 0,b = 0.15 +/- 0,eps = 0.68 +/- 0)
     p.d.f value is less than zero (-0.004142), trying to recover @ actualVars=(dE = -0.153575,a = -0.173084 +/- 0,b = 0.15 +/- 0,eps = 0.68 +/- 0)
     p.d.f value is less than zero (-0.005856), trying to recover @ actualVars=(dE = -0.14504,a = 
    ... (remaining 2038 messages suppressed)

Warning in <Minuit2>: MnHesse 2nd derivative zero for parameter a ; MnHesse fails and will return diagonal matrix
Warning in <Minuit2>: Minuit2Minimizer::Hesse Hesse failed - matrix is not valid
Warning in <Minuit2>: Minuit2Minimizer::Hesse 3
Warning in <ROOT::Math::Fitter::CalculateHessErrors>: Error when calculating Hessian

I deeply appreciate any help in understanding and solving this issue. Thank you in advance.

Best regards,
Ansu
Forum.pdf (27.0 KB)

Hi @Ansu!

I think you are missing an overall minus sign in the definition of your parabola. I would also simplify the expression for the parabola a bit.

But the main problem is that your RooGenericPdf for the parabola is not positive for the whole definition range of dE. You’re attempting to fix this problem my multiplying with a step function via RooProdPdf, yes, but this is not allowed. The RooProdPdf can only multiply pdfs. The step function is not actually a pdf but a function (as the name says), and the parabola can’t be used as a pdf either because it is always negative somewhere. You are “forcing” it to be a pdf with the “RooGenericPdf” class to make the compiler happy, but it’s not really a pdf. The usecase of the RooProdPdf is when you fit multiple observables at the same time, and you’re multiplying well-defined pdfs for different observables.

In you case, you should do something different. It would be best if you directly define the limited_parabola as a RooGenericPdf that includes the step function, so it can never become negative:

RooRealVar dE{"dE", "dE", -0.4, 0.2};

RooRealVar a("a", "a", -0.15,-0.18,-0.13);  // Lower end point of the parabola
RooRealVar b("b", "b", 0.15,0.10,0.17); // Upper end point of the parabola
RooRealVar eps("eps", "eps", 0.1,0.01,2); // Relative heights of the lower and upper peak

RooRealVar sigma("sigma", "sigma", 0.02,0.015,0.025);
RooRealVar mean("mean", "mean", -0.21,-0.23,-0.19);

// Create the limited parabolic function
RooGenericPdf limited_parabola("parabola", "parabola",
        "dE >= a && dE <= b ? -(dE - a)*(dE - b) * (x - a - eps * (x - b))/(b-a) : 0.0",
        RooArgList(dE, a, b, eps));

//Create the Gaussian resolution function
RooGaussModel gauss("gauss", "Gaussian resolution model", dE, mean , sigma);

//convolution
RooFFTConvPdf par_gauss{"par_gauss", "par_gauss", dE, limited_parabola,gauss};

I hope this helps!

Cheers,
Jonas

Ah yes, and if you want your pdf to support extended likelihood fits, you have to wrap in in a RooAddPdf or RooExtendedPdf that makes also a prediction on the expected number of events, as explained in this tutorial:
https://root.cern.ch/doc/master/rf202__extendedmlfit_8C.html

Dear @jonas ,
Thanks a lot for the reply. I tried your approach of directly defining the limited_parabola as a RooGenericPdf that includes the step function. But this doesn’t seem to solve the issue, the fit is still failing, and HESSE and MIGRAD are giving failed status.

I am attaching the pdf file of the roofit output and the fit plot obtained. I request you to please look into it. I really appreciate any help you can provide—many thanks for considering my request. I am also attaching my code here.
fit.C (5.0 KB)

Also pasting a small snippet of output here:
fit_output.pdf (152.9 KB)
Forum2.pdf (27.1 KB)
fit.C (5.0 KB)


RooAbsMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (-inf) to force MIGRAD to back out of this region. Error log follows.
Parameter values: a=-0.060744 b=0.046 eps=0.7 mean=-0.213 sigma=0.011
RooNumConvPdf::par_gauss[ gauss(dE) (*) limited_parabola(dE) ]
getLogVal() top-level p.d.f evaluates to zero @ !origVar=dE=-0.337412, !origPdf=gauss=6.05395e-27, !origModel=limited_parabola=0


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.