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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EIC
benchmarks
physics_benchmarks
Merge requests
!151
Kinematics correlations
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Kinematics correlations
kinematics-correlations
into
master
Overview
0
Commits
29
Pipelines
0
Changes
4
Merged
Tooba Ali
requested to merge
kinematics-correlations
into
master
3 years ago
Overview
0
Commits
29
Pipelines
0
Changes
4
Expand
Correlation plots of Q2 and x for Electron and Double Angle methods.
Edited
2 years ago
by
Tooba Ali
0
0
Merge request reports
Compare
master
version 29
6ccc50cc
2 years ago
version 28
3bef8354
2 years ago
version 27
cdb58b3c
2 years ago
version 26
6dcb419e
2 years ago
version 25
d88682a5
2 years ago
version 24
9fa04add
2 years ago
version 23
6874573e
2 years ago
version 22
45c2e1dd
2 years ago
version 21
61d494c9
2 years ago
version 20
6174e7c9
2 years ago
version 19
cf682a8f
2 years ago
version 18
27902d8a
2 years ago
version 17
b6d0703a
2 years ago
version 16
22956461
2 years ago
version 15
1de3fbb6
2 years ago
version 14
cbc7cac0
2 years ago
version 13
4b4e46e4
2 years ago
version 12
b6cba791
2 years ago
version 11
6547259f
2 years ago
version 10
2d50d0b3
2 years ago
version 9
da73af91
2 years ago
version 8
6ade9d3b
2 years ago
version 7
6e210781
2 years ago
version 6
7f5024bd
3 years ago
version 5
4c55fa4c
3 years ago
version 4
f6992965
3 years ago
version 3
a371eea8
3 years ago
version 2
db096cbf
3 years ago
version 1
4befd228
3 years ago
master (base)
and
latest version
latest version
dc33d0df
29 commits,
2 years ago
version 29
6ccc50cc
29 commits,
2 years ago
version 28
3bef8354
28 commits,
2 years ago
version 27
cdb58b3c
27 commits,
2 years ago
version 26
6dcb419e
26 commits,
2 years ago
version 25
d88682a5
25 commits,
2 years ago
version 24
9fa04add
24 commits,
2 years ago
version 23
6874573e
23 commits,
2 years ago
version 22
45c2e1dd
22 commits,
2 years ago
version 21
61d494c9
21 commits,
2 years ago
version 20
6174e7c9
20 commits,
2 years ago
version 19
cf682a8f
19 commits,
2 years ago
version 18
27902d8a
18 commits,
2 years ago
version 17
b6d0703a
17 commits,
2 years ago
version 16
22956461
16 commits,
2 years ago
version 15
1de3fbb6
15 commits,
2 years ago
version 14
cbc7cac0
14 commits,
2 years ago
version 13
4b4e46e4
13 commits,
2 years ago
version 12
b6cba791
12 commits,
2 years ago
version 11
6547259f
11 commits,
2 years ago
version 10
2d50d0b3
10 commits,
2 years ago
version 9
da73af91
9 commits,
2 years ago
version 8
6ade9d3b
8 commits,
2 years ago
version 7
6e210781
7 commits,
2 years ago
version 6
7f5024bd
6 commits,
3 years ago
version 5
4c55fa4c
5 commits,
3 years ago
version 4
f6992965
4 commits,
3 years ago
version 3
a371eea8
3 commits,
3 years ago
version 2
db096cbf
2 commits,
3 years ago
version 1
4befd228
1 commit,
3 years ago
4 files
+
199
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
benchmarks/dis/analysis/kinematics_correlations.py
0 → 100644
+
177
−
0
Options
#!/usr/bin/env python
# coding: utf-8
import
os
import
numpy
as
np
import
uproot
as
ur
import
awkward
as
ak
import
matplotlib.pyplot
as
plt
import
matplotlib
as
mpl
import
mplhep
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
--rec_file
'
,
type
=
str
,
help
=
'
Reconstructed track file.
'
)
parser
.
add_argument
(
'
--ebeam
'
,
type
=
float
,
help
=
'
Electron beam energy.
'
)
parser
.
add_argument
(
'
--pbeam
'
,
type
=
float
,
help
=
'
Proton (or ion) beam energy.
'
)
parser
.
add_argument
(
'
--minq2
'
,
type
=
float
,
help
=
'
Minimum four-momentum transfer squared Q2.
'
)
parser
.
add_argument
(
'
-o
'
,
dest
=
'
outdir
'
,
default
=
'
results/dis/
'
,
help
=
'
Output directory.
'
)
args
=
parser
.
parse_args
()
kwargs
=
vars
(
args
)
rec_file
=
args
.
rec_file
minq2
=
int
(
args
.
minq2
)
k
=
int
(
args
.
ebeam
)
p
=
int
(
args
.
pbeam
)
#logarithmically spaced bins in Q2 and 𝑥
Q2_bins
=
[
0.40938507
,
0.64786184
,
1.025353587
,
1.626191868
,
2.581181894
,
4.091148983
,
6.478618696
,
10.25353599
,
16.26191868
,
25.81181894
,
40.91148983
,
64.78618696
,
102.5353599
,
162.6191868
,
258.1181894
,
409.1148983
,
647.8618696
,
1025.353599
,
1626.191868
,
2581.181894
,
4091.148983
,
6482.897648
]
x_bins
=
[
4.09385E-05
,
6.47862E-05
,
0.000102535
,
0.000162619
,
0.000258118
,
0.000409115
,
0.000647862
,
0.001025354
,
0.001626192
,
0.002581182
,
0.004091149
,
0.006478619
,
0.010253536
,
0.016261919
,
0.025811819
,
0.04091149
,
0.064786187
,
0.10253536
,
0.162619187
,
0.25811819
,
0.409114898
,
0.647861868
,
1.025257131
]
#function to construct Q2 correlation plots
def
Q2correlation
(
minq2
,
method
):
#minq2 can be 1,10,100, or 1000; method can be 'E','DA', or 'JB'
Q2values_Y
=
method_Q2values_dict
[
'
{}
'
.
format
(
method
)]
#Q2 values of the given method, that are mapped onto the y axis
Q2_List_T
=
Q2values_T
[
'
{}
'
.
format
(
minq2
)]
#Truth Q2 values for given minq2, mapped along x axis
Q2_List_Y
=
Q2values_Y
[
'
{}
'
.
format
(
minq2
)]
#method (E/DA/JB) Q2 values for given minq2, mapped along y axis
T_len
=
ak
.
count
(
Q2_List_T
,
axis
=
0
)
#total number of events in Truth
Y_len
=
ak
.
count
(
Q2_List_Y
,
axis
=
0
)
#total number of events in method
if
T_len
>
Y_len
:
#if total number of events for Truth is greater
Y_boolean
=
ak
.
count
(
Q2_List_Y
,
axis
=-
1
)
>=
1
#boolean to filter ak.Arrays wrt single events in method
Q2_List_T_F
=
Q2_List_T
[
Y_boolean
]
#filtered Truth Q2 values
Q2_List_Y_F
=
Q2_List_Y
[
Y_boolean
]
#filtered method Q2 values
else
:
#if total number of events for method is greater
T_boolean
=
ak
.
count
(
Q2_List_T
,
axis
=-
1
)
>=
1
#boolean to filter ak.Arrays wrt single events in Truth
Q2_List_T_F
=
Q2_List_T
[
T_boolean
]
#filtered Truth Q2 values
Q2_List_Y_F
=
Q2_List_Y
[
T_boolean
]
#filtered method Q2 values
T_Q2s
=
np
.
array
(
ak
.
flatten
(
Q2_List_T_F
))
#Truth Q2 values, mapped along x axis
Y_Q2s
=
np
.
array
(
ak
.
flatten
(
Q2_List_Y_F
))
#methos Q2 values, mapped along y axis
#2-dimensional histogram, h
h
,
xedges
,
yedges
=
np
.
histogram2d
(
x
=
T_Q2s
,
y
=
Y_Q2s
,
bins
=
[
Q2_bins
,
Q2_bins
])
minq2_dict
=
{
'
1
'
:
2
,
'
10
'
:
7
,
'
100
'
:
12
,
'
1000
'
:
17
}
#Q2 bin index at which minq2 starts
h
[
0
:
minq2_dict
[
'
{}
'
.
format
(
minq2
)]]
=
0
#ignore values before minq2
#normalization of h:
col_sum
=
ak
.
sum
(
h
,
axis
=-
1
)
#number of events in each (verticle) column
norm_h
=
[]
#norm_h is the normalized matrix
norm_h_text
=
[]
#display labels matrix
for
i
in
range
(
len
(
col_sum
)):
if
col_sum
[
i
]
!=
0
:
norm_c
=
h
[
i
]
/
col_sum
[
i
]
#normalized column = column values divide by sum of the column
else
:
norm_c
=
h
[
i
]
norm_h
.
append
(
norm_c
)
norm_c_text
=
[
'
%.3f
'
%
elem
for
elem
in
norm_c
]
#display value to 3 dp
norm_h_text
.
append
(
norm_c_text
)
fig
=
plt
.
figure
()
mplhep
.
hist2dplot
(
H
=
norm_h
,
norm
=
mpl
.
colors
.
LogNorm
(),
labels
=
norm_h_text
,
xbins
=
Q2_bins
,
ybins
=
Q2_bins
,
cmax
=
1
,
cmin
=
1e-5
)
plt
.
yscale
(
'
log
'
)
plt
.
xscale
(
'
log
'
)
fig
.
set_figwidth
(
11
)
fig
.
set_figheight
(
11
)
plt
.
xlabel
(
'
$Q^2$ [$GeV^2$] Truth
'
)
plt
.
ylabel
(
'
$Q^2$ [$GeV^2$] {}
'
.
format
(
method_dict
[
'
{}
'
.
format
(
method
)]))
plt
.
title
(
'
{} $Q^2$ correlation {}x{} $minQ^2=${}$GeV^2$
'
.
format
(
method_dict
[
'
{}
'
.
format
(
method
)],
k
,
p
,
minq2
))
plt
.
show
()
plt
.
savefig
(
os
.
path
.
join
(
args
.
outdir
,
'
%gon%g/Q2_correlation_%s_%gx%g_minQ2=%g.png
'
%
(
k
,
p
,
method
,
k
,
p
,
minq2
)))
#function to construct Bjorken-x correlation plots
def
Xcorrelation
(
minq2
,
method
):
#minq2 can be 1,10,100, or 1000; method can be 'E','DA', or 'JB'
Xvalues_Y
=
method_Xvalues_dict
[
'
{}
'
.
format
(
method
)]
#x values of the given method, that are mapped onto the y axis
X_List_T
=
Xvalues_T
[
'
{}
'
.
format
(
minq2
)]
#Truth x values for given minq2, mapped along x axis
X_List_Y
=
Xvalues_Y
[
'
{}
'
.
format
(
minq2
)]
#method (E/DA/JB) x values for given minq2, mapped along y axis
T_len
=
ak
.
count
(
X_List_T
,
axis
=
0
)
#total number of events in Truth
Y_len
=
ak
.
count
(
X_List_Y
,
axis
=
0
)
#total number of events in method
if
T_len
>
Y_len
:
#if total number of events for Truth is greater
Y_boolean
=
ak
.
count
(
X_List_Y
,
axis
=-
1
)
>=
1
#boolean to filter ak.Arrays wrt single events in method
X_List_T_F
=
X_List_T
[
Y_boolean
]
#filtered Truth x values
X_List_Y_F
=
X_List_Y
[
Y_boolean
]
#filtered method x values
else
:
#if total number of events for method is greater
T_boolean
=
ak
.
count
(
X_List_T
,
axis
=-
1
)
>=
1
#boolean to filter ak.Arrays wrt single events in Truth
X_List_T_F
=
X_List_T
[
T_boolean
]
#filtered Truth x values
X_List_Y_F
=
X_List_Y
[
T_boolean
]
#filtered method x values
T_Xs
=
np
.
array
(
ak
.
flatten
(
X_List_T_F
))
#Truth Bjorken-x values, mapped along x axis
Y_Xs
=
np
.
array
(
ak
.
flatten
(
X_List_Y_F
))
#method Bjorken-x values, mapped along y axis
T_x_bool
=
T_Xs
>=
minq2
/
(
4
*
k
*
p
)
#boolean to filter x values that satisfy bjorken-x equation for minq2, ebeam and pbeam
T_Xs
=
T_Xs
[
T_x_bool
]
Y_Xs
=
Y_Xs
[
T_x_bool
]
#2-dimensional histogram, h
h
,
xedges
,
yedges
=
np
.
histogram2d
(
x
=
T_Xs
,
y
=
Y_Xs
,
bins
=
[
x_bins
,
x_bins
])
#normalization of h:
col_sum
=
ak
.
sum
(
h
,
axis
=-
1
)
#number of events in each (verticle) column
norm_h
=
[]
#norm_h is the normalized matrix
norm_h_text
=
[]
#display labels matrix
for
i
in
range
(
len
(
col_sum
)):
if
col_sum
[
i
]
!=
0
:
norm_c
=
h
[
i
]
/
col_sum
[
i
]
#normalized column = column values divide by sum of the column
else
:
norm_c
=
h
[
i
]
norm_h
.
append
(
norm_c
)
norm_c_text
=
[
'
%.2f
'
%
elem
for
elem
in
norm_c
]
#display value to 2 dp
norm_h_text
.
append
(
norm_c_text
)
fig
=
plt
.
figure
()
mplhep
.
hist2dplot
(
H
=
norm_h
,
norm
=
mpl
.
colors
.
LogNorm
(),
labels
=
norm_h_text
,
xbins
=
x_bins
,
ybins
=
x_bins
,
cmax
=
1
,
cmin
=
1e-5
)
plt
.
yscale
(
'
log
'
)
plt
.
xscale
(
'
log
'
)
fig
.
set_figwidth
(
11
)
fig
.
set_figheight
(
11
)
plt
.
xlabel
(
'
x Truth
'
)
plt
.
ylabel
(
'
$x$ {}
'
.
format
(
method_dict
[
'
{}
'
.
format
(
method
)]))
plt
.
title
(
'
{} $x$ correlation {}x{} $minQ^2=${}$GeV^2$
'
.
format
(
method_dict
[
'
{}
'
.
format
(
method
)],
k
,
p
,
minq2
))
plt
.
show
()
plt
.
savefig
(
os
.
path
.
join
(
args
.
outdir
,
'
%gon%g/x_correlation_%s_%gx%g_minQ2=%g.png
'
%
(
k
,
p
,
method
,
k
,
p
,
minq2
)))
keys
=
ur
.
concatenate
(
rec_file
+
'
:events/
'
+
'
InclusiveKinematicsTruth
'
)
minq2_1_T
=
[
keys
[
'
InclusiveKinematicsTruth.Q2
'
],
keys
[
'
InclusiveKinematicsTruth.x
'
]]
keys
=
ur
.
concatenate
(
rec_file
+
'
:events/
'
+
'
InclusiveKinematicsElectron
'
)
minq2_1_E
=
[
keys
[
'
InclusiveKinematicsElectron.Q2
'
],
keys
[
'
InclusiveKinematicsElectron.x
'
]]
keys
=
ur
.
concatenate
(
rec_file
+
'
:events/
'
+
'
InclusiveKinematicsDA
'
)
minq2_1_DA
=
[
keys
[
'
InclusiveKinematicsDA.Q2
'
],
keys
[
'
InclusiveKinematicsDA.x
'
]]
keys
=
ur
.
concatenate
(
rec_file
+
'
:events/
'
+
'
InclusiveKinematicsJB
'
)
minq2_1_JB
=
[
keys
[
'
InclusiveKinematicsJB.Q2
'
],
keys
[
'
InclusiveKinematicsJB.x
'
]]
Q2values_T
=
{
'
1
'
:
minq2_1_T
[
0
]}
Q2values_E
=
{
'
1
'
:
minq2_1_E
[
0
]}
Q2values_DA
=
{
'
1
'
:
minq2_1_DA
[
0
]}
Q2values_JB
=
{
'
1
'
:
minq2_1_JB
[
0
]}
Xvalues_T
=
{
'
1
'
:
minq2_1_T
[
1
]}
Xvalues_E
=
{
'
1
'
:
minq2_1_E
[
1
]}
Xvalues_DA
=
{
'
1
'
:
minq2_1_DA
[
1
]}
Xvalues_JB
=
{
'
1
'
:
minq2_1_JB
[
1
]}
method_dict
=
{
'
e
'
:
'
Electron
'
,
'
DA
'
:
'
Double-Angle
'
,
'
JB
'
:
'
Jacquet-Blondel
'
}
method_Q2values_dict
=
{
'
e
'
:
Q2values_E
,
'
DA
'
:
Q2values_DA
,
'
JB
'
:
Q2values_JB
}
method_Xvalues_dict
=
{
'
e
'
:
Xvalues_E
,
'
DA
'
:
Xvalues_DA
,
'
JB
'
:
Xvalues_JB
}
Q2correlation
(
minq2
,
'
e
'
)
Xcorrelation
(
minq2
,
'
e
'
)
Q2correlation
(
minq2
,
'
DA
'
)
Xcorrelation
(
minq2
,
'
DA
'
)
Q2correlation
(
minq2
,
'
JB
'
)
Xcorrelation
(
minq2
,
'
JB
'
)
Loading