Skip to content
Snippets Groups Projects
Commit b1819196 authored by Jihee Kim's avatar Jihee Kim
Browse files

Added input ROOT file and simple code

parent 2981fcc8
Branches highfive-mpi
No related tags found
1 merge request!1Resolve "Upload Sample Data File"
...@@ -5,9 +5,9 @@ git clone https://eicweb.phy.anl.gov/jihee.kim/study.git ...@@ -5,9 +5,9 @@ git clone https://eicweb.phy.anl.gov/jihee.kim/study.git
cd study cd study
``` ```
Input Root Files Input File
---------------- ----------
- from lAger event generator - from `lAger` event generator
Scripts Scripts
------- -------
......
File added
#############################
# Read ROOT File
# Loop over event by event
# Print interested variables
#############################
import ROOT
# ROOT file that you read
fname = "input.root"
# Open file and get TTree
f = ROOT.TFile.Open(fname)
tree = f.Get("lAger")
print("=======")
print("Read in ROOT file: {}".format(fname))
# Total number of events in TTree
nevt = tree.GetEntries()
print ("total number of events: ",nevt)
# Loop over event by event
print("Loop over event by event")
for ievt in range(0,nevt):
# Access info of an event
tree.GetEntry(ievt)
if ievt % 5 == 0: # Printing
print("Processing event number: {}".format(ievt))
W = tree.W # invariant mass: sqrt(center of mass energy virtual photon + target (Helium-4))
Q2 = tree.Q2 # virtual photon mass: four-momentum transfer of electron
t = tree.t # four-momentum transfer of Helium-4
# Total number of particles in an event
nptls = tree.particles.GetEntries()
print (nptls)
ip = 0 # index of particles
# Loop over particles
for ptl in range(0,nptls):
# TODO: Access leaf and Save as in array
# infomration needed
# each particles have below info
# particles.fPdgCode / particles.fStatusCode / particles.fE / particles.fPx / particles.fPy / particles.fPz
# Not Working...
#PID = tree.particles[ptl].fPdgCode
#PID[ip] = tree.GetLeaf("particles.fPdgCode").GetValue(ptl)
ip += 1
#print (PID)
# Just checking the first 10 events
if ievt > 9:
break
pass
print("=======")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment