Logo ROOT   6.18/05
Reference Guide
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.
15ROOT::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
21template<typename T>
22std::string GetName(T&)
23{
24 int dummy;
25 return TClassEdit::DemangleName(typeid(T).name(), dummy);
26}
27
28void 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}
#define e(i)
Definition: RSha256.hxx:103
static RooMathCoreReg dummy
unsigned long long ULong64_t
Definition: RtypesCore.h:70
char name[80]
Definition: TGX11.cxx:109
The public interface to the RDataFrame federation of classes.
Definition: RInterface.hxx:89
RInterface< RDFDetail::RFilter< F, Proxied >, DS_t > Filter(F f, const ColumnNames_t &columns={}, std::string_view name="")
Append a filter to the call graph.
Definition: RInterface.hxx:187
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
Definition: RDataFrame.hxx:42
TF1 * f1
Definition: legend1.C:11
std::string GetName(const std::string &scope_name)
Definition: Cppyy.cxx:146
double T(double x)
Definition: ChebyshevPol.h:34
char * DemangleName(const char *mangled_name, int &errorCode)
Definition: TClassEdit.h:205