12 def fill_tree(treeName, fileName):
13 tdf = ROOT.ROOT.RDataFrame(100)
14 tdf.Define(
"b1",
"(int) tdfentry_")\
15 .Define(
"b2",
"(float) tdfentry_ * tdfentry_").Snapshot(treeName, fileName)
19 fileName =
"df006_ranges_py.root" 22 fill_tree(treeName, fileName)
25 RDF = ROOT.ROOT.RDataFrame
26 d = RDF(treeName, fileName)
33 d_0_30 = d.Range(0, 30)
34 c_0_30 = d_0_30.Count()
37 d_15_end = d.Range(15, 0)
38 c_15_end = d_15_end.Count()
41 d_15_end_3 = d.Range(15, 0, 3)
42 c_15_end_3 = d_15_end_3.Count()
46 d_0_50 = d.Range(0, 50)
47 c_0_50_odd_b1 = d_0_50.Filter(
"1 == b1 % 2").Count()
52 c_0_3_after_even_b1 = d.Filter(
"0 == b1 % 2").
Range(0, 3).Count()
55 print(
"Usage of ranges:")
56 print(
" - All entries:", c_all.GetValue())
57 print(
" - Entries from 0 to 30:", c_0_30.GetValue())
58 print(
" - Entries from 15 onwards:", c_15_end.GetValue())
59 print(
" - Entries from 15 onwards in steps of 3:", c_15_end_3.GetValue())
60 print(
" - Entries from 0 to 50, odd only:", c_0_50_odd_b1.GetValue())
61 print(
" - First three entries of all even entries:", c_0_3_after_even_b1.GetValue())