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

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

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","mytree"); t->SetMakeClass(1); //See note later TH1D *…
crisgen
  • 23
  • 3
1
vote
0 answers

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 was something like from concurrent.futures import…
1
vote
0 answers

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, but I can't seem to get the correct bin errors…
Wprime
  • 11
  • 1
1
vote
1 answer

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', 'impact_parameter;1'] >>> data['ring_sums']
HEP N008
  • 187
  • 8
1
vote
1 answer

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 to_numpy(self, flow, dd) 100 """ 101 …
giammi56
  • 154
  • 1
  • 15
1
vote
1 answer

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"] …
1
vote
1 answer

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 sure I don't mess stuff up. For instance, I have the…
HEP N008
  • 187
  • 8
1
vote
1 answer

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 padding to convert it into a numpy array, but I want…
1
vote
0 answers

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 using an event loop. The code seems to work as…
1
vote
1 answer

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 can see in the TBrowser in ROOT. I started the…
1
vote
1 answer

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?
xaxablyat
  • 27
  • 1
  • 7
1
vote
0 answers

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 them (eg. sum/add, normalised difference, etc..):…
giammi56
  • 154
  • 1
  • 15
1
vote
1 answer

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 =…
giammi56
  • 154
  • 1
  • 15
1
vote
2 answers

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 replot the existing graph through matplotlib or…
giammi56
  • 154
  • 1
  • 15