🌐
Readthedocs
uproot.readthedocs.io › en › latest › uproot.behaviors.TTree.TTree.html
uproot.TTree — Uproot documentation
It only uses metadata from the already-loaded TTree; it only needs language to parse the expressions, not to evaluate them. In addition, the estimate is based on compressed TBasket sizes (the amount of data that would have to be read), not uncompressed TBasket sizes (the amount of data that the final arrays would use in memory, without considering cuts). This is the algorithm that iterate uses to convert a step_size expressed in memory units into a number of entries. Inherited from uproot.behaviors.TBranch.HasBranches.
🌐
CERN
indico.cern.ch › event › 840667 › contributions › 3527109 › attachments › 1908764 › 3153297 › uproot-irisfellow-final.pdf pdf
Writing TTrees using uproot Pratyush Das Jim Pivarski 1
uproot is able to write TTrees with baskets · containing flat data. Building up to TTree writing · 3 · Some issues needed to be fixed/features needed to be added before TTree writing could be · pursued - As well as improving histogram writing capability - (only PRs during fellowship period shown) !!!!
🌐
GitHub
github.com › scikit-hep › uproot3
GitHub - scikit-hep/uproot3: ROOT I/O in pure Python and NumPy. · GitHub
Uproot has a limited ability to write ROOT files, including TTrees of flat data (non-jagged: single number per event), a variety of histogram types, and TObjString (for metadata).
Author: scikit-hep
🌐
Readthedocs
uproot.readthedocs.io › en › stable › uproot.models.TTree.Model_TTree_v20.html
uproot.models.TTree.Model_TTree_v20 — Uproot documentation
String that uniquely specifies this TTree in its path, to use as part of object and array cache keys. Inherited from uproot.TTree.
🌐
Readthedocs
uproot.readthedocs.io › en › latest › uproot.models.TTree.Model_TTree_v19.html
uproot.models.TTree.Model_TTree_v19 — Uproot documentation
String that uniquely specifies this TTree in its path, to use as part of object and array cache keys. Inherited from uproot.TTree.
🌐
Readthedocs
uproot.readthedocs.io › en › latest › uproot.models.TTree.Model_TTree_v17.html
uproot.models.TTree.Model_TTree_v17 — Uproot documentation
String that uniquely specifies this TTree in its path, to use as part of object and array cache keys. Inherited from uproot.TTree.
🌐
GitHub
github.com › scikit-hep › uproot5 › discussions › 543
Aliases and cuts when reading ROOT file · scikit-hep/uproot5 · Discussion #543
The only hard/not currently possible part of what you want to do is adding branches to an existing TTree. The problem there is that Uproot would have to overwrite the TTree metadata (the part of the file that specifies what branches exist and what their types are) but not the preexisting data.
Author: scikit-hep
🌐
Masonproffitt
masonproffitt.github.io › uproot-tutorial › aio › index.html
Uproot Tutorial
March 21, 2022 - The output contains pairs of the form name: type. Therefore the key Events refers to a TTree object.
Find elsewhere
🌐
Readthedocs
uproot.readthedocs.io › en › stable › uproot.models.TTree.num_entries.html
uproot.num_entries — Uproot documentation - Read the Docs
If the file names have colons in them, you can also pass in a dictionary in the format of { file_path : object_path }. Other examples: "rel/file.root:ttree", "C:\abs\file.root:ttree", "http://where/what.root:ttree", "https://username:password@where/secure.root:ttree", "rel/file.root:tdirectory/ttree", iterables of the previous examples.
🌐
Notebook Community
notebook.community › scikit-hep › uproot › binder › tutorial
This tutorial is designed to help you start using uproot. ...
Basic information about the TTree, ... referred to via TKeys (dict-like lookup in uproot). TTree organizes data in TBranches, and uproot interprets one TBranch as one array, either a Numpy array or an awkward array....
🌐
Readthedocs
uproot.readthedocs.io › en › latest › basic.html
Getting started guide — Uproot documentation - Read the Docs
This can delete objects created by Uproot or objects created by ROOT if the file was opened with uproot.update. TTrees are a special type of object, just as TDirectories are special: data can be cumulatively added to them.
Top answer
1 of 2
1

In array-based programming, friends are implicit: you can JOIN any two columns after the fact—you don't have to declare them as friends ahead of time.

In the simplest case, if your arrays a and b have the same length and the same order, you can just use them together, like a + b. It doesn't matter whether a and b came from the same file or not. Even if I've if these is jagged (like jets.phi) and the other is not (like met.phi), you're still fine because the non-jagged array will be broadcasted to match the jagged one.

Note that awkward.Table and awkward.JaggedArray.zip can combine arrays into a single Table or jagged Table for bookkeeping.

If the two arrays are not in the same order, possibly because each writer was individually parallelized, then you'll need some column to act as the key associating rows of one array with different rows of the other. This is a classic database-style JOIN and although Uproot and Awkward don't provide routines for it, Pandas does. (Look up "merging, joining, and concatenating" in the Pandas documenting—there's a lot!) You can maintain an array's jaggedness in Pandas by preparing the column with the awkward.topandas function.

The following issue talks about a lot of these things, though the users in the issue below had to join sets of files, rather than just a single tree. (In principle, a process would have to look ahead to all the files to see which contain which keys: a distributed database problem.) Even if that's not your case, you might find more hints there to see how to get started.

https://github.com/scikit-hep/uproot/issues/314

2 of 2
0

This is how I have "friended" (befriended?) two TTree's in different files with uproot/awkward.

import awkward
import uproot

iterate1 = uproot.iterate(["file_with_a.root"]) # has branch "a"
iterate2 = uproot.iterate(["file_with_b.root"]) # has branch "b"
for array1, array2 in zip(iterate1, iterate2):
    # join arrays
    for field in array2.fields:
        array1 = awkward.with_field(array1, getattr(array2, field), where=field)
    # array1 now has branch "a" and "b"
    print(array1.a)
    print(array1.b)

Alternatively, if it is acceptable to "name" the trees,

import awkward
import uproot

iterate1 = uproot.iterate(["file_with_a.root"]) # has branch "a"
iterate2 = uproot.iterate(["file_with_b.root"]) # has branch "b"
for array1, array2 in zip(iterate1, iterate2):
    # join arrays
    zippedArray = awkward.zip({"tree1": array1, "tree2": array2})
    # zippedArray. now has branch "tree1.a" and "tree2.b"
    print(zippedArray.tree1.a)
    print(zippedArray.tree2.b)

Of course you can use array1 and array2 together without merging them like this. But if you have already written code that expects only 1 Array this can be useful.

🌐
Readthedocs
uproot.readthedocs.io › en › latest › uproot.behaviors.TBranch.iterate.html
uproot.iterate — Uproot documentation
>>> for array in uproot.iterate("files*.root:tree", ["x", "y"], step_size=100): ... # each of the following have 100 entries ... array["x"], array["y"] ... str/bytes: relative or absolute filesystem path or URL, without any colons other than Windows drive letter or URL schema. Examples: "rel/file.root", "C:\abs\file.root", "http://where/what.root" str/bytes: same with an object-within-ROOT path, separated by a colon. Example: "rel/file.root:tdirectory/ttree"
🌐
Readthedocs
uproot.readthedocs.io › en › latest › uproot.behaviors.TBranch.TBranch.html
uproot.TBranch — Uproot documentation
This method does not actually read the TBranch data or compute any expressions to arrive at its estimate. It only uses metadata from the already-loaded TTree; it only needs language to parse the expressions, not to evaluate them.
🌐
Readthedocs
uproot.readthedocs.io › en › latest › uproot.writing.writable.WritableDirectory.html
uproot.WritableDirectory — Uproot documentation
Creates an empty TTree in this directory. Note that starting in v5.7.0, Uproot uses RNTuples as the default format for writing data when using the dict-like assignment syntax.
🌐
Stack Overflow
stackoverflow.com › questions › 64389307 › uproot-question-the-full-ttree-structure-i-can-see-in-a-tbrowser-is-not-appeari
python - uproot question: The full TTree structure I can see in a TBrowser is not appearing in uproot - Stack Overflow
Based on what you're trying to do and the outputs you're getting, it looks like you're expecting Uproot 4, but you have Uproot 3. Until Uproot 4 has feature-parity with Uproot 3, it will be in a package named uproot4 (pip install uproot4 and import uproot4).
🌐
Readthedocs
uproot.readthedocs.io › en › latest › uproot.models.TTree.html
uproot.models.TTree - How to install — Uproot documentation
This module defines versioned models for TTree. See uproot.behaviors.TBranch for definitions of TTree-reading functions.