It doesn't fit!

I write a program to fit the spectrum of Th232. The program is very big, this is the first part, where I want to fit the background. I attach the file and a little routine read.h that read the file 232Th03.h

The problem is that it doesn’t fit: Abnormal termination of minimization. If I decomment the last line it works, but I want to use my function.
gamma_R.C (1009 Bytes)
read.h (1.7 KB)
232Th03.h (20.3 KB)

The function you are trying to fit does not represent correctly the data,
and then the minimization program cannot converge.
You need to describe also the signal peak in addition to the background in your fitting function.
Look for example at the example in tutorials/peaks.C which uses TSpectrum

Ciao,

Lorenzo

tutorials/peaks.C first estimate the background with a simple linear background without gaussian peaks. I use an exponential background because I think it’s better in my case. If I use “expo” instead of my user function “rumore” (they are the same in fact) all work.

If you use a user defined function you need to set the initial parameters of the function. In the case of “expo” they are set automatically.
So if you do for example (before h->Fit )

BackGround->SetParameters(10000,-1);

your fit will converge, but it will not be a good fit since the function is not describing correctly your data.