Skip to main content

uproot_tree_utils

codecov

A small collection of utilities for handling ROOT TTrees with uproot.

Usage

There are two functions currently in the package. The first is clone_tree:

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}.

The other function available is write_tree:

write_tree(branches, filename, treename)

This function will create a new tree entirely composed of arrays passed to it.

  • branches is a dictionary with items of the form 'branchname': array_with_branch_data
  • filename is the name of a new file to put the tree in
  • treename is the name of the new tree

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.

Metadata

Release files for uproot-tree-utils 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uproot-tree-utils 0.2
File Size Uploaded Provenance Actions
uproot_tree_utils-0.2.tar.gz 3.6 kB Without provenance Details for uproot_tree_utils-0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for uproot-tree-utils 0.2
File Interpreter ABI Platform Actions
uproot_tree_utils-0.2-py3-none-any.whl Python 3 none any Details for uproot_tree_utils-0.2-py3-none-any.whl

Total release size: 8.8 kB

Release files / uproot_tree_utils-0.2.tar.gz

Download URL uproot_tree_utils-0.2.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
77dc186b826f7e9f73c1197b99b0bc81d82fed87072164b5ab63f4f341e0dbbd
BLAKE2b-256 checksum
How to use checksums
374bde13ac67fa344b5acb30825b0b7610a1d06a2299bd8a3cb18ebeeb847359
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / uproot_tree_utils-0.2-py3-none-any.whl

Download URL uproot_tree_utils-0.2-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ee58a3c2a04da89ed500375682d51ad1d837d8179762f805ef11ba432a75fb8
BLAKE2b-256 checksum
How to use checksums
941d4c32fe7ba99ad149aa906273a1985da40f4fa66034438c41ec804aab6460
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Security for uproot-tree-utils 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page