Problem in smearing histogram

It is not necessary in order to know the width.
Scaling the area of the function g so that is equal to 1 gives you the correct amplitude for the function f before the effect of the resolution.

In line 16 could have been done using “TMath::Gaus(x, 0 ,3.5,kTRUE)” instead of “gaus”. You can do it and change a bit the code to remove the FixParameter related to g function.


The reason is that you have drawn h1 in both in c1->cd(1) and c1->cd(2). So when you fit h1 the function is drawn on both the pads.

Try to change the code below c1->cd(2) like this

c1->cd(2) 
TH1D * h1_clone= (TH1D *)h1->Clone();
h1_clone->Draw("E1");
h1_clone->Fit(f,"ME");

Now in c1->cd(2) you will draw and fit a clone of your histogram leaving the plot in c1->cd(1) untouched.

Hi,

So I modified the code a bit. Since we are now able to decompose the distribution without the effect of resolution using the function f_no_res (which we convert into a histogram and obtain the original widths without resolution).

Now I try to fit the f_no_res histogram using the 3 Gaussian function as
I was interested in calculating the area of the Gaussian functions used for fitting. What I see is that the fit parameters in cd(2) and cd(3) (see figure )are different even though we use the same function f_no_res. Is this normal ? Also the value of the integral is also different.

Here I also attach the macro :
Re_Smear_3gauss.C (5.2 KB)

I wonder why I get different fit parameters when I fit the same function.

It is an easy fix.
The Gaussian in f_conv and f_no_res do not have the 0.5 in the definition while f12, f11, f122 and f13 have the 0.5 in the definition.
Add the 0.5 in f_conv and f_no_res and everything will works.

Replace the (46.,130.) range with (40.,140.) everywhere and I suggest you also to fit the functions with option “MEL” since the Likelihood Method is better in fitting histograms. Especially in taking care of bins with 0 counts .

Below my results and here the macro modified Re_Smear_3gauss.c (5.2 KB)

1 Like

That resolves the problem. Thanks, @Dilicus.

So using the option MEL, would fit the histogram using the Binned likelihood method along with the error estimated using the TMinuit ?

TH1::Fit