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

Drawing several histograms in the same canvas with PyROOT in a loop

I am using PyROOT to try to loop over the files in a folder, get a specific histogram which is present in all the files (two in a minimal test) and draw all the histograms in the same canvas. The minimal example which I run with just two histograms…
Mil
  • 111
  • 7
1
vote
1 answer

Store histograms in a large array depending on location in for loop

I'm trying to store histograms in an array full of nested arrays that are created in multiple for a loop. The error that I am getting is that: 'TH1F' object has no attribute 'append' Here's an example of how the code works (a simplified…
JustTrying
  • 13
  • 4
1
vote
1 answer

Converting C++ to pyroot: How to get a file object from a file in pyroot?

I am doing neutrino research that requires me to do data analysis by overlaying histograms. We are using ROOT. I am currently trying to convert the following code from C++ to pyroot: #include "TFile.h" #include "TH1F.h" #include…
Kasey
  • 11
  • 2
1
vote
1 answer

Error installing rootpy: ROOT cannot be imported. Is ROOT installed with PyROOT enabled?

I am a 10.13.4 Mac user and I have ROOT 6.14.00 installed from running the dmg file downloaded from https://root.cern.ch/content/release-61400. I then tried to install rootpy by sudo pip install rootpy it gives me the error ROOT cannot be…
Joe Zhou
  • 11
  • 2
1
vote
1 answer

Reading a TTree branch using PyROOT

I like to read the content of a branch in TTree using PyROOT. I look for a possible solution to my problem here: Reading a TTree in root using PyRoot. However, the answer doesn't help me, because probabaly PyROOT doesn't know the structure of a…
Sadia Khalil
  • 41
  • 1
  • 5
1
vote
1 answer

rootpy installation probleme : Is ROOT installed with PyROOT enabled?

I have a big problem to install rootpy. When I try this command: sudo pip install rootpy I have this error message: ROOT cannot be imported. Is ROOT installed with PyROOT enabled? Command "python setup.py egg_info" failed with error code 1 in…
darkseall
  • 35
  • 5
1
vote
1 answer

Huge memory usage in pyROOT

My pyROOT analysis code is using huge amounts of memory. I have reduced the problem to the example code below: from ROOT import TChain, TH1D # Load file, chain chain = TChain("someChain") inFile = "someFile.root" chain.Add(inFile) nentries =…
Rob S
  • 37
  • 5
1
vote
1 answer

Accessing a friend TTree using pyROOT

I have a pyROOT script where I use TChain::AddFriend to combine two TTrees: from ROOT import TFile, gDirectory myfile = TFile("e.root") mychain = gDirectory.Get("elec_gen") entries = mychain.GetEntriesFast() friendFile =…
Rob S
  • 37
  • 5
1
vote
1 answer

Add a new branch to a TTree in a ROOT file with root_numpy (Python)

I would like to know how I could add a new branch to one of my TTree in a ROOT file using Python. with root_open('MC_output.root', mode='a') as myfile: new_column = numpy.array(gb_weights , dtype=[('weight', 'f8')]) …
alchauvi
  • 21
  • 5
1
vote
1 answer

Fitting gaussians to a ROOT histogram

I'm trying to write a program to fit several gaussians to a ROOT histogram, but unfortunately my inexperience with pyROOT is showing. I have a histogram of an emission spectrum of Ba133, and would like to fit gaussians to the peaks so that I know…
ponsly
  • 87
  • 9
1
vote
0 answers

Pyroot: Import Error: no module named handlers

I have been trying to build ROOT from source on my archlinux machine. I had gcc 5.3 which was not compatible with Cling so I downgraded to 4.9.3. Now the root build is successful but when I try to run a notebook in root I get the Import Error: No…
1
vote
1 answer

Pyroot AttributeError while importing histograms

I have a problem with pyroot. When I try to import a ROOT histogram I get the same AttributeError all the time. >>> from ROOT import TH1F AttributeError: type object 'TArray' has no attribute '__getitem__' During handling of the above exception,…
Joe
  • 13
  • 3
1
vote
1 answer

How to read branches in pyroot and make plots?

I'm completely new to Python and pyroot, and I want to write a small script in pyroot as a just practice. My root file has a subdirectory in which you can find a few trees some of which contains a few branches. What I am trying to do is making plots…
Damian
  • 11
  • 4
1
vote
1 answer

how to use TTreeReader in PyROOT

I'm trying to get up and running using the TTreeReader approach to reading TTrees in PyROOT. As a guide, I am using the ROOT 6 Analysis Workshop (http://root.cern.ch/drupal/content/7-using-ttreereader) and its associated ROOT file…
d3pd
  • 7,935
  • 24
  • 76
  • 127
1
vote
1 answer

pyroot Ntuple handler

I wanted to create class to handle the TTree: from ROOT import * from Exceptions import * import os.path class NTupleHandler: def __init__(self, fileName, eventType): if not os.path.isfile(fileName): raise InputError(…
user1877600
  • 627
  • 1
  • 9
  • 26