Ploting data from a .root file in PyROOT

1.1k Views Asked by At

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 data from the root file, but since inside the file there is multiple data my approaches failed(and i think i was far from any solution, so i didn't post my codes). I couldn't find any of their tutorials and examples that could help me in this task. So i would appreciate any help.

And there is anyway to see what is inside a .root file?

I am new to all of this, so any references or tips would be very valuable to me.

1

There are 1 best solutions below

0
On BEST ANSWER

Gladly i was able to solve my problem, so i am going to share it with you.

In order to be able to see the data inside a .root file, you can simply start root in the terminal and then type the following command:

TBrowser t;

It will open a window where you can navigate through .root files.

And to choose a file to plot inside a .root you can use:

histFile = root.TFile.Open(histFileName,"READ")

to open the .root and

h_zee = histFile.Get("zee")

to choose one of the histograms or scatter points inside of it to work with.