Passing RDataFrame arguments

I am picking up my task to rewrite a code using RDataFrame after 1.5 years (Thank you Corona lock-down). I am still bumping into the issue of passing RDataFrame objects around between different routines. Please see the code below,

auto MakeDataFrame()
  auto d = ROOT::RDataFrame(10).Define("fAap",[](){return 1;});
  return d;

auto FilterDataFrame(ROOT::RDF::RNode &d,std::string &select)
  auto d_cut = d.Filter(select);
  return d_cut;

void mytest()
  auto d1 = MakeDataFrame();
  auto d2 = FilterDataFrame(d1,"fAap>0");

this results in the following error:

root [0] .L mytest.C
In file included from input_line_8:1:
/Users/eddyo/src/mytest.C:16:13: error: no matching function for call to 'FilterDataFrame'
  auto d2 = FilterDataFrame(d1,"fAap>0");
/Users/eddyo/src/mytest.C:7:6: note: candidate function not viable: no known conversion from 'ROOT::RDF::RInterface<ROOT::Detail::RDF::RLoopManager, void>' to
      'ROOT::RDF::RNode &' (aka 'RInterface< ::ROOT::Detail::RDF::RNodeBase, void> &') for 1st argument
auto FilterDataFrame(ROOT::RDF::RNode &d,std::string &select)

any help appreciated ,


ROOT Version: 6.20.02
Platform: MacOSX
Compiler: -Dcxx14=ON ; Apple clang version 11.0.0

I think @eguiraud can help you.

Hi Eddy,
the compiler errors are sadly unhelpful as it sometimes happens with C++, but the fix is simple: you should change

auto FilterDataFrame(ROOT::RDF::RNode &d,std::string &select)


auto FilterDataFrame(ROOT::RDF::RNode d, std::string select)

i.e. pass by value instead of reference. For the RNode argument, I think the problem is that the compiler refuses to do the conversion to RNode and then take a reference, too many steps. For the string argument, the problem is that you can’t bind an rvalue temporary "fAap>0" to a reference parameter.

Hope this helps!

EDIT: note that passing an RDF object by value is not expensive at all, no data is copied, just the state of that node of the computation graph

1 Like

Hi Enrico,

Yes that solved all my compilation issues .

Thanks, Eddy

1 Like

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