Fitting Cs137 spectrum from Compton scattering experiment

Compton.cxx (960 Bytes) Compton.txt (329.3 KB)
Hello,

I am struggling to fit data of Cs137 spectrum from Compton scattering experiment with a single function which is the sum of the gaussian for the signal and the polynomial or an exponential for the background (or it could be sum of exponential and polynomial). I tried using the predefined functions, but my fit doesn’t look good. I am aware there is a way to create a customized function, though I don’t know how to create one that would fit the data well. I am very lost and any help would be greatly appreciated
_ROOT Version:_ROOT 6.23/01

Maybe @moneta can give you some hints

Hi,
att your mod macro
main problem was TF1… ,pol20+gaus
Cheers
Otto

Compton.cxx (1.1 KB)

Wow, thank you very much! Just one question, how did you know to set the parameters to
g->SetParameters(1000, -2, 0, 0, 2000,450,40);

Hi Edward,
first 4 params are the pol3 (the background) which in your case
looks approx linear crossing 0 around 1000-2000 with
negative slope, the quadratic and cubic terms we let for the fit.
The last is the gauss width, so approx 100/2, last but one the
center of the peak and then the constant, it must be quite big.
Btw. Its good practice before doing the fit to draw the function
with the initial parameters.
Cheers
Otto