18 void fill_tree(
const char *filename,
const char *treeName)
20 TFile f(filename,
"RECREATE");
21 TTree t(treeName, treeName);
26 for (
int i = 0; i < 100; ++i) {
40 auto fileName =
"tdf006_ranges.root";
41 auto treeName =
"myTree";
42 fill_tree(fileName, treeName);
49 auto c_all = d.Count();
52 auto d_0_30 = d.Range(0, 30);
53 auto c_0_30 = d_0_30.Count();
56 auto d_15_end = d.Range(15, 0);
57 auto c_15_end = d_15_end.Count();
60 auto d_15_end_3 = d.Range(15, 0, 3);
61 auto c_15_end_3 = d_15_end_3.Count();
65 auto d_0_50 = d.Range(0, 50);
66 auto c_0_50_odd_b1 = d_0_50.Filter(
"1 == b1 % 2").Count();
71 auto c_0_3_after_even_b1 = d.Filter(
"0 == b1 % 2").Range(0, 3).Count();
74 cout <<
"Usage of ranges:\n" 75 <<
" - All entries: " << *c_all << endl
76 <<
" - Entries from 0 to 30: " << *c_0_30 << endl
77 <<
" - Entries from 15 onwards: " << *c_15_end << endl
78 <<
" - Entries from 15 onwards in steps of 3: " << *c_15_end_3 << endl
79 <<
" - Entries from 0 to 50, odd only: " << *c_0_50_odd_b1 << endl
80 <<
" - First three entries of all even entries: " << *c_0_3_after_even_b1 << endl;
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
ROOT's TDataFrame offers a high level interface for analyses of data stored in TTrees.
A TTree object has a header with a name and a title.