Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
df025_RNode.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_dataframe
3 /// \notebook
4 /// RNode is a generic type which represents any transformation node in the computation graph.
5 /// This tutorial shows how to take advantage of the RNode class.
6 ///
7 /// \macro_code
8 /// \macro_output
9 ///
10 /// \date December 2018
11 /// \author Danilo Piparo
12 
13 /// This function does not need to be a template: the RNode type accommodates all
14 /// possible nodes.
15 ROOT::RDF::RNode AddFilter(ROOT::RDF::RNode node, string_view filterStr)
16 {
17  return node.Filter(filterStr);
18 }
19 
20 /// Trivial helper function which returns the demangled typename from a typeid
21 template<typename T>
22 std::string GetName(T&)
23 {
24  int dummy;
25  return TClassEdit::DemangleName(typeid(T).name(), dummy);
26 }
27 
28 void df025_RNode()
29 {
30  ROOT::RDataFrame df(8);
31  std::cout << "Type name of input node: " << GetName(df) << std::endl;
32  auto f1 = AddFilter(df, "rdfentry_ > 0");
33  auto f2 = f1.Filter([](ULong64_t e) { return e > 1; }, {"rdfentry_"});
34  std::cout << "Type name of input node: " << GetName(f2) << std::endl;
35  auto f3 = AddFilter(f2, "rdfentry_ > 2");
36 
37  std::cout << "Entries passing the selection: " << *f3.Count() << std::endl;
38 }