Hi,
I working in pyroot and I am trying to perform a fit using TMinuit. The fit worked fine with a previous root releases (the nightlies from a pair of months ago) and then now gives me the error:
... line 123, in MinuitLinearFit
minuit.mnexcm("MIGRAD", arglist, 2,ierflg)
TypeError: void TMinuit::mnexcm(const char* comand, double* plist, int llist, int& ierflg) =>
TypeError: 'c_double' object does not support item assignment
Here the relevant part of my code:
minuit = ROOT.TMinuit(2)#.Fitter(0, 2)
minuit.SetFCN(linearChi2)
arglist = array('d',2*[0])
arglist[0] =1.0
arglist[0] = 500000
ierflg = ctypes.c_int(0)
minuit.SetPrintLevel(-1)
minuit.mnexcm("SET ERR",arglist,1,ierflg)
minuit.mnparm(0, 'offset',1,0.1,-1,1,ierflg)
minuit.mnparm(1, 'slope',1,0.1,-0.3,0.3,ierflg)
minuit.mnexcm("MIGRAD", arglist, 2,ierflg)
def linearChi2(npar, gin, f, par, istatus ):
vec = yy-(par[0]+par[1]*(xx-25))#SLOPEOFFSETUNCORR
chi2 = np.linalg.multi_dot( [vec.T, invCov, vec] )
f[0] = chi2
return
Between the working version and the current one changed only the deprecated ierflg=ROOT.Long(0) into ierflg = ctypes.c_int(0), but the problems seems related to the way I am passing arglist, If I understood correctly.
I did some try:
-
I tried to define arglist as: arglist = (ctypes.c_double * 2)() but the error is unchanged
-
I tried to use ROOT.TVirtualFitter.Fitter instead of TMinuit (changing all the methods accordingly) but I face the same error also with TVirtualFitter.
-
I tried to comment the two minuit.mnparm(…) lines. In this case the error disappears but the fit is different.
Can somebody help me?
Thank you very much in advance,
ROOT Version: /cvmfs/sft-nightlies.cern.ch/lcg/views/dev3/latest/x86_64-centos7-gcc8-opt/setup.sh
Platform: CentOS Linux release 7.4.1708 (Core)
Compiler: +gcc (GCC) version 8.30.0