Problem in calculating areas under fitted peak

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;

Yes, this should be correct. A potential difficult comes when you wants to calculate the error in the background area. In that case you need to take into account correlations between the two terms you are subtracting.

Lorenzo

Thanks so much @moneta

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

std::cout << h->Integral(h->FindFixBin(395.), h->FindFixBin(435.)) << std::endl;

I was checking the values from both. But able to find that there is a difference.
First gives 15360 while second gives 15483.
Could you please elaborate why the two values are different?