12 void fill_tree(
const char *treeName,
const char *fileName)
16 d.Define(
"b1", [&i]() {
return i; })
23 .Snapshot(treeName, fileName);
30 auto fileName =
"df006_ranges.root";
31 auto treeName =
"myTree";
32 fill_tree(treeName, fileName);
39 auto c_all =
d.Count();
42 auto d_0_30 =
d.Range(0, 30);
43 auto c_0_30 = d_0_30.Count();
46 auto d_15_end =
d.Range(15, 0);
47 auto c_15_end = d_15_end.Count();
50 auto d_15_end_3 =
d.Range(15, 0, 3);
51 auto c_15_end_3 = d_15_end_3.Count();
55 auto d_0_50 =
d.Range(0, 50);
56 auto c_0_50_odd_b1 = d_0_50.Filter(
"1 == b1 % 2").Count();
61 auto c_0_3_after_even_b1 =
d.Filter(
"0 == b1 % 2").Range(0, 3).Count();
64 cout <<
"Usage of ranges:\n" 65 <<
" - All entries: " << *c_all << endl
66 <<
" - Entries from 0 to 30: " << *c_0_30 << endl
67 <<
" - Entries from 15 onwards: " << *c_15_end << endl
68 <<
" - Entries from 15 onwards in steps of 3: " << *c_15_end_3 << endl
69 <<
" - Entries from 0 to 50, odd only: " << *c_0_50_odd_b1 << endl
70 <<
" - First three entries of all even entries: " << *c_0_3_after_even_b1 << endl;
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees, CSV's and other data formats.