A small collection of utilities for handling ROOT TTrees with uproot.
Project description
uproot_tree_utils
A small collection of utilities for handling ROOT TTrees with uproot.
Usage
The only function currently in the package is clone_tree()
. The full function signature is
clone_tree(tree, new_filename, new_treename=None, branches=None, selection=None, new_branches=None)
The required arguments tree
and new_filename
are the TTree object to copy from (as retrieved by uproot) and the file to copy to, respectively. The simplest usage looks like
import uproot
from uproot_tree_utils import clone_tree
file = uproot.open('some_root_file.root')
clone_tree(file['the_treename'], 'a_new_filename.root')
This will simply copy the entire tree from the original file to a new file (with no other objects).
new_treename
can be used to give the new tree a different name. The default is the original tree's name.branches
can be a list of strings representing the branches to copy. Only the selected branches will be in the new file.selection
is an optional array determining which events to copy. This can be a boolean mask or integers corresponding to the desired event indices.new_branches
allows the user to pass a dictionary of new branches to insert into the tree. The format for the dictionary should be{'new_branchname': array_with_branch_data}
.
Limitations
Not all branch types can be written by uproot.
Currently supported branch types:
Char_t
/char
Short_t
/short
Int_t
/int
Float_t
/float
Double_t
/double
Long64_t
/long long
Bool_t
/bool
std::vector<short>
std::vector<int>
std::vector<float>
std::vector<double>
Character strings, unsigned integers, vector<char>
, and vector<bool>
are not yet supported. There are also some known bugs with vector<long>
and vector<long long>
. Further nesting of vectors (e.g. vector<vector<int> >
) is not supported by uproot's tree writing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for uproot_tree_utils-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9935767110111d04426ec4b5c3c502a703a4bc18dfbef1c518d0dfb1768837d6 |
|
MD5 | 475fbe2cf42af148cde1d7ff8654b61c |
|
BLAKE2b-256 | 1cf6ca1429fe57bc5a319623c49c63ff8efa8d4328c8ae8ce42ac6f8d8f8e0ab |