Questions tagged [uproot]

A library for reading [root-framework] data into [numpy] and [awkward-array].

uproot is a narrowly-scoped Python library whose sole function is to read data from ROOT files, which are widely used in the particle physics community (see ).

Rather than reconstituting data as C++ objects, as ROOT does, uproot reads columns of data as NumPy arrays. If the data have too much structure to represent in NumPy, such as a collection of unequal-length std::vector<X>, uproot uses to return jagged arrays with NumPy-like semantics.

uproot can read most types of objects serialized by ROOT, including TTree datasets, Lorentz vectors, histograms, and other types of graphs. Custom behaviors for these objects can be defined by adding functions to uproot-methods.

uproot interfaces with , , , cachetools, Python's concurrent.futures, and xrootd.

94 questions
1
vote
0 answers

How do you use TEntryList from ROOT with UPROOT

I have two root files, and am using uproot 3.12 right now. td = uproot.open("data.root") tc = uproot.open("cuts.root") tc contains a few TEntryLists that provide selected events for td. Using uproot I can load tc and can see the event-lists. The…
bungernut
  • 43
  • 5
1
vote
1 answer

Parsing a struct using 2D arrays using uproot

I need to read a root tree that contains a 2D array stored within a struct and would like to use uproot for this. For example: the following code-snippet creates a tree with both a 2D array and a 2D array within a struct. Uproot has no problem…
1
vote
0 answers

Reading ROOT files to dataframes: uproot slower than root_numpy's tree2array

I am trying to convert my flat ROOT ntuples into dataframes (via arrays). Currently, I am using root_numpy and would like to use uproot instead to avoid any ROOT dependencies. I have a list of string names of the 20 variables to save (from a total…
Dnoel
  • 11
  • 2
1
vote
1 answer

Saving TLorentzVector info in DataFrames for future analysis

I'm wondering about the recommended protocol for converting TLorentzVector information from .root files into Pandas DataFrames. So far, my strategy has been to save pT, eta, and phi information for each particle I care about. I then write my own…
mpettee
  • 13
  • 2
1
vote
0 answers

Writing a TH2 histogram in uproot

In uproot the example provided in the docs for writing a TH1 histogram to a root file works very well. Is it possible to do the same thing with TH2 as well? If yes, would it be possible to provide an example, and possibly include in the…
xaratustra
  • 647
  • 1
  • 14
  • 28
1
vote
2 answers

How to read file from s3 with uproot?

Is there a way to open a ROOT file using s3? ROOT support reading (but not writing) with TS3WebFile
Ruggero Turra
  • 16,929
  • 16
  • 85
  • 141
1
vote
1 answer

Copy TTree from file into a new file with uproot

I'm new to uproot and I am trying to achieve a fairly simply task, but I'm not sure how to do this. Essentially, I have a root file that contains a bunch of histograms and one TTree that is made up of 8 branches for roughly 4 million entries. What…
EichFlo
  • 11
  • 1
1
vote
0 answers

Automatic setting of dtypes when reading a ROOT file into a daskframe using uproot

I am trying to parallelize a (somewhat) simple script using dask. I originally read my ROOT file using uproot into a pandas.DataFrame in this way: import uproot file_name = "ntuple.root" tree_name = "Events" branches = ["Trigger", "nTracks",…
Graipher
  • 6,891
  • 27
  • 47
1
vote
1 answer

Uproot: AttributeError: 'module' object has no attribute 'open'

It seems uproot doesn't recognise "open". I'm using code from the documentation; import uproot file = uproot.open("http://scikit-hep.org/uproot/examples/nesteddirs.root") which returns AttributeError: 'module' object has no attribute 'open' I'm…
liv
  • 11
  • 2
1
vote
1 answer

How to get uproot.iterate() output identical to the root_numpy root2array() output with jagged arrays

I know that there is a solution for the similar question: How to get uproot.iterate() output like the root_numpy root2array() output fast But as I understand it is suitable for the flat ROOT TTrees only. I want to have generalized solution…
qwaiqir
  • 23
  • 3
1
vote
1 answer

Continuing to read tree data with compression issue with uproot

When reading data with uproot from a tree compressed with zlib, I find there are some compression errors from zlib, such as: Error -3 while decompressing data: incorrect data check or Error -5 while decompressing data: incomplete or truncated…
1
vote
2 answers

Reading TTree Friend with uproot

Is there an equivalent of TTree::AddFriend() with uproot ? I have 2 parallel trees in 2 different files which I'd need to read with uproot.iterate and using interpretations (setting the 'branches' option of uproot.iterate). Maybe I can do that by…
rdrien
  • 65
  • 4
1
vote
1 answer

How to write a tree with a jagged array as a branch?

I would like to write a tree with two branches. One branch contains a single number per fill and the other branch contains a variable length array per fill. From the documentation, I can see how to do the first, but not how to do the second?
olq_plo
  • 1,002
  • 10
  • 18
1
vote
2 answers

How to avoid "Too many open files" error when using uproot.daskframes to create daskframe from many ROOT files

I wanted to try using uproot to read a number of root files with flat ROOT NTupels into a desk frame. 214 files, 500kb each, about 8000 rows and 16 columns/variables in each. They easily fit in a pandas data frame in memory, but I am trying to learn…
Michael E.
  • 128
  • 1
  • 7
1
vote
0 answers

Troubles with importing uproot in Jupyter notebook

I have troubles importing uproot in jupyter notebooks since some time ago. It worked fine before and it still works fine when importing it in my other python scripts, but when I try to import it in jupyter notebook it says ModuleNotFoundError: No…
gasar8
  • 306
  • 4
  • 12