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
1 answer

How can I load a TTree with TVector3 branches into a Pandas DataFrame using uproot

I have several ROOT files containing a TTree with (among others) some branches that are TVector3 objects. I am trying to load the vector components (x, y, z) into a Pandas DataFrame, but I keep getting this error, no matter what I try: ValueError:…
Lukas Koch
  • 31
  • 4
1
vote
1 answer

How to efficiently retrieve tracks in uproot?

So I'm given a TFile that contains two TTree objects, which contain track/tower pT, eta and phi, divided by events. My goals is to extract each track and tower in the event and then cluster whole event using the FastJet package. Now, if I'm doing…
1
vote
1 answer

Content, starts and stops of ChunkedArray - built from lazyarray

I have some code that works fine for JaggedArrays extracting content, starts, stops, but I would like to run the same code on some ChunkedArrays, obtained from lazyarrays from uproot. Unfortunately, I obtained the following…
1
vote
1 answer

How to access a TGraph with uproot?

I'm trying to access a ROOT TGraph with uproot. In the uproot tutorial (https://github.com/scikit-hep/uproot#histograms-tprofiles-tgraphs-and-others) TGraphs are mentioned, but no where is written how to load them to python. Could somebody show me a…
FeWa
  • 141
  • 5
1
vote
1 answer

getting a histogram of a JaggedArray

Hi I have a ROOT TTree with a bit of a complicated structure. When I use uproot to create an array: analysis = uproot.open("/b/LJ_data/02Oct2019/FRVZ/FRVZprompt2zd_mH125_mzd01.root")["analysis"] el_Eratio = analysis.arrays(["el_Eratio"],…
1
vote
1 answer

Read a tree from a .root file and then make zero padded .h5 file

I have a .root file containing a tree named FlatSubstructureJetTreeD file = uproot.open("/data/debo/jetAnomaly/AtlasData/dijets/mergedRoot/miniTrees/user.cdelitzs.JZ2W.mini.root")["FlatSubstructureJetTreeD"] It has the following…
1
vote
1 answer

Strings in pandas dataframe from uproot

Working with simulations in Geant4 that outputs .root files, I was happy to discover the uproot package. Believing that dataframes are the best joice for my specific ananylsis task, I'm using uproot.pandas.df() to read contents from a TTree into…
Number42
  • 133
  • 2
  • 10
1
vote
1 answer

zero padding variable length of array in uproot

I need a memory efficient way to zero pad uneven array size per event according to largest array in a tree. Is there any way available to do that in uproot?
1
vote
1 answer

Arrays of strings from uproot

I have a tree with one branch storing a string. When I read using uproot.open() and then the method arrays() I get the following: >>> array_train['backtracked_end_process']
1
vote
1 answer

Trouble obtaining data from multiple *.root files...but no problems using only one

I am using pythong version 3.6.5 and have a jagged TTree with a multi-dimensional structure. This data is spread over more than 1000 files, all with the same identical TTree structure. suppose I have two files though and I'll call…
1
vote
2 answers

loading TProfile in Uproot issue getting y-values

I have trouble loading y-values from a TProfile object from my .root file. It seems using file.pandas() loads only the x-values, the counts and variances but not the specific y-values. I have tried file.values also, which returns counts, but not…
1
vote
1 answer

May I see a short example of cutting on data to prepare it for histogramming in uproot?

I have am using Python 3.6.5 (or higher) and I have successfully installed 'numpy', 'uproot', and 'awkward'. I have a previously made *.root file with a jagged NTuple which contains quite a large number of branches. This is particle physics data and…
1
vote
1 answer

Can JaggedArray counts innermost layer and return another JaggeredArray?

so_jaggered = awkward.fromiter([[[0, 1, 2]], [[0, 1], [2, 3]], [[0, 1, 2], [3, 4]]]) so_jaggered.counts Current version 0.12.13 returns array([1, 2, 2]) However, I want to count only the innermost part, which can be achieved by following…
1
vote
1 answer

How to combine two uproot jagged arrays into one

I am using uproot with awkward-array and have two jagged arrays containing the list of electrons per event and muons per event. How can I combine these to get the list of leptons per event i.e. concatenate the inner axis E.g. I have
1
vote
1 answer

Can't load data from uproot in Python

I am trying to load a Higgs Boson dataset from uproot. I am not comfortable with the use of uproot and the .root data type. I am using the following code which is a sort of official instructions to load the library. I have made a virtual environment…
Akash Kumar
  • 1,356
  • 1
  • 10
  • 28