oxyroot
Another attempt to make library reading and writing .root binary files which are commonly used in particle physics
Cli tools
- oxyroot-ls : List the content of trees of a root file
- oxyroot-dump : Dump the content of trees of a root file
Inspiration
To make this library :
- heavy inspiration taken from groot for reading root file, even the code organisation
- inspiration taken from uproot to provide branch interface (for reading basket buffer)
Limitations
For now:
- can only write uncompressed file
See also
Another rust implementation of a root reader is root-io.
Getting started
Example: Iter over a branch tree containing i32 values
use RootFile;
let s = "examples/from_uproot/data/HZZ.root";
let tree = open.unwrap.get_tree.unwrap;
let NJet = tree.branch.unwrap.;
NJet.for_each;
Example: Write i32 values in a branch
use ;
let s = "/tmp/simple.root";
let mut file = create.expect;
let mut tree = new;
let it = ;
tree.new_branch;
tree.write.expect;
file.close.expect;
Example: Iter over a branch tree containing Vec<i32>  (aka std::vector<int32_t>) values
use RootFile;
let s = "tests/stl_containers/stl_containers.root";
let tree = open.unwrap.get_tree.unwrap;
let vector_int32 = tree.branch
.unwrap. 
. ;
assert_eq!;
Example : Iter over several branches by using ReadFromTree.
If you a root file containing several branches, you can use ReadFromTree to read them all at once. To read
Point from branches x, y:
use ReadFromTree;
let s = "tests/point/point.root";
let tree = open.unwrap.get_tree.unwrap;
let points = from_tree.unwrap;
for point in points 
Example : Write to several branches by using WriteToTree.
use ReadFromTree;
let s = "tests/point/point.root";
let mut f = create.unwrap;
let mut tree = new;
let points = vec!;
to_tree.unwrap;
tree.write.unwrap;
f.close.unwrap;
Feature
oxyroot use flate2 to decompress zlib compressed data.
The default backend is miniz_oxide, pure Rust crate.
If you want maximum performance, you can use the zlib-ng C library:
[]
 = {  = "0.1",  = ["zlib-ng"] }