ROOT::Fit:Fitter in multithreaded application error:

I am trying to fit a series of vectors with a function utilizing multithreading. Based on previous discussions I have dug up I am using the ROOT::Fit:Fitter methodology to directly fit a vector rather than transforming it into a TH1 and useing the TH1::Fit as I understand that not to be threadsafe. However, I seem to be running into non-threadsafe behavior. Namely if I set the tthreadexecutor to use only one thread the code runs without issue however if I allow it to use two or more threads it seg faults with a common error message of:
“FitConfiguration and Minimizer result are not consistent
Number of free parameters from FitConfig = 5
Number of free parameters from Minimizer = 3”
though other error messages arise at other times.

This is my first venture into multithreaded operations within root and I am clearly doing something wrong, I suspect within the memory management), any recommendations would be greatly appreciated! I have converted my code to run over a locally generated list of vectors (normally I use a ttree input to read the vectors from) so that it may be portable for others to run if they are interested.

test_portable.C (3.3 KB)

Thank you very much!

_ROOT Version: 6
_Platform: ubuntu

Hi @inneedofhelp ,
sorry for the high latency, wee need @moneta here, let’s ping him.


Hi Enrico and @moneta,

Over the past 10 days I have been digging into this quite a bit and was able to resolve the issue by changing the minimization used to GSL as opposed to the default minimizer. To the best I could tell the TMinuit, which I understand to be the default minimizer of ROOT::Fit::Fitter, does not properly handle multithreading therefore I had to swap the minimizer used. I am unsure what aspect specifically about TMinuit is not threadsafe, at least in my application, but replacing it did work.

Ah, right – @moneta can confirm, but I think minuit is 100% not thread safe and minuit2 is supposed to be the thread-safe replacement.

Yes this is correct, TMinuit uses a global function definition therefore is not thread safe.
Minuit2 is thread safe, but you need to be sure that the implementation of the objective function passed by the user to the Fitter is thread safe.
The same will happen with Minuit2 when using the GSL minimiser.

Best regards


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