Non-Convergence of Fit

Dear ROOT Experts,

I am trying to fit a PDF to data using RooFit to extract the PDF parameters (8 parameters). When I run the fit on toy data (Left-Plot), it works properly, but when I use the real data (2 inputs :x, costheta), the fit is not good (Right-Plot), as shown by the plots below. I’m not quite sure what the issue could be. Could it be related to parameter adjustments? I don’t know the physical values of each of these parameters.

Here is the code i’m using
Rootfit_Test.cc (16.7 KB)

Thanks in advance,
Mustapha

Hello @Mustaphaa,

just looking at the formulae in your file, it is hard to follow how the PDF is supposed to look like. It certainly doesn’t seem to follow the data with the current values of the parameters.

What does the fitter say about this PDF? Could it be that the parameters have strong correlations (i.e. moving one can be compensated by moving another)?
It could also be that the straight line we see is a region that the fitter has trouble coming out of. It would suggest to make the PDF as simple as possible, and look for starting values that roughly follow the data. Then you fit and see where it goes. You can add complexity to the PDF later once you know good starting values.

Hi @StephanH,

Indeed the PDF is a little bit complicated , this is the likelihood how it is defined :

for the output of the fitter is like this
Minuit2Minimizer : Valid minimum - status = 0
FVAL = 88344.7639211591886
Edm = 0.000152453542378743086
Nfcn = 891
gamma1 = -0.9 +/- 0.00202508 (limited)
gamma2 = -0.5 +/- 0.00362778 (limited)
gamma3 = -0.9 +/- 0.000592726 (limited)
gamma4 = 0.563283 +/- 0.00604722 (limited)
gamma5 = -0.5 +/- 0.000338502 (limited)
gamma6 = -0.5 +/- 0.000302322 (limited)
gamma7 = -0.5 +/- 0.000203322 (limited)
gamma8 = 4 +/- 0.00069419 (limited)
Info in : Minuit2Minimizer::Hesse Using max-calls 4000
Info in : Minuit2Minimizer::Hesse Hesse is valid - matrix is accurate
[#1] INFO:Minimization – RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization
[#1] INFO:Plotting – RooAbsReal::plotOn(GenPdf) plot on x integrates over variables (costheta)
[#1] INFO:NumericIntegration – RooRealIntegral::init(GenPdf_Int[costheta,x]) using numeric integrator RooAdaptiveIntegratorND to calculate Int(x,costheta)
[#1] INFO:NumericIntegration – RooRealIntegral::init(GenPdf_Int[costheta]_Norm[costheta,x]) using numeric integrator RooIntegrator1D to calculate Int(costheta)
[#1] INFO:Plotting – RooAbsReal::plotOn(GenPdf) plot on costheta integrates over variables (x)
[#1] INFO:NumericIntegration – RooRealIntegral::init(GenPdf_Int_Norm[costheta,x]) using numeric integrator RooIntegrator1D to calculate Int(x)

By trying to inspect the PDF and considering, for example, 1 or 2 parameters, the fit on the costheta variable changes,
but for the x variable, there is no effect. Essentially, my likelihood depends on x and costheta,
so all the functions depend on both x and costheta. However, in the functions, costheta is explicitly defined, in contrast to x.
Therefore, I am wondering whether this is the reason why the fit on x remains unchanged.

For example the function :
RooFormulaVar FDZ(
“FDZ”,
"C_F1_DZ * "
"(F - "
"H1) * (1 - 3 * pow(costheta, 2)) - "
"C_F1_DZ * "
"G * (1 + pow(costheta, 2)) - "
"2 * C_F4_DZ * "
"(F + "
"G - "
“H1)*costheta”,
RooArgList(x,costheta, H1,G,F,C_F1_DZ, C_F4_DZ
)
);

The dependence on x is encoded in the functions G, H1, and H2.

@jonas do you see what the problem could be?

I see formula vars like this there:

// Omega PLus -------------------------
RooFormulaVar omega_plus(
    "omega_plus",
    "((r < B) ? ((x >= B*r && x < r) ? (1 - r) : "
    "              (x >= r && x < B) ? (1 - x) : "
    "              (x >= B) ? (1 - x) : 0) : 0)",
    RooArgList(r, B) 
);

It attempts to use x, but it’s not declared in the list of dependencies. How does it even compile?

Maybe if the you declare all the dependencies in the RooFormulaVar correctly, it will work?

It’s strange that the code didn’t trigger a warning about missing dependency on x. I have opened a ticket to remind us to fix it:

Sorry for the inconvenience.