How can I extract data from root file into simple TXT?

Good day. I have a dna.root filer, which consist of points of ionisation and exitation x,y,z and energy depositions.

There are a track of 100 keV proton in dna.root file. How can I extract data from root file into a simple txt file with structure:
x1, y1, z1, energy1
ā€¦
xN,yN,zN,energyN
?

Hi,
I assume you have a TTree stored in the .root file (you can think of a TTree as a table with rows and columns).

Here is an example to read the contents of your TTree in python:

As you read, you can write the values of your branches to a .txt file.

1 Like