I have data stored in th1d histogram. I want to define its behaviour by fitting it with Gaussian+any kind of function. After fit it I want to use mean and sigma. I attached the macro that I use. I used gauss+3rd order polynomial but somehow it does not show the right means and sigmas. However chi2/ndf is good and fit looks ok. I expect mean is where I observe the top of the function but the parameter that I wrote in text for each pt bin is away different than the top part of the function. What can be the reason for this? I need really help. I stacked.
fitting_justsubt.C (3.6 KB)
just_subt.root (25.9 KB)
I tried to run your routine, and I changed a little bit.
With respect to your shows the pol3 and gaussian separately and I expanded the range along y axis.
How you can see if you run this new routine, the single fit are not so good.
So I advice you to use also the option L when you fit histogram, , in particular in the case when you have bin with few counts. LogLikelihood is a better choice in my opinion with respect to Chi2 square to fit histogram
Maybe you should fit a larger range, to have a better estimation of the background parameters.
Moreover Do you obtain histogram from some subtraction?
I ask because for value of invariant mass larger than 2GeV/c you have negative counts.
The Last one is just a curiosity but maybe can influence your fit.
fitting_justsubt.C (4.2 KB)
Many thanks for your checking. I looked and you are right since two functions are different from each other the means and the sigmas are lower than the point that I expected. When I use L option chi2 are very bad. Do I use LR together or do you suggest me only use L?
Yes these are the subtracted results. I do not know how to ignore when it goes -.
I suggest to use both L and R.
Maybe you can try to fit the histogram before the subtraction, I don’t know if it is possible.
This is the result that I must fit to get definition of the background. It is not possible to fit before subtraction and then use it. When I use RL together or L alone means and sigmas are ok but CHi2 is really bad. I think I should find another function next to gausian . I do not know if there is another solution.Do you have an idea?
Can you try to give more context?
I think you’re trying to reconstruct the mass of a Delta baryon and your data are from sort of Montecarlo simulation.
How are build the histograms that you use for the subtraction?
Yes these are MC results.I have TH1D histograms which are filled in right way and then I subtract one from the other. I believe there is nothing wrong in subtraction and filling part. Just this distribution does not have nice shape to fit.
So you have two MC histograms and then I subtract one from the other.
Do you fill histogram with some weight? If it is the case, do you set the Sumw2 option to be true?
Yes I did in the same way.
Maybe you should to set better start parameters for both gauss and pol3, and maybe put ParLimits also on the pol3 variable.
This is the last thing I can suggest, I have no more idea sorry.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.