We now have a stable version on both the server and the portable. The issue was related to a set of parameters that could not be fitted. It was OK on the server but not on the portable (or vice versa!). We put a statistical test for removing these parameters.
You can close this thread as solved…other questions are coming in a new thread.
Thank you so much for the gang at CERN. You kick ass !
@moneta I have a related problem (different Minuit2 result on different computers), but I’m having trouble debugging it using Minuit2 print level.
On my laptop I have root v6-20-04-23-g95ac5da, while on another machine I have root v6-24-02-2-g0173f51a8c.
I’m using ROOT::Fit::Fitter with a custom chi2 class.
On my laptop, if I do fitter.Config().MinimizerOptions().SetPrintLevel(3); I get the usual detailed output from VariableMetricBuilder at each iteration, while on the other machine I get nothing.
Indeed, I see that in root 6-24 the print logic changed with respect to root 6-20.
I tried to use MnPrint::SetGlobalLevel(3) on the other machine, but it didn’t help.
What is the corresponding line of code to minimize.Minimizer().Builder().SetPrintLevel(3) if I use ROOT::Fit::Fitter instead of MnMinimize?
I attach here an example of a fit using the Fitter class
/// Example of unbinned fit using ROOT
std::vector<double> GenerateData(int nevts) {
// generate 30% with gaussian (signal)
// and 70% with background (exponential)
std::vector<double> v(nevts);
// use in range [0,10]
for ( auto & e : v) {
if (gRandom->Rndm() < 0.3)
e = gRandom->Gaus(5,0.5);
else {
// take into account some events are outside the range
do {
e = gRandom->Exp(10);
} while (e > 10);
}
}
return v;
}
int UnbinFit(int printLevel=0) {
const int nevts = 5000;
auto x = GenerateData(nevts);
// make the dataset for fitting
ROOT::Fit::UnBinData data(x.size());
for ( auto & val : x)
data.Add(val);
// create fit function
auto f1 = new TF1("f1","[fs]*ROOT::Math::normal_pdf(x,[sigma],[mean]) + (1.-[fs])*ROOT::Math::exponential_pdf(x,[tau])/ROOT::Math::exponential_cdf(10,[tau])",0,10);
// set initial fit parameters
f1->SetParameter("fs",0.5);
f1->SetParameter("mean",4);
f1->SetParameter("sigma",1);
f1->SetParameter("tau",0.2);
f1->Print("V");
f1->Draw();
ROOT::Fit::Fitter fitter;
ROOT::Math::WrappedMultiTF1 wf(*f1);
// pass false do not use gradients of TF1 when fitting
fitter.SetFunction(wf, false);
fitter.Config().MinimizerOptions().SetMinimizerType("Minuit2");
fitter.Config().MinimizerOptions().SetPrintLevel(printLevel);
bool ret = fitter.Fit(data);
if (ret)
fitter.Result().Print(std::cout);
else {
std::cout << "Unbinned Likelihood Fit Failed " << std::endl;
return -1;
}
// plot the data in an histogram
auto h1 = new TH1D("h1","h1",100,0,10);
h1->FillN(nevts,x.data(), nullptr);
// plot the data and the function on top normalized to the obsered data
auto normFunc = new TF1("normFunc","[Constant]*f1",0,10);
normFunc->SetParameter("Constant",h1->GetBinWidth(1)*nevts);
h1->GetListOfFunctions()->Add(normFunc);
h1->Draw();
return 0;
}
It could be that you have re-defined, maybe without knowing it, the global Error level of ROOT.
Can you print , before calling fitter.FitFCN the ROOT variable gErrorIgnoreLevel.
It should be -1 by default, if it has an higher value (e.g. >=1000) Info messages are suppressed