Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
physics_benchmarks
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
EIC
benchmarks
physics_benchmarks
Commits
1bb63fb2
Commit
1bb63fb2
authored
May 5, 2023
by
Tooba Ali
Browse files
Options
Downloads
Patches
Plain Diff
remove same_length_lists() function in benchmarks/dis/analysis/truth_reconstruction.py
parent
e04c3a03
No related branches found
No related tags found
1 merge request
!199
Draft: Use of JUGGLER_N_EVENTS=10000
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
benchmarks/dis/analysis/truth_reconstruction.py
+59
-81
59 additions, 81 deletions
benchmarks/dis/analysis/truth_reconstruction.py
with
59 additions
and
81 deletions
benchmarks/dis/analysis/truth_reconstruction.py
+
59
−
81
View file @
1bb63fb2
...
@@ -73,13 +73,13 @@ title_list = ['Theta','Momentum','Phi','Eta']
...
@@ -73,13 +73,13 @@ title_list = ['Theta','Momentum','Phi','Eta']
title_list_n
=
[
'
2
'
,
'
1
'
,
'
4
'
,
'
3
'
]
title_list_n
=
[
'
2
'
,
'
1
'
,
'
4
'
,
'
3
'
]
particle_name_n
=
{
'
Electrons
'
:
'
5
'
,
'
Pions
'
:
'
6
'
,
'
Photons
'
:
'
7
'
}
particle_name_n
=
{
'
Electrons
'
:
'
5
'
,
'
Pions
'
:
'
6
'
,
'
Photons
'
:
'
7
'
}
### MC Momentum for different particles list
### MC Momentum for different particles list
M_list
=
[
ak
.
Array
(
momentum_mc
[
simID
]),
M_list
=
[
np
.
array
(
ak
.
flatten
(
ak
.
Array
(
momentum_mc
[
simID
])
))
,
ak
.
Array
(
momentum_mc
[
simID
][
boolean_pion
]),
np
.
array
(
ak
.
flatten
(
ak
.
Array
(
momentum_mc
[
simID
][
boolean_pion
])
))
,
ak
.
Array
(
momentum_mc
[
simID
][
boolean_proton
]),
np
.
array
(
ak
.
flatten
(
ak
.
Array
(
momentum_mc
[
simID
][
boolean_proton
])
))
,
ak
.
Array
(
momentum_mc
[
simID
][
boolean_electron
]),
np
.
array
(
ak
.
flatten
(
ak
.
Array
(
momentum_mc
[
simID
][
boolean_electron
])
))
,
ak
.
Array
(
momentum_mc
[
simID
][
boolean_neutron
]),
np
.
array
(
ak
.
flatten
(
ak
.
Array
(
momentum_mc
[
simID
][
boolean_neutron
])
))
,
ak
.
Array
(
momentum_mc
[
simID
][
boolean_photon
])]
np
.
array
(
ak
.
flatten
(
ak
.
Array
(
momentum_mc
[
simID
][
boolean_photon
])
))
]
momentum_range
=
(
min
(
M_list
[
0
]),
max
(
M_list
[
0
]))
#Marker Size in plots
#Marker Size in plots
if
Nevents
==
100
:
if
Nevents
==
100
:
...
@@ -118,56 +118,45 @@ def error_bars(plot_x, plot_y, x_axis_range):
...
@@ -118,56 +118,45 @@ def error_bars(plot_x, plot_y, x_axis_range):
bin_HalfWidth
=
(
xedges
[
1
:]
-
xedges
[:
-
1
])
/
2
bin_HalfWidth
=
(
xedges
[
1
:]
-
xedges
[:
-
1
])
/
2
return
bin_Midpoint
,
mean
,
bin_HalfWidth
,
std
,
min_std
return
bin_Midpoint
,
mean
,
bin_HalfWidth
,
std
,
min_std
def
same_length_lists
(
plot_x
,
plot_y
):
X_length
=
ak
.
count
(
plot_x
,
axis
=
None
)
Y_length
=
ak
.
count
(
plot_y
,
axis
=
None
)
if
X_length
>
Y_length
:
F_boolean
=
np
.
ones_like
(
plot_y
)
==
1
else
:
F_boolean
=
np
.
ones_like
(
plot_x
)
==
1
return
F_boolean
boolean_tilt
=
list
(
np
.
zeros
(
len
(
M_list
)))
boolean_tilt
=
list
(
np
.
zeros
(
len
(
M_list
)))
for
i
in
range
(
len
(
MC_list
)):
#Repeat the following steps for each variable (theta,momentum,phi,eta)
for
i
in
range
(
len
(
MC_list
)):
#Repeat the following steps for each variable (theta,momentum,phi,eta)
MCparts
=
MC_list
[
i
]
#MCParticles events to be plotted on x-axis
MCparts
=
MC_list
[
i
]
#MCParticles events to be plotted on x-axis
RCparts
=
RC_list
[
i
]
#ReconstructedParticles events
RCparts
=
RC_list
[
i
]
#ReconstructedParticles events
X_list
=
[
ak
.
A
rray
(
MCparts
),
X_list
=
[
np
.
a
rray
(
ak
.
flatten
(
MCparts
)
)
,
ak
.
Array
(
MCparts
[
boolean_pion
]),
np
.
array
(
ak
.
flatten
(
MCparts
[
boolean_pion
])
)
,
ak
.
Array
(
MCparts
[
boolean_proton
]),
np
.
array
(
ak
.
flatten
(
MCparts
[
boolean_proton
])
)
,
ak
.
Array
(
MCparts
[
boolean_electron
]),
np
.
array
(
ak
.
flatten
(
MCparts
[
boolean_electron
])
)
,
ak
.
Array
(
MCparts
[
boolean_neutron
]),
np
.
array
(
ak
.
flatten
(
MCparts
[
boolean_neutron
])
)
,
ak
.
Array
(
MCparts
[
boolean_photon
])]
np
.
array
(
ak
.
flatten
(
MCparts
[
boolean_photon
])
)
]
Y_list
=
[
ak
.
A
rray
(
RCparts
),
Y_list
=
[
np
.
a
rray
(
ak
.
flatten
(
RCparts
)
)
,
ak
.
Array
(
RCparts
[
boolean_pion
]),
np
.
array
(
ak
.
flatten
(
RCparts
[
boolean_pion
])
)
,
ak
.
Array
(
RCparts
[
boolean_proton
]),
np
.
array
(
ak
.
flatten
(
RCparts
[
boolean_proton
])
)
,
ak
.
Array
(
RCparts
[
boolean_electron
]),
np
.
array
(
ak
.
flatten
(
RCparts
[
boolean_electron
])
)
,
ak
.
Array
(
RCparts
[
boolean_neutron
]),
np
.
array
(
ak
.
flatten
(
RCparts
[
boolean_neutron
])
)
,
ak
.
Array
(
RCparts
[
boolean_photon
])]
np
.
array
(
ak
.
flatten
(
RCparts
[
boolean_photon
])
)
]
X_plot
=
list
(
np
.
zeros
(
len
(
X_list
)))
X_plot
=
list
(
np
.
zeros
(
len
(
X_list
)))
Y_plot
=
list
(
np
.
zeros
(
len
(
X_list
)))
Y_plot
=
list
(
np
.
zeros
(
len
(
X_list
)))
Y_error
=
list
(
np
.
zeros
(
len
(
X_list
)))
Y_error
=
list
(
np
.
zeros
(
len
(
X_list
)))
####################################################################################################
#Ratio
####################################################################################################
for
j
in
range
(
len
(
X_list
)):
#Repeat the following steps for each particle (pions,protons,electrons,neutrons,photons)
for
j
in
range
(
len
(
X_list
)):
#Repeat the following steps for each particle (pions,protons,electrons,neutrons,photons)
F_boolean
=
same_length_lists
(
X_list
[
j
],
Y_list
[
j
])
X_s
=
np
.
array
(
ak
.
flatten
(
X_list
[
j
][
F_boolean
]))
#Filtered lists
Y_s
=
np
.
array
(
ak
.
flatten
(
Y_list
[
j
][
F_boolean
]))
if
i
==
1
:
#Momentum
if
i
==
1
:
#Momentum
ratio
=
np
.
array
((
ak
.
Array
(
Y_s
)
/
ak
.
Array
(
X_s
)))
ratio
=
Y_list
[
j
]
/
X_list
[
j
]
else
:
#Angle difference
else
:
#Angle difference
ratio
=
np
.
array
((
ak
.
Array
(
Y_s
)
-
(
ak
.
Array
(
X_s
))))
ratio
=
Y_list
[
j
]
-
X_list
[
j
]
X_plot
[
j
]
=
X_s
Y_plot
[
j
]
=
ratio
Y_plot
[
j
]
=
ratio
if
i
==
0
:
# for theta
if
i
==
0
:
#Theta
X_plot
[
j
]
=
-
X_plot
[
j
]
boolean_tilt_x
=
np
.
logical_and
(
X_list
[
j
]
>
0
,
X_list
[
j
]
<
0.5
)
boolean_tilt_x
=
np
.
logical_and
(
X_plot
[
j
]
<
0
,
X_plot
[
j
]
>
-
0.5
)
boolean_tilt_y
=
np
.
logical_or
(
Y_plot
[
j
]
<
-
0.02
,
Y_plot
[
j
]
>
0.02
)
boolean_tilt_y
=
np
.
logical_or
(
Y_plot
[
j
]
<
-
0.02
,
Y_plot
[
j
]
>
0.02
)
boolean_tilt
[
j
]
=
np
.
logical_and
(
boolean_tilt_x
,
boolean_tilt_y
)
boolean_tilt
[
j
]
=
np
.
logical_and
(
boolean_tilt_x
,
boolean_tilt_y
)
####################################################################################################
#Ratio
####################################################################################################
X_plot
=
X_list
if
i
==
0
:
#Theta
X_plot
=
-
1
*
np
.
array
(
X_plot
)
particle_nlist
=
[
'
All
'
,
'
Pions
'
,
'
Protons
'
,
'
Electrons
'
,
'
Neutrons
'
,
'
Photons
'
]
particle_nlist
=
[
'
All
'
,
'
Pions
'
,
'
Protons
'
,
'
Electrons
'
,
'
Neutrons
'
,
'
Photons
'
]
for
iterate
in
[
0
,
1
]:
for
iterate
in
[
0
,
1
]:
fig
=
plt
.
figure
()
fig
=
plt
.
figure
()
...
@@ -211,15 +200,10 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (the
...
@@ -211,15 +200,10 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (the
ax5
.
set_xlabel
(
'
- %s mc
'
%
(
title_list
[
i
]))
ax5
.
set_xlabel
(
'
- %s mc
'
%
(
title_list
[
i
]))
ax6
.
set_xlabel
(
'
- %s mc
'
%
(
title_list
[
i
]))
ax6
.
set_xlabel
(
'
- %s mc
'
%
(
title_list
[
i
]))
x_range
=
[
0
,
np
.
pi
]
x_range
=
[
0
,
np
.
pi
]
flatten_momentum
=
M_list
[
0
]
momentum_range
=
(
min
(
np
.
array
(
ak
.
flatten
(
flatten_momentum
))),
max
(
np
.
array
(
ak
.
flatten
(
flatten_momentum
))))
else
:
else
:
ax5
.
set_xlabel
(
'
%s mc
'
%
(
title_list
[
i
]))
ax5
.
set_xlabel
(
'
%s mc
'
%
(
title_list
[
i
]))
ax6
.
set_xlabel
(
'
%s mc
'
%
(
title_list
[
i
]))
ax6
.
set_xlabel
(
'
%s mc
'
%
(
title_list
[
i
]))
x_range
=
list
(
ax1
.
get_xlim
())
x_range
=
list
(
ax1
.
get_xlim
())
if
i
==
1
:
momentum_range
=
x_range
fig
.
set_figwidth
(
20
)
fig
.
set_figwidth
(
20
)
fig
.
set_figheight
(
10
)
fig
.
set_figheight
(
10
)
...
@@ -257,17 +241,7 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (the
...
@@ -257,17 +241,7 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (the
###################################################################################################
###################################################################################################
if
i
!=
1
:
#for each variable theta, phi, and eta
if
i
!=
1
:
#for each variable theta, phi, and eta
for
j
in
range
(
len
(
M_list
)):
#Repeat the following steps for each particle (pions,protons,electrons,neutrons,photons)
X_plot
=
M_list
X
=
X_list
[
j
]
Y
=
Y_list
[
j
]
M_mc
=
M_list
[
j
]
boolean_M
=
np
.
ones_like
(
M_mc
)
==
1
X_s
=
np
.
array
(
ak
.
flatten
(
X
[
boolean_M
]))
Y_s
=
np
.
array
(
ak
.
flatten
(
Y
[
boolean_M
]))
M_s
=
np
.
array
(
ak
.
flatten
(
M_mc
))
ratio
=
np
.
array
((
ak
.
Array
(
Y_s
)
-
(
ak
.
Array
(
X_s
))))
X_plot
[
j
]
=
M_s
Y_plot
[
j
]
=
ratio
title
=
'
difference vs momentum
'
title
=
'
difference vs momentum
'
particle_nlist
=
[
'
All
'
,
'
Pions
'
,
'
Protons
'
,
'
Electrons
'
,
'
Neutrons
'
,
'
Photons
'
]
particle_nlist
=
[
'
All
'
,
'
Pions
'
,
'
Protons
'
,
'
Electrons
'
,
'
Neutrons
'
,
'
Photons
'
]
...
@@ -325,9 +299,8 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (the
...
@@ -325,9 +299,8 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (the
###################################################################################################
###################################################################################################
#Repeat the following steps for each variable (theta,momentum,phi,eta)
#Repeat the following steps for each variable (theta,momentum,phi,eta)
F_boolean
=
same_length_lists
(
MCparts
,
RCparts
)
X_s
=
X_list
[
0
]
X_s
=
np
.
array
(
ak
.
flatten
(
MCparts
[
F_boolean
]))
#Filtered lists
Y_s
=
Y_list
[
0
]
Y_s
=
np
.
array
(
ak
.
flatten
(
RCparts
[
F_boolean
]))
#Histogram
#Histogram
fig
,
axs
=
plt
.
subplots
(
1
,
2
,
figsize
=
(
20
,
10
))
fig
,
axs
=
plt
.
subplots
(
1
,
2
,
figsize
=
(
20
,
10
))
...
@@ -367,29 +340,34 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (the
...
@@ -367,29 +340,34 @@ for i in range(len(MC_list)): #Repeat the following steps for each variable (the
def
particle_plots
(
boolean_particle
):
def
particle_plots
(
boolean_particle
):
#filtered lists w.r.t the particle
#filtered lists w.r.t the particle
theta_mc_fil
=
ak
.
Array
(
theta_mc
[
simID
])[
boolean_particle
]
theta_mc_filtered
=
np
.
array
(
ak
.
flatten
(
ak
.
Array
(
theta_mc
[
simID
])[
boolean_particle
]))
theta_rc_fil
=
ak
.
Array
(
theta_rc
[
recID
])[
boolean_particle
]
theta_rc_filtered
=
np
.
array
(
ak
.
flatten
(
ak
.
Array
(
theta_rc
[
recID
])[
boolean_particle
]))
phi_mc_fil
=
ak
.
Array
(
phi_mc
[
simID
])[
boolean_particle
]
phi_mc_filtered
=
np
.
array
(
ak
.
flatten
(
ak
.
Array
(
phi_mc
[
simID
])[
boolean_particle
]))
phi_rc_fil
=
ak
.
Array
(
phi_rc
[
recID
])[
boolean_particle
]
phi_rc_filtered
=
np
.
array
(
ak
.
flatten
(
ak
.
Array
(
phi_rc
[
recID
])[
boolean_particle
]))
theta_mc_filtered_with_tilt
=
np
.
array
(
ak
.
flatten
(
theta_mc
[
simID
])[
np
.
logical_and
(
ak
.
flatten
(
boolean_particle
),
boolean_tilt
[
0
])])
F_boolean
=
same_length_lists
(
theta_mc_fil
,
theta_rc_fil
)
theta_rc_filtered_with_tilt
=
np
.
array
(
ak
.
flatten
(
theta_rc
[
recID
])[
np
.
logical_and
(
ak
.
flatten
(
boolean_particle
),
boolean_tilt
[
0
])])
#filtered lists w.r.t length
phi_mc_filtered_with_tilt
=
np
.
array
(
ak
.
flatten
(
phi_mc
[
simID
])[
np
.
logical_and
(
ak
.
flatten
(
boolean_particle
),
boolean_tilt
[
0
])])
theta_mc_F
=
np
.
array
(
ak
.
flatten
(
theta_mc_fil
[
F_boolean
]))
phi_rc_filtered_with_tilt
=
np
.
array
(
ak
.
flatten
(
phi_rc
[
recID
])[
np
.
logical_and
(
ak
.
flatten
(
boolean_particle
),
boolean_tilt
[
0
])])
theta_rc_F
=
np
.
array
(
ak
.
flatten
(
theta_rc_fil
[
F_boolean
]))
phi_mc_F
=
np
.
array
(
ak
.
flatten
(
phi_mc_fil
[
F_boolean
]))
ratio
=
theta_rc_filtered
-
theta_mc_filtered
phi_rc_F
=
np
.
array
(
ak
.
flatten
(
phi_rc_fil
[
F_boolean
]))
ratio_tilt
=
theta_rc_filtered_with_tilt
-
theta_mc_filtered_with_tilt
ratio
=
np
.
array
((
ak
.
Array
(
theta_rc_F
)
-
(
ak
.
Array
(
theta_mc_F
))))
x_range
=
[
0
,
np
.
pi
]
x_range
=
[
0
,
np
.
pi
]
Y_error
=
[
error_bars
(
theta_mc_
F
,
ratio
,
x_range
),
error_bars
(
theta_rc_
F
,
ratio
,
x_range
)]
Y_error
=
[
error_bars
(
theta_mc_
filtered
,
ratio
,
x_range
),
error_bars
(
theta_rc_
filtered
,
ratio
,
x_range
)]
fig
=
plt
.
figure
()
fig
=
plt
.
figure
()
gs
=
fig
.
add_gridspec
(
3
,
2
,
wspace
=
0
,
hspace
=
0.3
)
gs
=
fig
.
add_gridspec
(
3
,
2
,
wspace
=
0
,
hspace
=
0.3
)
(
ax1
,
ax2
),
(
ax3
,
ax4
),
(
ax5
,
ax6
)
=
gs
.
subplots
(
sharex
=
True
,
sharey
=
'
row
'
)
(
ax1
,
ax2
),
(
ax3
,
ax4
),
(
ax5
,
ax6
)
=
gs
.
subplots
(
sharex
=
True
,
sharey
=
'
row
'
)
ax1
.
scatter
(
-
theta_mc_F
,
ratio
,
s
=
ssize
)
ax1
.
scatter
(
-
theta_mc_filtered
,
ratio
,
s
=
ssize
)
ax2
.
scatter
(
-
theta_rc_F
,
ratio
,
s
=
ssize
)
ax2
.
scatter
(
-
theta_rc_filtered
,
ratio
,
s
=
ssize
)
ax3
.
scatter
(
-
theta_mc_F
,
ratio
,
s
=
ssize
)
ax3
.
scatter
(
-
theta_mc_filtered
,
ratio
,
s
=
ssize
)
ax4
.
scatter
(
-
theta_rc_F
,
ratio
,
s
=
ssize
)
ax4
.
scatter
(
-
theta_rc_filtered
,
ratio
,
s
=
ssize
)
ax5
.
scatter
(
-
theta_mc_F
,
phi_mc_F
,
s
=
ssize
)
ax5
.
scatter
(
-
theta_mc_filtered
,
phi_mc_filtered
,
s
=
ssize
)
ax6
.
scatter
(
-
theta_rc_F
,
phi_rc_F
,
s
=
ssize
)
ax6
.
scatter
(
-
theta_rc_filtered
,
phi_rc_filtered
,
s
=
ssize
)
ax1
.
scatter
(
-
theta_mc_filtered_with_tilt
,
ratio_tilt
,
s
=
ssize
,
c
=
'
red
'
)
ax2
.
scatter
(
-
theta_rc_filtered_with_tilt
,
ratio_tilt
,
s
=
ssize
,
c
=
'
red
'
)
ax3
.
scatter
(
-
theta_mc_filtered_with_tilt
,
ratio_tilt
,
s
=
ssize
,
c
=
'
red
'
)
ax4
.
scatter
(
-
theta_rc_filtered_with_tilt
,
ratio_tilt
,
s
=
ssize
,
c
=
'
red
'
)
ax5
.
scatter
(
-
theta_mc_filtered_with_tilt
,
phi_mc_filtered_with_tilt
,
s
=
ssize
,
c
=
'
red
'
)
ax6
.
scatter
(
-
theta_rc_filtered_with_tilt
,
phi_rc_filtered_with_tilt
,
s
=
ssize
,
c
=
'
red
'
)
ax1
.
set_ylabel
(
'
Theta rc-mc
'
)
ax1
.
set_ylabel
(
'
Theta rc-mc
'
)
ax2
.
set_ylabel
(
'
Theta rc-mc
'
)
ax2
.
set_ylabel
(
'
Theta rc-mc
'
)
ax3
.
set_ylabel
(
'
Theta rc-mc
'
)
ax3
.
set_ylabel
(
'
Theta rc-mc
'
)
...
...
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