Why different fit results on different machine?

Hi all,
this is tricky but I need to understand what to do… I have a root macro which perform a fit of a function with the following code:

RooRealVar p1_0_Sig("p1_0_Sig","p1_0_Sig",0.0001, 1.0);
RooRealVar p1_1_Sig("p1_1_Sig","p1_1_Sig",0.1   ,100.);
RooRealVar p1_2_Sig("p1_2_Sig","p1_2_Sig",0.01  ,100.);
RooGenericPdf f_bkgd_1_Sig("f_bkgd_1_Sig", "f_bkgd_1_Sig","p1_0_Sig * pow((1-mInv/13000),p1_1_Sig)/pow(mInv/13000,p1_2_Sig)",RooArgList(mInv,p1_0_Sig,p1_1_Sig,p1_2_Sig));
auto result_1_Sig = f_bkgd_1_Sig.fitTo(hist_bkgd1_Sig,SumW2Error(true),PrintLevel(printlevel),RooFit::Save(true));
result_1_Sig->Print();
p1_0_Sig.setConstant(kTRUE);
p1_1_Sig.setConstant(kTRUE);
p1_2_Sig.setConstant(kTRUE);

Sometimes I work on a linux system:

Linux ui02.recas.ba.infn.it 3.10.0-1160.80.1.el7.x86_64 #1 SMP Tue Nov 8 15:48:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

with the CERN environment: /cvmfs/sft.cern.ch/lcg/views/LCG_105/x86_64-centos7-gcc11-opt and ROOT 6.30/02

Sometimes I work on my Mac (Sonoma 14.5) with ROOT 6.30/06.

The result of the fit are different (this is just one example… I use this function and other similar function hundreds of times and the overall behavior is really different)

Linux output:

[#1] INFO:NumericIntegration -- RooRealIntegral::init(f_bkgd_1_Sig_Int[mInv]) using numeric integrator RooRombergIntegrator to calculate Int(mInv)
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
[#1] INFO:Fitting -- RooAbsPdf::fitTo(f_bkgd_1_Sig) Calculating sum-of-weights-squared correction matrix for covariance matrix
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization

  RooFitResult: minimized FCN value: 69259.6, estimated distance to minimum: 12.35
                covariance matrix quality: Approximation only, not accurate
                Status : MINIMIZE=0 HESSE=0 HESSE=0

    Floating Parameter    FinalValue +/-  Error
  --------------------  --------------------------
              p1_0_Sig    5.0005e-01 +/-  8.40e-07
              p1_1_Sig    1.4312e+01 +/-  8.82e-01
              p1_2_Sig    4.0143e+00 +/-  2.08e-02

OSX output:

[#1] INFO:NumericIntegration -- RooRealIntegral::init(f_bkgd_1_Sig_Int[mInv]) using numeric integrator RooRombergIntegrator to calculate Int(mInv)
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
[#1] INFO:Fitting -- RooAbsPdf::fitTo(f_bkgd_1_Sig) Calculating sum-of-weights-squared correction matrix for covariance matrix
Warning in <ROOT::Math::Fitter::CalculateHessErrors>: Error when calculating Hessian
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization

  RooFitResult: minimized FCN value: 99020, estimated distance to minimum: 0.000405247
                covariance matrix quality: Not calculated at all
                Status : MINIMIZE=0 HESSE=0 HESSE=300

    Floating Parameter    FinalValue +/-  Error
  --------------------  --------------------------
              p1_0_Sig    5.0005e-01 +/-  4.63e+04
              p1_1_Sig    1.4378e+01 +/-  3.43e+00
              p1_2_Sig    4.0132e+00 +/-  8.05e-02

How do you explain this difference? Just to give you an idea of my problem… on my OSX the fit gives a STATUS=0 only ~60 times on more than 2500 different samples histogram on the Linux system STATUS=0 is more than 1800 over the same 2500 histogram…

Another example…
OSX:

  RooFitResult: minimized FCN value: 98901.3, estimated distance to minimum: 3.64921
                covariance matrix quality: Full, accurate covariance matrix
                Status : MINIMIZE=0 HESSE=0 HESSE=0

    Floating Parameter    FinalValue +/-  Error
  --------------------  --------------------------
              p1_0_Muo    5.0005e-01 +/-  4.63e+04
              p1_1_Muo    1.7899e+01 +/-  3.38e+00
              p1_2_Muo    3.9459e+00 +/-  7.77e-02

LINUX:

[#1] INFO:NumericIntegration -- RooRealIntegral::init(f_bkgd_1_Muo_Int[mInv]) using numeric integrator RooRombergIntegrator to calculate Int(mInv)
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
[#1] INFO:Fitting -- RooAbsPdf::fitTo(f_bkgd_1_Muo) Calculating sum-of-weights-squared correction matrix for covariance matrix
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization

  RooFitResult: minimized FCN value: 69228.4, estimated distance to minimum: 3.10305e-06
                covariance matrix quality: Approximation only, not accurate
                Status : MINIMIZE=0 HESSE=0 HESSE=0

    Floating Parameter    FinalValue +/-  Error
  --------------------  --------------------------
              p1_0_Muo    2.5491e-02 +/-  1.28e+00
              p1_1_Muo    1.7768e+01 +/-  1.08e+00
              p1_2_Muo    3.9490e+00 +/-  2.51e-02

In this case both have STATUS=0 but numbers are different and also errors are different…

Any idea of what’s going on?
Thanks

Attilio

A wild guess, and I could be way off, but maybe it’s a precision issue between different systems/compilers. Looking at the the RooRealVar and RooGenericPdf documentation (e.g. parameters and return values), it seems that they work with doubles, not with Double_t (which is ensured to be portable), so there can be differences. If you are explicitly using int, double, etc I would change them to the ROOT types, but you cannot change what RooRealVar/RooGenericPdf do (unless you change the ROOT code, of course).

Hello,
Thanks for the suggestion… I was using double, float and int but going to root types dosen’t change anything… the difference is still there.

Best

Attilio

Hi Attilio,

Most likely ROOT has been compiled with different optimization settings on the two systems.

Your fit will be non-linear and use many iterations that are guided by comparing floats.
The matrix that you have to invert is most likely ill-defined, very large condition number,
also resulting in different results depending on the precision in the comparisons.

So make sure that ROOT is compiled with the same settings on both systems first.

-Eddy

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