Issues with the DataSetHelper in pyROOT (using only 1 variable for dataset)

Dear experts,
I am trying to use ROOT 6.26.04 and its new functionality for DataSet making with RDataFrame

My script looks as follow inside a python loop updating a dictionary.

    ##### various swaps mass and cut coupled
    helper = r.RooDataSetHelper(f"dataset_Kpi_{y}" , f"#mu ProbK>0.2, e #ProbK<0.2 , anti-PID B2emu {y}", r.RooArgSet( massKpi))
    Histos.update( { y :  {"kpi" : node_inverted_PID.Filter("muminus_MC15TuneV1_ProbNNk>0.2 && eplus_MC15TuneV1_ProbNNk<0.2")\
                           .Define("muminus_h", f"makeLVMass( muminus_PX, muminus_PY, muminus_PZ, {kMass})")\
                           .Define("eplus_h",   f"makeLVMass( eplus_PX, eplus_PY, eplus_PZ, {piMass})")\
                           .Define("emu_hh",     f"(eplus_h+muminus_h).Mag()")\
                           .Book( r.std.move(helper), "emu_hh")}})

I get the following message

  File "/afs/", line 116, in <module>
    Histos.update( { y :  {"kpi" : node_inverted_PID.Filter("muminus_MC15TuneV1_ProbNNk>0.2 && eplus_MC15TuneV1_ProbNNk<0.2")\
TypeError: Template method resolution failed:
  Failed to instantiate "Book(RooAbsDataHelper<RooDataSet>&&,std::string)"

Do you have any suggestions?


Does it work if you put the column names in a tuple like this?

.Book( r.std.move(helper), ("emu_hh"))}})

At least that’s how it is done in the tutorial:

1 Like

Hi @jonas
I tried and same error.
I copied the tutorial and dropped one variable on the method and i see the same error.
Not sure if this mean that with >1 variable. all is good, but with only one it doesn’t work?

not sure, but apparently with only one variable :

ROOT.std.move(ROOT.RooDataSetHelper("dataset", "Title of dataset", ROOT.RooArgSet(x))), ["x"]

this seems to work. Might be good to update the tutorial with a 1-variable case as well?

Actually I realized it was just a problem from ambiguous Python syntax. This would have worked I think:

.Book( r.std.move(helper), ("emu_hh", ))}})

With the comma in the tuple. This is necessary to tell Python that the type is a tuple, otherwise (“emu_hh”) will just evaluate to the string inside the brackets, which is the wrong type.


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