Questions tagged [uproot]
A library for reading [root-framework] data into [numpy] and [awkward-array].
94
questions
1
vote
1
answer
62
views
How can I "dump" / get the content of objects of "experiment specific" / "custom" classes (from a TTree)
I am trying to use Uproot to read some existing trees.
I can open the ROOT file with trees, I can "get" the trees and "show" their branches.
I've met branches for which I don't ...
1
vote
1
answer
23
views
Getting i-th element of branch with uproot
I am using uproot to read root files in Python. My files are such that I am doing this:
ifile = uproot.open(path_to_root_file)
metadata = ifile['Metadata']
waveforms = ifile['Waveforms']
waveforms....
1
vote
1
answer
23
views
How can I resolve the 'Basket data should be added to all branches' exception when writing to a TTree with Uproot?
Reading from an ntuple and saving into a new ntuple, after many iterations over events, getting the following:
utils.writeTree(outf, ltree, outtreename, brs)
File "/srv01/agrp/roybr/...
1
vote
0
answers
74
views
Not reading / opening of root file from uproot
I am trying to read a file.root using ** uproot** but it's throwing back this error :-
File "/Users/siddharthkeshar/opt/anaconda3/lib/python3.9/site-packages/uproot/source/chunk.py", line ...
2
votes
1
answer
46
views
Casting a char* type on a Branch using mktree
I'm trying to recreate a root file that contains a char* type branch (which is interpreted by uproot as AsStrings())
When using mktree uproot doesn't recognize the np.dtype('string') and when trying ...
2
votes
0
answers
101
views
Trees written with uproot, cannot be read properly
I have created a script that reads from some root files, does some processing, and creates a slimmed version of these files, using uproot3 (3.14.4).
Then I use these files I created to create ...
1
vote
1
answer
46
views
how to add new field in a 'zip' jagged array
I want to add a new field in an already zipped jagged array. For example, if I zip 4D info into a muons object, then I can call pt,eta,phi,charge like this: muons.Muon.pt. However, if I want to add a ...
1
vote
1
answer
294
views
Copy TTree to Other File
I'm trying to extract cycles/revisions ("TreeName;3" etc) from one root file and make them their own trees in a new one. I tried doing it by creating a new file and assigning it to a new ...
2
votes
0
answers
56
views
Histogram bin edges read wrong in uproot 4
Edit: this is a version problem. Uproot 4.3.7 produces the expected result, while the error below occurred in 4.0.0
I am creating 1-D histograms in ROOT with non-uniform bin sizes, then accessing them ...
1
vote
1
answer
309
views
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 ...
1
vote
1
answer
40
views
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....
1
vote
1
answer
93
views
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 ...
2
votes
0
answers
33
views
How to access contents of a TLorentz vector using python code
I am using the uproot package in python to read a .root file, and I need to access the contents of pf. As you can see from the picture, I can easily access the content of vz (blue arrows). However, ...
1
vote
1
answer
114
views
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 ...
0
votes
0
answers
364
views
Rebinning a TH2 histogram from ROOT using uproot and then plot it with matplotlib
I am able to extract a TH2 histogram from ROOT using the h = f[...].to_numpy() of uproot.
This I can then plot with mplhep as a hist2dplot(h).
However, I have the problem that I would like to rebin ...
1
vote
0
answers
48
views
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 ...
1
vote
0
answers
534
views
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 ...
1
vote
1
answer
163
views
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())....
3
votes
1
answer
338
views
Writing Trees, number of baskets and compression (uproot)
I am trying to optimize the way trees are written in pyroot and came across uproot. In the end my application should write events (consisiting of arrays) to a tree which are continuously coming in.
...
1
vote
1
answer
214
views
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 ...
1
vote
1
answer
239
views
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:
...
1
vote
0
answers
51
views
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/...
1
vote
1
answer
145
views
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'...
0
votes
1
answer
917
views
Reading TH1D and TH2D histograms in uproot
I have a file in cern root format which contains a number of TH1D and TH2D histograms. I'd like to be able to plot these by using uproot4 to read them, then matplotlib to do the plotting.
I can open ...
1
vote
0
answers
225
views
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 ...
1
vote
2
answers
476
views
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 ...
1
vote
0
answers
54
views
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("...
1
vote
1
answer
83
views
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 ...
1
vote
0
answers
143
views
Read TEfficiency with uproot
I have a ROOT file with some TDirectories and TEfficiency contained in them. I need to extract the data from those for further processing.
file = uproot.open("myroot.root")
my_directory = ...
1
vote
2
answers
310
views
Reading a branch of TH1Ds
I am trying to read a branch of TH1D objects in uproot4. A sample rootfile can be created with:
TFile * f = new TFile("new.root","RECREATE");
TTree * t = new TTree("mytree&...
1
vote
0
answers
132
views
Memory problem in parallel processing while using uproot 4, it wasn't the case in uproot 3
I have this root file which is available on Google drive at this link, and when I used to convert it to arrays in root 3 using parallel processing, it took less time and memory. The code I was using ...
1
vote
0
answers
258
views
Writing a boost-histogram to a root file created in uproot
I am currently trying to read in a ROOT tree with uproot, book and fill histograms with boost-histogram and write these back out to a new ROOT file.
This seems to work very well for the bin contents, ...
1
vote
1
answer
120
views
How do I read a TMatrixT with uproot in Python?
I have a *.root file I'm trying to read into Python with uproot (uproot4). It looks like this:
>>> data = up.open('file.root')
>>> data.keys()
['ring_sums;1', 'tpc_multiplicity;1', '...
1
vote
1
answer
106
views
Model_TH3D_v3 on uproot4
I am trying to import a TH3 v3 file from .root, but I get the following error message:
----> 3 a=fileRCL[filename].to_numpy()
~/anaconda3/lib/python3.8/site-packages/uproot/behaviors/TH3.py in ...
1
vote
1
answer
96
views
awkward array ak.unzip behaviour
When I acess a root file and extract the data I want like in following example:
events=uproot.open(filename)["btagana/ttree;6"]
jet_data=events.arrays(filter_name=["Jet_nFirstTrack&...
2
votes
1
answer
238
views
Can uproot3 write TBranches containing arrays?
In uproot 3 documentation there is information, that uproot can write only branches containing 1 value per entry. On the other hand, I can see some topics on uproot Github regarding writing jagged ...
1
vote
1
answer
145
views
ROOT functions in upROOT?
I'm trying to run analysis strictly in Python using upROOT, but I'm finding (unsurprisingly) that I have to build a lot of tools that are already in ROOT. I don't mind doing it, but I want to make ...
1
vote
1
answer
262
views
Awkward array add attributes in intervals
I want to extract data out of a root file and get it into shape to end with a numpy array/tensor to fill it into a neural-network. I am already able to get the track data I want in shape with a ...
2
votes
0
answers
98
views
Can uproot4 write TTrees?
uproot3 had some limited writing capabilities, is writing TTrees possible in uproot4? In particular, I would like to create a skim, just discarding branches and one or two simple event-level cuts.
2
votes
2
answers
286
views
Reshape Array in Array in Array
I have a root file that I open with 2000 entries, and variable amount of subentries and in each column is a different variable. Lets say I am only interested in 5 of those. I want to put them in an ...
2
votes
0
answers
171
views
Read parts of a tree with uproot4
I have a single file with a single ROOT tree and would like to read it with uproot4 in multiple processes, with each of them reading disjoint parts of the tree.
With uproot3 this was possible by ...
1
vote
0
answers
995
views
How can I load many very large files using uproot?
I am using a CMSSW_11_1_4 environment (Python 3.8.4, uproot 3.11.3, awkward 0.12.20) and I am trying to open a few very large .root files (3 files, 9 GB each) and iterate over some of their branches ...
1
vote
1
answer
382
views
uproot question: The full TTree structure I can see in a TBrowser is not appearing in uproot
Summary: TTree branches seem to go missing when running the uproot tutorial.
I have a root file that contains a TTree called 'prod' which has a complicated set of jagged leaves and branches which I ...
2
votes
1
answer
85
views
Import dataset from a ROOT file with cut using zfit
I am trying to perform a fit to a tree. But I need to add some cut to the branches which are not the observables of the fit.
Website https://zfit.readthedocs.io/en/latest/getting_started/intro/data....
1
vote
1
answer
757
views
Uproot: Add branch to existing TTree in root file
I am trying to use uproot to add a branch to an existing TTree that I have in a .root file. Is it possible to this with uproot?
1
vote
0
answers
49
views
uproot: allowed operations between TH2D histograms
I am trying to translate my data analysis workflow into python from C++. I have a very basic question: I have loaded two TH2D objects, unstuck them, and now I want to perform some operations between ...
1
vote
1
answer
241
views
uproot: processing a TH2D using the uproot method .pandas()
I am very new to uproot and Python, but hopefully catching up quickly.
I am wondering why the method .pandas() is creating such a weird table from a TH2D histogram:
myhisto = file["...
1
vote
2
answers
2k
views
uproot: best way to load and replot a TH2 histogram from a .root file on a jupyter notebook
I am very new to python and uproot. Previously, I have been using ROOT in a C++ environment.
Following the uproot tutorial, I can read my TH2D graphs from a .root file
I want now to recreate and ...
1
vote
0
answers
134
views
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 ...
2
votes
0
answers
344
views
Flattening of 3x3 arrays in uproot.pandas.iterate
I'm trying to modify one of my existing scripts that uses uproot to read data from a root file into a pandas dataframe using uproot.pandas.iterate. Currently it only reads branches containing simple ...