Minimizer Parameters exceeding SetVariableLimit max in Minuit2

Hello fellow ROOTers, I’m using ROOT 6.12 and am having an issue with Minuit2. When running a minimization program on a set of root files the parameters will exceed the maximum allowed value specified in the SetVariableLimit and goes to nan. This only happens with two sets of root files and not a third set.

There is nothing really different between the sets except that the two sets I’m having issues with have a couple of extra branches in their TTrees.

Here is the code that initializes the fit:

void minimize()
{
  string minName = "Minuit2";
  string algName = "Fumili2";//changed from Fumili2
  ROOT::Math::Minimizer *min = 
    ROOT::Math::Factory::CreateMinimizer(minName, algName);
  
  min -> SetMaxFunctionCalls(1000);
  min -> SetTolerance(1.0);
  min -> SetPrintLevel(1);

  ROOT::Math::Functor minWrapper(&min3, 5);//par4 = mass scale
  double step[5]  = {0.01, 0.01, 0.01, 0.01, 0.01};
  double start[5] = {0.3, 0.3, 0.3, 0.3, 1.0};

  min -> SetFunction(minWrapper);

  min -> SetVariable(0, "dy"  , start[0], step[0]);
  min -> SetVariable(1, "jpsi", start[1], step[1]);
  min -> SetVariable(2, "psip", start[2], step[2]);
  min -> SetVariable(3, "jmix", start[3], step[3]);
  min -> SetVariable(4, "mass scale", start[4], step[4]);

  min -> SetVariableLimits(0, 0.05, 0.45);//.02to.1
  min -> SetVariableLimits(1, 0.05, 0.45);
  min -> SetVariableLimits(2, 0.05, 0.45);
  min -> SetVariableLimits(3, 0.05, 0.45);
  //min -> SetVariableLimits(4, 0.9, 1.1);
  min -> SetFixedVariable(4, "mass scale", 1.0);

  nF = 4;

  min -> Minimize();

Any help is greatly appreciated.

1 Like

Hello @scottmar1054,

setting limits on fit variables can always be tricky if the fit really wants to go towards or over the limit.

Some ideas:

  • Could it be that your dataset has outliers or broken entries?
  • Does it work when you remove the limits on the relevant parameters? Does it make sense that the fit converges to a specific minimum?
  • Is the fit function well defined?
  • Maybe two or more of your parameters are highly correlated, and it is therefore impossible to find a good minimum? In this case you should re-parametrise.
  • If you have to enforce limits, you could impose a constraint using a Lagrange multiplier, i.e., you could penalise deviating from the allowed range. This is not a brute-force limit. It is softer, and therefore more nice to the minimiser.

Thanks. I figured it out. My fitting function was dividing by zero, some of the bins had no events and hence no error, and it was returning -nan. I did not catch it due to couting a different chisq measurement.

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