Something wrong with fit

Hi everybody. I am fitting the sidebands of a histogram (in other words, I exclude a continuous central range in the fitting procedure) several times through a loop. The concerned histogram changes each time as due to different cuts on candidates (features) that fill it. The procedure takes place successfully on and on (so far around 450 times), until it breaks because of a floating point exception. The lines below might hint at the cause of the crash:

#6 ROOT::Fit::FitUtil::<lambda(unsigned int)>::operator()(unsigned int) const (__closure=0x7ffc0cb0e670, i=<optimized out>) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/mathcore/src/FitUtil.cxx:357

#7 0x00007f069c91f9e2 in ROOT::Fit::FitUtil::EvaluateChi2 (func=…, data=…, p=0xefeba90, executionPolicy=ROOT::Fit::ExecutionPolicy::kSerial, nChunks=0) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/mathcore/src/FitUtil.cxx:389

#8 0x00007f069c2aa448 in ROOT::Math::IBaseFunctionMultiDimTempl<double>::operator() (x=0xefeba90, this=<optimized out>) at /build/workarea/sw/20155959/1/BUILD/af8d5672c258f1fe8582f454a42a8ea945655486/ROOT/include/Math/IFunction.h:94

#9 TMinuitMinimizer::Fcn (f=

0x7ffc0cb0e888: 6.9004336992530585e-310, x=0xefeba90) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/minuit/src/TMinuitMinimizer.cxx:253

#10 0x00007f069c29a41e in TMinuit::Eval (flag=4, par=<optimized out>, fval=

0x7ffc0cb0e888: 6.9004336992530585e-310, grad=<optimized out>, npar=<optimized out>, this=0xefaff00) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/minuit/src/TMinuit.cxx:829

#11 TMinuit::mnline (this=0xefaff00, start=<optimized out>, fstart=279907.35598436906, step=0xede5d60, slope=-59825127.620885201, toler=0.050000000000000003) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/minuit/src/TMinuit.cxx:4796

#12 0x00007f069c29cbcf in TMinuit::mnmigr (this=this

entry=0xefaff00) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/minuit/src/TMinuit.cxx:5216

#13 0x00007f069c2a6655 in TMinuit::mnmigr (this=<optimized out>) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/minuit/src/TMinuit.cxx:5070

#14 TMinuit::mnexcm (this=<optimized out>, command=<optimized out>, plist=<optimized out>, llist=2, ierflg=

0x7ffc0cb0f31c: 0) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/minuit/src/TMinuit.cxx:2858

#15 0x00007f069c2ac973 in TMinuitMinimizer::Minimize (this=0x1293fba0) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/minuit/src/TMinuitMinimizer.cxx:558

#16 0x00007f069c927d40 in ROOT::Fit::Fitter::DoMinimization (this=this

entry=0x1293f900, chi2func=chi2func

entry=0x0) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/mathcore/src/Fitter.cxx:809

#17 0x00007f069c928a2a in ROOT::Fit::Fitter::DoMinimization (this=this

entry=0x1293f900, objFunc=…, chi2func=chi2func

entry=0x0) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/mathcore/src/Fitter.cxx:847

#18 0x00007f069c928df8 in ROOT::Fit::Fitter::DoLeastSquareFit (this=this

entry=0x1293f900, executionPolicy=

0x7ffc0cb0f790: ROOT::Fit::ExecutionPolicy::kSerial) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/math/mathcore/src/Fitter.cxx:361

#19 0x00007f069cdf0cac in ROOT::Fit::Fitter::Fit (executionPolicy=

0x7ffc0cb0f790: ROOT::Fit::ExecutionPolicy::kSerial, data=…, this=<optimized out>) at /build/workarea/sw/20155959/1/BUILD/af8d5672c258f1fe8582f454a42a8ea945655486/ROOT/include/Fit/Fitter.h:153

#20 HFit::Fit<TH1> (h1=h1

entry=0xf33bbd0, f1=0x9b2a0c0, fitOption=…, minOption=…, goption=0x7f069f245675 “”, range=…) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/hist/hist/src/HFitImpl.cxx:368

#21 0x00007f069cde6b95 in ROOT::Fit::FitObject (h1=h1

entry=0xf33bbd0, f1=f1

entry=0x9b2a0c0, foption=…, moption=…, goption=<optimized out>, range=…) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/hist/hist/src/HFitImpl.cxx:973

#22 0x00007f069cea5c5d in TH1::Fit (this=0xf33bbd0, f1=0x9b2a0c0, option=<optimized out>, goption=<optimized out>, xxmin=0, xxmax=<optimized out>) at /build/workarea/sw/20155959/1/SOURCES/ROOT/v6-14-04/v6-14-04/hist/hist/src/TH1.cxx:4040

#23 0x00007f069f1ce6f1 in ?? ()

#24 0x0000000000000000 in ?? ()

Any idea anyone?

Thanks in advance

Hi

We would need a running example to reproduce this problem,

Cheers

Lorenzo

Hi, I eventually solved the problem by reducing the number of fits. The problem would manifest itself after roughly 2-3 hours of code running.
Basically, as far as the fitting is concerned, the following simple lines of code (iterated hundreds of times) were involved:

for(i = 0; i < 4; i++)
{
fl->SetParameters(2, -1);
reject = kTRUE;
massinvBkg[i]->Fit(fl,“0B”);
reject = kFALSE;
}

where fl was defined as follows:

Bool_t reject;

Double_t fline(Double_t *x, Double_t *par)

{

if (reject && x[0] > a && x[0] < b)

{

TF1::RejectPoint();

return 0;

}

return par[0]*exp(par[1]*x[0]);

}

Thanks