C function with argument passed as reference (TMinuit)


So here is a problem I have using TMinuit from PyROOT.
After performing a fit correctly, I do :

a=0 e=0 myMinuit.GetParameter(i, a , e)

Then e is filled with the expected error value but a=e…
I guess this has something to deal with the fact that GetParameter passes argument as references ?
I could have a workaround because TMinuit has all its members public, but there is maybe something smarter ?


yes, this is a known problem. I should introduce a special class, something like “Double” for the purpose of pass-by-ref. Unfortunately, at the moment there is little else you can do other than giving both a and e different values (0.132 and 0.123, say). The python interpreter re-uses literal float values, hence your a and e point to the same object if you assign ‘0’ to both.

All that said, this is (AFAICS) a reliable way of getting fresh float objects:[code]$ cat GimeDouble.C
double Double() {
return 0.;

$ python

from ROOT import *
gROOT.LoadMacro( “GimeDouble.C+” )
a = Double()
b = Double()

etc. …[/code]