Df 0 2 5_ R Node

RNode is a generic type which represents any transformation node in the computation graph. This tutorial shows how to take advantage of the RNode class.

Author: Danilo Piparo
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Monday, January 27, 2020 at 01:17 AM.

/ this function does not need to be a template: the rnode type accommodates all / possible nodes.

In [1]:
ROOT::RDF::RNode AddFilter(ROOT::RDF::RNode node, string_view filterStr)
{
   return node.Filter(filterStr);
}

/ trivial helper function which returns the demangled typename from a typeid

In [2]:
template<typename T>
std::string GetName(T&)
{
   int dummy;
   return TClassEdit::DemangleName(typeid(T).name(), dummy);
}
In [3]:
ROOT::RDataFrame df(8);
std::cout << "Type name of input node: " << GetName(df) << std::endl;
auto f1 = AddFilter(df, "rdfentry_ > 0");
auto f2 = f1.Filter([](ULong64_t e) { return e > 1; }, {"rdfentry_"});
std::cout << "Type name of input node: " << GetName(f2) << std::endl;
auto f3 = AddFilter(f2, "rdfentry_ > 2");

std::cout << "Entries passing the selection: " << *f3.Count() << std::endl;
Type name of input node: ROOT::RDataFrame
Type name of input node: ROOT::RDF::RInterface<ROOT::Detail::RDF::RFilter<__cling_N54::__cling_Un1Qu32(void*)::$_0, ROOT::Detail::RDF::RNodeBase>, void>
Entries passing the selection: 5

Draw all canvases

In [4]:
gROOT->GetListOfCanvases()->Draw()