I have a problem when i was fitting the histogram with fixing initail parameters

Hi experts.
I wanna fit the histogram fixing the initial parameters.
So i use this code.
double initparms[] = {5, 3.2, 6.76268e-1};
TF1 *f = new TF1(“f”,“gaus”);
f->SetParameters(initparms);
f->FixParameter(2,3.2);
f->FixParameter(3,6.76268e-1);
f->SetLineColor(kBlue);
f->SetLineStyle(3);
N_37->Fit(f,“R”,“I”,0,6);

But It shows like below.

I wanna fix second parameter and third parameter. What should i do?

Try: N_37->Fit(f, "IB", "", 0., 6.);

When using predefined functions as gaus, landau, expo you need to use the fit option B for fixing some of the parameters.

Screenshot from 2021-08-05 12-39-16


Thanks for reply!
I did as you said, but it shows that only the 3rd parameter ,sigma, is fixed. But even this value is different from the value 6.76268e-1 i entered.

What is the problem?

The TF1 parameters are numbered starting from 0, not 1 (regardless of what the minimizer’s output shows).

Thanks! It really helps me.

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