Speeding up fitting to a Landau distribution

Hi,

I am surprised that ([0] exp(-(X - [1])^2 / (2 * [2] ^2) ) is faster than TMath::Gaus. This can happen only if you are using ROOT 5.34 (i.e. CINT) and define the function using a string (i.e. using TFormula).

In 5.34 you would need to write the function in C++ code in order to be fast.
This on the other hand is not needed anymore in ROOT 6.
If you are using the master we are putting speedup in fitting by using multi-threads and also vectorisation in the function evaluation. We don;t have yet a vectorised version for Math::Landau, but we will have it soon.

You should not use Simplex, it is much slower than Migrad. You might need to use Migrad with strategy 0 to be a bit faster if you are not interest in the error evaluation. You might try also to increase slightly the tolerance.
Just do for example before calling TH1.Fit

ROOT::Math::MinimizerOptions::SetDefaultStrategy(0);
ROOT::Math::MinimizerOptions::SetDefaultTolerance(10);

Best Regards

Lorenzo