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

Does uproot4 not support tree.pandas.df()function anymore?

I used to retrieve pandas dataframe from ROOT file using tree.pandas.df() function in Uproot4(2 years ago). However, I got the below errors when I ran my code recently. Could anyone tell me what the problem is? f = uproot.open(inputFile) treeName =…
Zhen Yan
  • 59
  • 4
1
vote
1 answer

Is there an analog of coffea.processor.PackedSelection() for jagged array masks?

So in a coffea processor, I've implemented a series of cuts on the object level using a dictionary of jagged truth arrays, where each item is just a cut; think cuts['etacut'] = abs(events.cscRechitClusterEta) > 1.9. And if I want to superimpose…
aaportel
  • 471
  • 1
  • 3
  • 6
1
vote
1 answer

Recursion Error when Accessing Histograms from Root File using uproot in a Jupyter Notebook

I've made root files with histograms through another program, and I'm trying to extract this histograms in a Jupyter notebook using Python3 to do various bits of analysis on these histograms. In the past, this has been a non-issue, but I'm on a new…
1
vote
1 answer

Using the same counter branch for multiple array branches

I'm trying to output a TTree with the same general format as an input TTree which has the structure: ttree.show(datatypes.keys()) name | typename | interpretation …
1
vote
0 answers

Slash in keyname

This might be a stupid question but unfortunately I have root files which contain keys with names such as "DQMInfo/runno". This is the the actual name. Because it represents a 2d histogram someone thought that it would be a good idea to indicate…
1
vote
0 answers

How to save Numpy array to root file using uproot4

I'm trying to save a large amount of Numpy arrays to a root file using uproot. I've read through the uproot documentation, and as far as I can tell this ability was remove in uproot3. Note I can't save this as a histogram because the order of the…
1
vote
1 answer

Multiprocessing uproot approach

I just started looking into parallelizing the analysis of rootfiles, i.e. trees. I have worked with RDataFrames where implicit multiprocessing can be enabled with one line of code (EnableImplicitMT()). This works quite well. Now I want to experiment…
Jailbone
  • 83
  • 6
1
vote
1 answer

Trying to improve Uproot4 Root tree file input deserialization of one branch

I am using Uproot to access a Root Tree in Python and I am noticing a significant slowdown when I try to access one particular branch: wf, which contains an array of jagged arrays Root Tree Branches I am accessing the branches by using the…
1
vote
1 answer

TLorentz vector features in uproot4/vector when calculating invariant mass of a jet

I wish to sum all the 4-momenta of the constituents in a jet. In uproot3 (+ uproot3-methods) there was the functionality of creating a TLorentzVectorArray and just doing .sum() So this worked fine: import uproot3 import akward0 as ak input_file =…
LauritsT
  • 57
  • 6
1
vote
0 answers

Set interpretation as multi dim array when reading TBranchElement

I have a file that contains TGeoTracks on one branch element. TGeoTracks have two private members that I'm interested in, a number of points and an array that's 4*nPoints (https://root.cern.ch/doc/master/TGeoTrack_8h_source.html#l00040). private : …
RemusKaos
  • 43
  • 8
1
vote
1 answer

Uproot issue: Trouble making sense of a particular 'branch'

I have a root file open in python as such: file = uproot.open('C:\\Users\\me\\Documents\\test.root') print(file.keys()) [b'evts;1', b'miscAccum;1', b'cal;1', b'configstr;1', b'time;1', b'Plugs;1', b'acc;1'] print(file[b'Plugs'].keys()) [b'veto;1',…
Canuck
  • 567
  • 1
  • 7
  • 15
1
vote
0 answers

changing names of branches in root file

I have a root file with one TTree and 57 branches. I would like to transform this to a root file with just 40 of those branches, with their names changed. I'm doing this with python. What's the best way to go about this? Should I create a new root…
Dizzy
  • 33
  • 3
1
vote
2 answers

Use a multidimensional index on a MultiIndex pandas dataframe?

I have a multiindex pandas dataframe that looks like this (called p_z): p_z entry subentry 0 0 0.338738 1 0.636035 2 -0.307365 3 -0.167779 4 0.243284 ... …
HEP N008
  • 187
  • 8
1
vote
0 answers

TParameter has no attribute "value"

I have this TParameter (a Model_TParameter_3c_double_3e__v2 to be precise) which I am trying to access via its "value" attribute which I have seen to use via the docs here uproot.open("pathtoTParameter").value But that doesn't work and spits…
Colm
  • 73
  • 5
1
vote
1 answer

TH2D object to NumPy with bin labels

I have a 2D correlation matrix between nuisance parameters that are used in a likelihood fit. I would like to translate this to NumPy to use with other vis libraries. The problem is TH2D.edges returns the bin index and I need the bin label, i.e.…