A confusing Pyroot error

I use following ways to construct RooDataHist.

from ROOT import TFile, TH1D, RooRealVar, RooWorkspace, RooArgSet,  RooDataHist

w = RooWorkspace()
m = RooRealVar()
m = w.var("D_M_K3pi")
m.setRange(xmin,2000)
m.setBins(100)
xmin2 = 1350

hsl = TH1D("hsl","",130,xmin2,2000.0)
dh_sl = RooDataHist("dh_sl","",RooArgList(m), hsl)

But errors happened:

Traceback (most recent call last):
  File "test.py", line 32, in <module>
    dh_sl = RooDataHist("dh_sl","", m, hsl)
TypeError: none of the 8 overloaded methods succeeded. Full details:
  RooDataHist::RooDataHist() =>
    takes at most 0 arguments (4 given)
  RooDataHist::RooDataHist(const char* name, const char* title, const RooArgSet& vars, const char* binningName = 0) =>
    could not convert argument 3
  RooDataHist::RooDataHist(const char* name, const char* title, const RooArgList& vars, const RooCmdArg& arg1, const RooCmdArg& arg2 = RooCmdArg(), const RooCmdArg& arg3 = RooCmdArg(), const RooCmdArg& arg4 = RooCmdArg(), const RooCmdArg& arg5 = RooCmdArg(), const RooCmdArg& arg6 = RooCmdArg(), const RooCmdArg& arg7 = RooCmdArg(), const RooCmdArg& arg8 = RooCmdArg()) =>
    could not convert argument 3
  RooDataHist::RooDataHist(const RooDataHist& other, const char* newname = 0) =>
    takes at most 2 arguments (4 given)
  RooDataHist::RooDataHist(const char* name, const char* title, const RooArgSet& vars, const RooAbsData& data, double initWgt = 1.) =>
    could not convert argument 3
  RooDataHist::RooDataHist(const char* name, const char* title, const RooArgList& vars, const TH1* hist, double initWgt = 1.) =>
    could not convert argument 3
  RooDataHist::RooDataHist(const char* name, const char* title, const RooArgList& vars, RooCategory& indexCat, map<string,TH1*> histMap, double initWgt = 1.) =>
    takes at least 5 arguments (4 given)
  RooDataHist::RooDataHist(const char* name, const char* title, const RooArgList& vars, RooCategory& indexCat, map<string,RooDataHist*> dhistMap, double wgt = 1.) =>
    takes at least 5 arguments (4 given)

It is very strange cause this constructor will work in C++ ROOT.
But in pyroot, I have to change m into RooArgSet(m).
Why?

Hello,

What version of ROOT are you using? I tried to reproduce with 6.24/06 but I can’t.

Could you also share a full reproducer?

@jonas

1 Like

I use root_v6.20.04_python3

Then it’s probably an issue that has been fixed in the meantime.

My recommendation is to either use a newer ROOT release, or if you want to stick to an old release you already found a workaround :slight_smile:

Cheers,
Jonas

1 Like

Thank you and I will try it again with pyroot_v6.24.06. :star_struck:

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