Landau fit problem

Hello I’m trying to fit two TH1F using the Landau function…but it doesn’t look like working fine…

This is the macro
simlemmaev.cpp (6.0 KB)

This is one of the Root files

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

you can do:

te->Draw(Form("ReleasedEnergy >> htemp(100, 0., 1.)"), "", "goff");

as you do not need the graphics produced by Tree::Draw

For the fitting issue I think you can look at the paragraph Setting initial conditions in this page.

Thank you @couet, but due that I’m using a landau function, shouldn’t the initial conditions be automatic?

I am not sure, it looks like the fit does not converge properly.
It is often due to bad initial values,
Ask @moneta

I tried it but the macro doesn’t run if I use that line…

I know that for predefined function the initial values are not needed…and it’s also written in the page of your link

The setting of the parameter initial values is automatic for the predefined functions : poln, expo, gaus, landau.

Anyway I agree that the problem was due to bad initial values because I tried to set initial conditions and now I get a good fit as you can see in this plot

I used the initial condition from an old macro to fit data by a logistic function…
The fit looks like good, but I get the 0 error on the MPV


maybe, is @moneta able to improve the initial conditions?

Here the new macro simlemmaev.cpp (6.7 KB)

The error is not zero. As you see in the printout is around 2E-5. It is maybe a display problem in the fit result that truncate the error. It should use a scientific notation in this case. Maybe open a GitHub issue for this.
The fit however is not so good, the chi2 is quite large.
For the initial conditions, I think for the landau one sets initial MPV and sigma according to histogram mean and standard deviation. However these values cannot be good for all the case. Having better initial conditions is often helpful

Best regards


Thank you @moneta

Where did you read this value?

How can I do it?


You can get a fit result when fitting and print it. IN your code , replace the line where fitting the histogram with these 2 lines:

auto result = htemprelenev2->Fit("Fit2","S");

See ROOT Bug Tracker is now GitHub

Thank you @moneta in this way I get the values printed on the terminal…but I meant if it’s possible to force to print in scientific notation in the stat box too…
Thank you

Yes, there is a way. Just add this line before fitting:




Thank you @moneta

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.