···56# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7[lib]
8-name = "py_oxyroot"
9crate-type = ["cdylib"]
1011[dependencies]
12-pyo3 = "0.25.0"
00
···56# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7[lib]
8+name = "oxyroot"
9crate-type = ["cdylib"]
1011[dependencies]
12+numpy = "0.26.0"
13+oxyroot = "0.1.25"
14+pyo3 = { version = "0.26.0", features = ["abi3-py38"] }
···1+import oxyroot
2+3+if __name__ == '__main__':
4+ import uproot
5+ import numpy as np
6+ import time
7+8+ file_name = "ntuples.root"
9+ tree_name = 'mu_mc'
10+11+ up_start_time = time.time()
12+ up_tree = uproot.open(file_name)[tree_name]
13+ for branch in up_tree.keys():
14+ # print(branch, up_tree[branch].typename)
15+ if up_tree[branch].typename != "std::string":
16+ up_values = up_tree[branch].array(library="np")
17+ print(f"Uproot read {branch} into a {type(up_values)} and it has a mean of {np.nanmean(up_values):.2f}")
18+ up_end_time = time.time()
19+20+ print("\n")
21+22+ oxy_start_time = time.time()
23+ oxy_branches = oxyroot.read_root(file_name, tree_name=tree_name)
24+ for branch in oxy_branches:
25+ oxyroot.read_root(file_name, tree_name=tree_name, branch=branch)
26+ oxy_values = oxyroot.read_root(file_name, tree_name=tree_name, branch=branch)
27+ if type(oxy_values) is np.ndarray:
28+ print(f"Oxyroot read {branch} into a {type(oxy_values)} and it has a mean of {np.nanmean(oxy_values):.2f}")
29+ else:
30+ print(f"Oxyroot read {branch} into a {type(oxy_values)} and it has a length of {len(oxy_values)}")
31+ oxy_end_time = time.time()
32+33+ print("\n Total time")
34+ print(f"Uproot took: {up_end_time - up_start_time:.3}s")
35+ print(f"Oxyroot took: {oxy_end_time - oxy_start_time:.3}s")