Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
reconstruction_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
reconstruction_benchmarks
Merge requests
!281
Update IMCAL ML benchmarks
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Update IMCAL ML benchmarks
improve_imcal_ml_benchmarks
into
master
Overview
0
Commits
2
Pipelines
0
Changes
3
Merged
Update IMCAL ML benchmarks
Chao Peng
requested to merge
improve_imcal_ml_benchmarks
into
master
Nov 14, 2022
Overview
0
Commits
2
Pipelines
0
Changes
3
add one general plot for epcut scan result
0
0
Merge request reports
Compare
master
version 1
e2a19ffa
Nov 14, 2022
master (base)
and
latest version
latest version
5a3bdc54
2 commits,
Nov 14, 2022
version 1
e2a19ffa
1 commit,
Nov 14, 2022
3 files
+
73
−
18
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
benchmarks/imaging_shower_ML/scripts/epcut_scan.py
+
62
−
17
View file @ 5a3bdc54
Edit in single-file editor
Open in Web IDE
Show full file
@@ -16,6 +16,7 @@ import numpy as np
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
import
matplotlib.backends.backend_pdf
as
mpdf
from
matplotlib.ticker
import
MultipleLocator
from
collections
import
OrderedDict
from
utils
import
flatten_collection
,
imcal_info
@@ -169,22 +170,25 @@ if __name__ == '__main__':
# print(dfr)
# study the epcut performance with binned data
best
=
{
'
layer
'
:
int
(
nlayers
+
1
),
'
ep_cut
'
:
0.
,
'
el_eff
'
:
0.
,
'
pi_rej
'
:
0.
,
}
ep_dict
=
OrderedDict
([
(
'
info
'
,
{
'
nsamples
'
:
int
(
ntotal
),
'
targeted_efficiency
'
:
args
.
eff
,
'
tracking_resolution
'
:
args
.
res
}),
(
'
best
'
,
best
),
])
# prepare output container
best
=
OrderedDict
(
layer
=
int
(
nlayers
+
1
),
ep_cut
=
0.
,
el_eff
=
0.
,
pi_rej
=
0.
,
)
ep_dict
=
OrderedDict
(
info
=
OrderedDict
(
nsamples
=
int
(
ntotal
),
targeted_efficiency
=
args
.
eff
,
tracking_resolution
=
args
.
res
),
best
=
best
,
)
# scan layers
pdf
=
mpdf
.
PdfPages
(
os
.
path
.
join
(
args
.
outdir
,
'
{}_layers.pdf
'
.
format
(
args
.
ntag
)))
box_props
=
dict
(
boxstyle
=
'
round
'
,
facecolor
=
'
white
'
,
alpha
=
0.5
)
for
i
in
np
.
arange
(
nlayers
):
elvals
,
pivals
=
el_hist
[
i
],
pi_hist
[
i
]
# cut position
@@ -214,11 +218,52 @@ if __name__ == '__main__':
ax
.
set_xlabel
(
'
$E/p$
'
,
fontsize
=
20
)
ax
.
set_ylabel
(
'
Counts
'
,
fontsize
=
20
)
ax
.
axvline
(
x
=
ep_cut
,
color
=
'
k
'
,
ls
=
'
--
'
,
lw
=
2
)
props
=
dict
(
boxstyle
=
'
round
'
,
facecolor
=
'
white
'
,
alpha
=
0.5
)
ax
.
text
(
0.5
,
0.97
,
'
Layer $\leq${:d}
\n
$\epsilon_e={:.2f}$%
\n
$R_{{\pi}}={:.2f}$%
'
.
format
(
i
+
1
,
eff
*
100.
,
rej
*
100.
),
transform
=
ax
.
transAxes
,
fontsize
=
20
,
va
=
'
top
'
,
ha
=
'
center
'
,
bbox
=
props
)
transform
=
ax
.
transAxes
,
fontsize
=
20
,
va
=
'
top
'
,
ha
=
'
center
'
,
bbox
=
box_
props
)
pdf
.
savefig
(
fig
)
plt
.
close
(
fig
)
# a plot for the cut scan
cuts
=
[
ep_dict
.
get
(
'
layer_{:d}
'
.
format
(
i
+
1
))
for
i
in
np
.
arange
(
nlayers
)]
cuts_pos
=
np
.
array
([
c
.
get
(
'
ep_cut
'
)
for
c
in
cuts
])
cuts_rej
=
np
.
array
([
c
.
get
(
'
pi_rej
'
)
for
c
in
cuts
])
# estimated uncertainty (binomial)
nerr
=
np
.
sqrt
(
cuts_rej
*
(
1.
-
cuts_rej
)
*
ntotal
)
# npq
# leftover pions
nres
=
ntotal
*
(
1.
-
cuts_rej
)
nres_lo
=
np
.
clip
(
nres
-
nerr
,
1
,
ntotal
)
nres_hi
=
np
.
clip
(
nres
+
nerr
,
1
,
ntotal
)
# rejection power
rej_pow
=
ntotal
/
nres
rej_err
=
(
rej_pow
-
ntotal
/
nres_hi
,
ntotal
/
nres_lo
-
rej_pow
)
fig
,
ax1
=
plt
.
subplots
(
figsize
=
(
8
,
8
))
ax2
=
ax1
.
twinx
()
ax2
.
set_yscale
(
'
log
'
)
ax1
.
plot
(
np
.
arange
(
nlayers
)
+
1
,
cuts_pos
,
ls
=
'
-
'
,
color
=
colors
[
0
])
ax2
.
errorbar
(
np
.
arange
(
nlayers
)
+
1
,
rej_pow
,
yerr
=
rej_err
,
fmt
=
'
o
'
,
capsize
=
3
,
color
=
colors
[
1
])
ax1
.
set_xlabel
(
'
Layer Number
'
,
fontsize
=
20
)
ax1
.
set_ylabel
(
'
Cut Position (E/p)
'
,
color
=
colors
[
0
],
fontsize
=
20
)
ax2
.
grid
(
axis
=
'
both
'
,
which
=
'
both
'
,
ls
=
'
:
'
)
ax2
.
xaxis
.
set_major_locator
(
MultipleLocator
(
5
))
ax2
.
xaxis
.
set_minor_locator
(
MultipleLocator
(
1
))
ax2
.
set_ylabel
(
'
$\pi^-$ Rejection Power
'
,
color
=
colors
[
1
],
fontsize
=
20
)
ax1
.
tick_params
(
labelsize
=
20
)
ax2
.
tick_params
(
labelsize
=
20
)
ax1
.
set_title
(
'
2D Scan of E/p Cut
'
,
fontsize
=
22
)
ax1
.
text
(
0.5
,
0.03
,
'
$\epsilon_e \geq$ {:.2f}%
'
.
format
(
args
.
eff
*
100.
),
transform
=
ax1
.
transAxes
,
fontsize
=
20
,
va
=
'
bottom
'
,
ha
=
'
center
'
,
bbox
=
box_props
)
fig
.
subplots_adjust
(
left
=
0.15
,
right
=
0.85
)
pdf
.
savefig
(
fig
)
plt
.
close
(
fig
)
pdf
.
close
()
# save cut position and performance
Loading