#include "df0001.h" #include "ROOT/RDataFrame.hxx" #include "TApplication.h" void fill_tree(const char* treeName, const char* fileName) { ROOT::RDataFrame d(10); int i{ 0 }; d.Define("b1", [&i]() {return static_cast(i); }) .Define("b2", [&i]() {auto j = i * i; ++i; return j; }) .Snapshot(treeName, fileName); } int df0001_introduction() { // We prepare an input tree to run on auto fileName = "df001_introduction.root"; auto treeName = "myTree"; fill_tree(treeName, fileName); ROOT::RDataFrame d(treeName, fileName, { "b1" }); auto cutb1 = [](double b1) { return b1 < 5.; }; auto cutb1b2 = [](int b2, double b1) { return b2 % 2 && b1 < 4.; }; auto entries1 = d.Filter(cutb1) // <- no column name specified here! .Filter(cutb1b2, { "b2", "b1" }) .Count(); std::cout << *entries1 << " entries passed all filters" << std::endl; auto entries2 = d.Filter("b1 < 10.").Count(); std::cout << *entries2 << " entries passed the string filter" << std::endl; return 0; } int main(int argc, char** argv) { TApplication app("app", &argc, argv); df0001_introduction(); app.Run(); return 0; }