Problem in calculating areas under fitted peak

A question that is still a mystery for me is
fithisto.C (4.2 KB) (code)
eu_gu_1.txt (44.1 KB) (data )
In the above code, i have written //Area1 and //Area2
Area1 is calculating the area of the fitted peaks but // Area2 is calculating the area of the fitted peaks when the background subtraction is done.
I expected the two areas to be almost equal.
In other words, Area2 is slightly lesser than Area1.
but results are given below:(one can observe the large differences between the two areas)
Area1
Ist peak 15483
2 peak 6177
3 peak 16218
4 peak 1922
5 peak 4446
6 peak 1561
7 peak 4310
8 peak 3567
9 peak 4553
Area2
1 peak 985.818
2 peak 958.479
3 peak 530.542
4 peak 417.44
5 peak 399.915
6 peak 657.501
7 peak 349.103
8 peak 173.916
9 peak 57.8716
Have a good day.

_ROOT Version:6.14
_Platform:Ubuntu
Compiler: Not Provided


Thanks for replying @Wile_E_Coyote.
I haven’t got the answer of my question.

Your supervisor should easily be able to explain the nonnegligible differences between the fitted peak areas and the corresponding histogram integrals.

Thanks for your suggestion @Wile_E_Coyote
The problem is not about the non-negligible differences between the fitted peak areas and the corresponding histogram integrals that i already understood and my supervisor had already told me what mistake i was making.

Please listen carefully.
First, run the code with commenting the area2 part
i.e.fithisto.C (4.1 KB)

Secondly, run the code[fithisto.C|attachment] (commented the area1part)(upload://8RsSLniSC8LpvaVWYqfFk2h5G57.C) (4.1 KB)

My question is only that when i change the position of the code (keeping limits and everything same)
then why am i getting this differences? Would you be able to explain that?

In the middle you have s->Background(h->GetArray() + 1, ...); which modifies the histogram contents.

Thanks @Wile_E_Coyote.
So, if i want to calculate the areas under the fitted peaks i should have taken only area1 part.
and please explain me this part.

No, you are expected to use “gausn”, instead of “gaus”, as shown in my previous examples (and use “LBR+” fit options, instead of “BR+”, for better agreement).

Thanks @Wile_E_Coyote
Does BR+ part belongs to gaus function and LBR+ part belongs to gausn function?
Am I right?

TH1::Fit

Thanks @Wile_E_Coyote.
For helping me so much.

Please tell me about this one also.

TSpectrum::Background

@Wile_E_Coyote @couet
Here I use gausn(0) + pol1(3) where what does pol1(3) implies? Is it linear background?
If yes, then what do I conclude from it because I am confused that whether it already subtract the background data from the raw data or is it just a linear fitting or it implies subtraction of background also?

May be @moneta can help.

@Wile_E_Coyote @couet
Well, I think it is certainly reducing the counts because instead of “gausn(0) + pol(3)” if i used only “gausn(0)” then following happens:

  1. The peak is not fitted properly.
  2. I observe that the area for “gausn(0)” is greater than “gausn(0) + pol(3)”.
    Should I conclude that pol(3) is also used for subtracting the background?

@Wile_E_Coyote

???

Hi

gaus(0)+po1l(3) means that you are using as fitted function a Gaussian plus a degree=1 polynomial.
The (0) and (3) refer to the parameters of the function.
`par(0),par(1),par(2) are the amplitude, mean and sigma of the Gaussian, while par(3) and par(4) are the slope and the intercept of the linear polynomial function.

By doing the following you can print the actual code of the built formula function:

TF1 f("f","gaus(0)+pol1(3)");
f.Print("V"); 

Lorenzo

@moneta @couet @Wile_E_Coyote
Thanks for replying.
I already know this but i am concern for the background subtraction.
Also, when I am using gausn(0) + pol1(3), for which I know that its par(0) gives me area. par(1)and par(2) give me mean and sigma respectively.
Now, I just want to know that the area given by par(0), does it includes background subtraction (using linear function) or isn’t?

Hi,

Yes if you are using gausn then par[0] will represent the area of the gaussian component, so basically the area under the peak - background.
If you want the background are, you would need to fit with a normalised background function.
There is a class in ROOT that does it automatically for you, TF1NormSum. See the tutorial
https://root.cern.ch/doc/master/fitNormSum_8C.html

Best regards
Lorenzo

Thanks @moneta
Can I get the background value using:

std::cout << "peak area = " << f1->GetParameter(0) << std::endl;
std::cout << "background = " << f1->Integral(395., 435.) - f1->GetParameter(0) << std::endl;