Using RNode in RDataFrame

Hi there,

I’m trying to create a function like these ones:
https://root.cern.ch/doc/master/df025__RNode_8C_source.html

to apply filters to an RDataFrame. But annoyingly I can’t seem to find the right thing to #include to gain access to RNode. My best guesses for header names have failed and I can’t find an example with full code.

Help?


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi @kpachal,
ROOT::RNode comes with #include <ROOT/RDataFrame.hxx>…if you have a recent enough ROOT version :smiley: The tutorial you are linking to is for ROOT “master” (latest, unreleased ROOT). ROOT::RNode is not available e.g. in ROOT v6.14.

Could this be the issue?
If yes, you can download a compiled version of ROOT master from our website and use that one, or source a nightly build of ROOT from lcg, or compile a more recent ROOT yourself.

Cheers,
Enrico

Hi Enrico,

Ah – that’d be it! I was using 6.14. I’ll try to get a more recent version, but I’m on a shared cluster so I’ll have to use what’s available. In case I’m stuck with 6.14, is there an equivalent way to do this there?

Cheers,
Kate

Hi,
note that there is no more recent release of ROOT (for now: v6.16 is coming soon, with all the RNode goodness). But you can get a nightly build of ROOT master branch from the LCG releases on cmvs, if it’s available on your cluster: source /cvmfs/sft-nightlies.cern.ch/lcg/views/dev3/latest/x86_64-slc6-gcc7-opt/setup.sh – they are kind of stable, ok to use most of the time.

Otherwise, depending on what you actually need to do with RNode, you can use a template function instead.
With C++14 auto return types it’s pretty straightforward:

// c++14
template <typename RDF_t>
auto AddFilter(RDF_t node, string_view filterStr)
 {
    return node.Filter(filterStr);
 }

This becomes more awkward in C++11, where we have to specify the return type somehow (trailing return types to the rescue):

// c++11
template <typename RDF_t>
auto AddFilter(RDF_t node, string_view filterStr) -> decltype(node.Filter(filterStr))
 {
    return node.Filter(filterStr);
 }

Feel free to ask if you encounter any further problems.
Cheers,
Enrico

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