How to fix parameter after TVirtualFitter::SetDefaultFitter

I try to fix parameters after using TVirtualFitter::SetDefaultFitter(Fumili/Minuit2/Fumili2), but without success - parameters still are changed. Here is a sample code:

	TVirtualFitter::SetDefaultFitter("Fumili2");
	TVirtualFitter *fitter = TVirtualFitter::Fitter(0, 11);
	TF2 *psf_fin = new TF2("psf_fin", psf_func, -5.5, 5.5, -5.5, 5.5, 11);

        fitter->SetParameter(0, "x", 0, 0, 1, 1);
	fitter->SetParameter(1, "y", 400, 0, 1, 1);
	fitter->SetParameter(2, "dx", 1.48984e-01, 0.01, -1.1, 1.1);
	fitter->SetParameter(3, "dy", 3.64288e-01, 0.01, -1.1, 1.1);
	fitter->SetParameter(4, "z", 4.30968e-01,  0.1, 0, 0.2);
	fitter->SetParameter(5, "ast", -2.94616e-08, 1e-06, 0, 0);
	fitter->SetParameter(6, "coma", -3.78867e-07, 1e-06, -1, -	1);
	fitter->SetParameter(7, "spher", -3.41418e-07,  1e-06, -1, -1);
	fitter->SetParameter(8, "spher1",  6.22142e-08, 1e-06, -1, -1);
	fitter->SetParameter(9, "scale", 8.07310e-09, 1e-08, 0, 0);
	fitter->SetParameter(10, "bg", 5.75715e-02, 1e-02, 0, 0);

psf->Fit(psf_fin, "R");

I have no succes using also psf_fin->FixParameter(). If I skip the SetDefaultFitter() part and use psf_fin->FixParameter(), everything works fine.

I would appreciate if you could tell me, what am I doing wrong…

Hello,

it should work when you fix the parameter using the TF1::FixParameter function.
The attached code works for me, with the latest ROOT version

Best Regards

Lorenzo
ExampleFixParam.C (319 Bytes)

I modified your code to see if parameters are truly not changed. I use root 5.22b. Parameter 2 is fixed and is reported as fixed, but here it is slightly changed a few times with Fumili. It is not so when TVirtualFitter::SetDefaultFitter() line is commented.
ExampleFixParam.C (739 Bytes)

Hi,

thank you very much for the example. Yes, it looks that in Fumili2 the derivative is calculated also with respect to the fixed parameter.
This explains the small change observed with your example
This calculation is not needed, and I am wasting some CPU cycles.
However, there should be no influence on the result, at the end the parameter is not varied to a new point.
I will however produce a fix for this to avoid this unneeded calculation

Best Regards

Lorenzo

Thanks, I would apprieciate a fix - my function needs a very long time to calculate, so every such uneeded parameter change affects my fitting time.

Btw. same thing happens with “Fumili”. It is ok with “Minuit” and “Minuit2”.