Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Study
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jihee Kim
Study
Commits
b1819196
Commit
b1819196
authored
Apr 24, 2021
by
Jihee Kim
Browse files
Options
Downloads
Patches
Plain Diff
Added input ROOT file and simple code
parent
2981fcc8
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1
Resolve "Upload Sample Data File"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+3
-3
3 additions, 3 deletions
README.md
sample/input.root
+0
-0
0 additions, 0 deletions
sample/input.root
sample/read_and_print.py
+56
-0
56 additions, 0 deletions
sample/read_and_print.py
with
59 additions
and
3 deletions
README.md
+
3
−
3
View file @
b1819196
...
@@ -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
File
s
Input File
----------
------
----------
-
from lAger event generator
-
from
`
lAger
`
event generator
Scripts
Scripts
-------
-------
...
...
This diff is collapsed.
Click to expand it.
sample/input.root
0 → 100644
+
0
−
0
View file @
b1819196
File added
This diff is collapsed.
Click to expand it.
sample/read_and_print.py
0 → 100644
+
56
−
0
View file @
b1819196
#############################
# 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
(
"
=======
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment