chi2FitTo does not take arguments in pyroot

I have used FitTo to perform fits on a roofit extended pdf, using the syntax below.

self.fitresult = self.func_pdf.chi2FitTo( self.datahist,
                                 ROOT.RooCmdArg( 'Strategy', 3 ) ,   

I try to switch to chi2 fit by only changing FitTo to chi2FitTo and it gives me the following error. It seems that the pyroot method is bound to the C method that takes a RooLinkedList instead of several option arguments. i.e. RooAbsPdf::chi2FitTo(RooDataHist& data, const RooLinkedList& cmdList) I checked that chi2FitTo and FitTo are overloaded in the same way in the C++ source code so I am surprised they have different behavior.

I wonder if there is any workaround. If the only way is to use RooLinkedList, how do I do that?
root version: 6.06.00

Traceback (most recent call last):
  File "./", line 608, in <module>
  File "./", line 161, in main
    basesel=baseeta+failpix+ltmet,tag="regB"+tbase,ic = ic,maxtimes=150,doData=doData)
  File "./", line 231, in makevariableplots_simultaneous
    tag=tag, ic = ic, xbins=(200,0,200), dobkgd =dobkgd, maxtimes = maxtimes, doData=doData)
  File "./", line 296, in fitting_simultaneous
    tag=tag,ic = ic, maxtimes =maxtimes)
  File "./", line 352, in corefitting_simultaneous
    froo_dcb = fm.run_fit_chi2(fr)
  File "/home/kakw/efake/WG_Analysis/Plotting/", line 406, in run_fit_chi2
TypeError: RooFitResult* RooAbsPdf::chi2FitTo(RooDataHist& data, const RooLinkedList& cmdList) =>
    takes at most 2 arguments (6 given)

Hello @sciencecw,

chi2FitTo with >2 arguments is not reimplemented for RooAbsPdf, and that’s apparently why pyroot does not call it:

The base class RooAbsReal does have the overload you are looking for
and we should find out how to call it.

@etejedor might know how we can convince pyroot to do that.

HI @sciencecw

This indeed looks like a bug in the overload resolution of PyROOT, could you try with a newer ROOT version (6.14) to see if the problem is there?

Also, could you post here a minimal reproducer that we can run to check the issue?

Thank you,

You can set up a new ROOT version from cvmfs. You can find instructions on the following page under CVMFS:

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