Questions tagged [pyroot]

`PyROOT` is a Python extension module that allows the user to interact with any `ROOT` class from the Python interpreter.

PyROOT is a Python extension module that allows the user to interact with any ROOT class from the Python interpreter. This is done generically using the ROOT dictionary, therefore there is no need to generate any Python wrapper code to include new ROOT classes. At the same time PyROOT offers the possibility to execute and evaluate any Python command or start a Python shell from the ROOT/CINT prompt. Further details are available in the PyROOT manual.

See more:

56 questions
6
votes
0 answers

Python C API: omitted variable assignment causes unexpected behaviour

While using python with pyroot (a python interface to a CERN data analysis package named ROOT), I encountered the following strange behaviour: print ROOT.TFile(fname).GetListOfKeys() outputs None while the seemingly semantically equivalent…
user2247306
  • 183
  • 4
5
votes
0 answers

Pycharm SSH remote interpreter: editor doesn't recognize module

I'm currently trying to get PyCharm running with a remote interpreter via SSH. The connection itself is working well, however one of my imported modules "ROOT" is not recognized by the editor ("No module named ROOT" at the "import ROOT"…
0vbb
  • 839
  • 11
  • 27
5
votes
2 answers

python argparse don't show correct help message

I have a python script using argparse. After typing in python script_name.py -h on the command line, it shows help message for another command but the code still works. The script can recognize options defined in it and run well. It looks like the…
Yicheng
  • 71
  • 7
4
votes
1 answer

Reading a TTree in root using PyRoot

I just started using pyroot to read root files and I can't read the data from a file using jupyter notebook. Here is how the TBrowser looks like: I started like this: import ROOT as root import numpy as np f = root.TFile("RealData.root") myTree =…
Silviu
  • 749
  • 3
  • 7
  • 17
4
votes
2 answers

Declaring a TTree Branch in PyRoot

I am trying to simply define a Root TTree using python and give it a TBranch. Sounds reasonable, right? I tried: from ROOT import * myvar = int() mytree = TTree('mytree', 'mytree') tree.Branch('myvar', AddressOf(myvar), 'myvar/I') exit(0) and this…
user3458163
  • 41
  • 1
  • 3
3
votes
4 answers

pyROOT in virtualenv

I want to use pyROOT in a virtualenv, I have ROOT installed on my system, when outside the virtualenv I can do import ROOT and it works, but inside a virtualenv doing an import ROOT gives the following error: ModuleNotFoundError: No module named…
A Deshmukh
  • 43
  • 8
2
votes
1 answer

Creating a TTree with Branches in Using Root through Python

I am trying to create a tree with branches in root through python. I have a .root file and I am trying to create branches that are the variables (or data pts) of my .root file. Here is my attempt: f = ROOT.TFile('event.root', 'read') #opening the…
usernew
  • 125
  • 1
  • 13
2
votes
0 answers

Reading Values using PyROOT

I am trying to read out values from a ROOT file using PyROOT and is stuck with this issue. Any help is appreciated. import ROOT rootFile = "file.root" f = ROOT.TFile(rootFile,'read') tree = f.Get('FCS_ParametrizationInput') leaves =…
Ananda
  • 2,925
  • 5
  • 22
  • 45
2
votes
2 answers

pyLCIO setMomentum: error const float* in python

Context: I am implementing a particle physics library called LCIO that is C++ code, but there is a python wrapper called pyLCIO. When trying to run a function called setMomentum() the C++ implementation looks like this: void setMomentum (const…
Tsangares
  • 780
  • 1
  • 9
  • 27
2
votes
1 answer

ImportError: No module named ROOT when using yoda2root

I'm trying to convert a yoda file produced by a Rivet analysis into a Root file. When I try to do this, I get the error: yoda2root Rivet.yoda test.root Traceback (most recent call last): File "/usr/local/bin/yoda2root", line 24, in module import…
R. Pickles
  • 21
  • 3
1
vote
0 answers

ROOT - pyroot: Branch seen as leaf, can't access actual leaves

I am trying to extract information from a root file using pyroot. I tried using the usual GetBranch, GetLeaf, GetValue but it does not work as usual, so I tried alternatives. I found an equivalent code in c++ which is extracting the values just fine…
Alheana
  • 139
  • 1
  • 4
1
vote
1 answer

Executing a python script through .sh or .desktop file not working

I am setting up a PC running Ubuntu 20.04.3 with a touchscreen and no keyboard/mouse. Due to this, I am putting desktop icons that will run the software needed for data taking/analysis. I was able to set one up with no problem first using a .sh file…
1
vote
1 answer

Ploting data from a .root file in PyROOT

I am starting to work with PyROOT, and so i was studding the following example: https://root.cern.ch/doc/master/pyroot_2fillrandom_8py.html At the end of the code, it saves some data in the py-fillrandom.root file. And so, i wanted to plot the…
Matthew D.
  • 311
  • 1
  • 3
  • 10
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

Performance of Random number generators of pyroot and random

I was looking to optimize a simple given code that generates a random number ([0,1,2]) that is not in a given list. The random number generator is TRandom3 from ROOT. def getNumber(noList, randomgen): #Fügen Sie hier Ihren Code ein!: i =…
1
2 3 4