Fitting small,noisy pulses causes program to hang - stop it!

Hi,

I am trying to fit pulses in order to gain timing and signal information. The fitting occurs within a larger (compiled) program, but I have attached the shortest Root file that will suffice.

Within Root, “.X TraceFit.C”

The first pulse, although small, fits well. Now uncomment one of the other three pulses (together with it’s corresponding pedestal value). Now when trying to fit, an error of the following nature results:

Error: exp param[0]=2339.61 up:709 low:-inf out of range FILE:tracefit.C LINE:3
FCN=526.587 FROM MIGRAD STATUS=CONVERGED 287 CALLS 288 TOTAL
EDM=0 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 100.0 per cent
EXT PARAMETER APPROXIMATE STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 Constant -1.44718e+00 3.75869e-05 3.95026e-02 0.00000e+00
2 Mean -5.25390e+01 8.64552e-04 1.09651e+00 0.00000e+00
3 Sigma -1.41295e+02 8.22045e-04 -1.55098e-03 0.00000e+00
4 Alpha -1.75053e+02 2.44399e-03 -5.88760e+00 0.00000e+00
5 Pedestal -1.98800e+01 fixed
(Int_t)0
*** Interpreter error recovered ***
Error: G__CallFunc::SetArgArray() must be initialized with ‘G__CallFunc::SetFunc(G__ClassInfo* cls,char* fname,char* args,long* poffset)’ first

with the first and last lines being repeated many times.

I know why the fit fails on the latter three pulses: the pulses are noisy and there is little signal present. That is not my main concern. The big problem occurs when running my compiled program which the fitting routine is part of. On these troublesome pulses the program hangs in the fitting process, and never recovers.

Perhaps there is a better solution, but I was thinking along the lines of: Is there some way of detecting when this error occurs and returning a simple TF1 (y=-fPed would be fine)? Most importantly, a way of preventing the program from hanging.

Thanks,

Dave

I use g++, ROOT version 4 (4.00/03), and RedHat 9.
tracefit.C (3.53 KB)

Your function fitfunc is very unstable. I see that fitval may have values
gretater than 10e27.
You should protect the exp against silly values.

Rene