Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pftruth-standalone
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
Alessandro Brusamolino
pftruth-standalone
Commits
2e157987
Commit
2e157987
authored
10 months ago
by
brusale
Browse files
Options
Downloads
Patches
Plain Diff
make plots for truth information
parent
9ff39012
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
data/clusters.py
+77
-2
77 additions, 2 deletions
data/clusters.py
data/config.yml
+2
-2
2 additions, 2 deletions
data/config.yml
data/makeSamples.py
+6
-1
6 additions, 1 deletion
data/makeSamples.py
run-workflow.sh
+1
-1
1 addition, 1 deletion
run-workflow.sh
with
88 additions
and
7 deletions
.gitignore
+
2
−
1
View file @
2e157987
AutoDict*
*.csv
*.png
.vscode/*
*.root
*.a
*.o
.venv/*
*/__pycache__/*
\ No newline at end of file
*/__pycache__/*
This diff is collapsed.
Click to expand it.
data/clusters.py
+
77
−
2
View file @
2e157987
import
numpy
as
np
import
matplotlib.colors
as
colors
import
matplotlib.pyplot
as
plt
from
sklearn.datasets
import
make_blobs
from
tools
import
makeCSVFile
class
clusters
:
def
__init__
(
self
,
centers
,
std
,
n_samples
,
csv_path
):
def
__init__
(
self
,
centers
,
std
,
n_samples
,
bins
,
csv_path
):
self
.
centers
=
centers
self
.
std
=
std
self
.
n_samples
=
n_samples
self
.
x
,
self
.
y
,
self
.
clusters
=
self
.
makeClusters
()
self
.
bins
=
bins
self
.
csv_path
=
csv_path
self
.
dictionary
()
self
.
makePixelTruthPlot
()
self
.
makeDetectorView
()
def
makeClusters
(
self
):
nClusters
=
len
(
self
.
centers
)
...
...
@@ -56,3 +62,72 @@ class clusters:
'
simCluster_layer
'
:
[
0
for
_
in
range
(
len
(
self
.
centers
))]
}
makeCSVFile
(
dictionary
,
self
.
csv_path
)
def
binnedClusters
(
self
):
nclusters
=
len
(
self
.
clusters
)
bins
=
self
.
bins
binned_clusters_content
,
binned_clusters_x
,
binned_clusters_y
,
binned_clusters_fraction
=
[],
[],
[],
[]
for
clusters
in
range
(
0
,
nclusters
):
content
,
xedges
,
yedges
=
np
.
histogram2d
(
self
.
clusters
[
clusters
][
0
],
self
.
clusters
[
clusters
][
1
],
bins
=
bins
)
binned_clusters_content
.
append
(
content
)
binned_clusters_x
.
append
([
0.5
*
(
xedges
[
i
]
+
xedges
[
i
-
1
])
for
i
in
range
(
1
,
len
(
xedges
))])
binned_clusters_y
.
append
([
0.5
*
(
yedges
[
i
]
+
yedges
[
i
-
1
])
for
i
in
range
(
1
,
len
(
yedges
))])
total_content
,
max_contribution
=
[],
[]
for
x_bin
in
range
(
0
,
len
(
bins
)
-
1
):
total_content_x
=
[]
for
y_bin
in
range
(
0
,
len
(
bins
)
-
1
):
max_fraction
=
0
max_fraction_cl
=
-
1
total_bin_content
=
0
for
cluster
in
range
(
0
,
nclusters
):
total_bin_content
+=
binned_clusters_content
[
cluster
][
x_bin
][
y_bin
]
if
binned_clusters_content
[
cluster
][
x_bin
][
y_bin
]
>
max_fraction
:
max_fraction
=
binned_clusters_content
[
cluster
][
x_bin
][
y_bin
]
max_fraction_cl
=
cluster
if
total_bin_content
==
0
:
denominator
=
float
(
"
inf
"
)
else
:
denominator
=
total_bin_content
max_contribution
.
append
([
max_fraction_cl
,
max_fraction
/
denominator
,
total_bin_content
])
total_content_x
.
append
(
denominator
)
total_content
.
append
(
total_content_x
)
for
cluster
in
range
(
0
,
nclusters
):
fractions
=
[]
for
x_bin
in
range
(
0
,
len
(
bins
)
-
1
):
x_fraction
=
[]
for
y_bin
in
range
(
0
,
len
(
bins
)
-
1
):
fraction
=
binned_clusters_content
[
cluster
][
x_bin
][
y_bin
]
/
total_content
[
x_bin
][
y_bin
]
x_fraction
.
append
(
fraction
)
fractions
.
append
(
x_fraction
)
binned_clusters_fraction
.
append
(
fractions
)
return
binned_clusters_content
,
binned_clusters_x
,
binned_clusters_y
,
max_contribution
,
binned_clusters_fraction
def
makePixelTruthPlot
(
self
):
color
=
[
'
white
'
,
'
blue
'
,
'
green
'
,
'
red
'
]
_
,
_
,
_
,
max_contribution
,
_
=
self
.
binnedClusters
()
size
=
len
(
self
.
bins
)
-
1
min_x
=
self
.
bins
[
0
]
max_x
=
self
.
bins
[
-
1
]
min_y
=
min_x
max_y
=
max_x
cmap
=
colors
.
LinearSegmentedColormap
.
from_list
(
""
,
color
)
board
=
np
.
zeros
((
size
,
size
))
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
for
i
in
range
(
size
):
for
j
in
range
(
size
):
board
[
i
][
j
]
=
max_contribution
[
i
+
j
*
size
][
0
]
ax
.
imshow
(
board
,
cmap
=
cmap
,
interpolation
=
'
nearest
'
,
extent
=
[
min_x
,
max_x
,
min_y
,
max_y
])
ax
.
invert_yaxis
()
fig
.
savefig
(
'
pixelTruthPlot.png
'
)
fig
.
clf
()
def
makeDetectorView
(
self
):
plt
.
hist2d
(
self
.
x
,
self
.
y
,
bins
=
self
.
bins
,
norm
=
colors
.
LogNorm
(),
cmap
=
'
inferno
'
)
plt
.
colorbar
()
plt
.
xlim
(
self
.
bins
[
0
],
self
.
bins
[
-
1
])
plt
.
ylim
(
self
.
bins
[
0
],
self
.
bins
[
-
1
])
plt
.
savefig
(
'
detectorView.png
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
data/config.yml
+
2
−
2
View file @
2e157987
...
...
@@ -8,8 +8,8 @@ clusters:
hits
:
bins
:
start
:
-0.
0
3
end
:
0.
0
3
start
:
-0.3
end
:
0.3
n_bins
:
50
csv_file
:
"
csv/hits.csv"
...
...
This diff is collapsed.
Click to expand it.
data/makeSamples.py
+
6
−
1
View file @
2e157987
...
...
@@ -16,9 +16,14 @@ if __name__ == '__main__':
nSamples
=
config
[
'
clusters
'
][
'
n_samples
'
]
centers
=
config
[
'
clusters
'
][
'
centers
'
]
bins
=
np
.
linspace
(
config
[
'
hits
'
][
'
bins
'
][
'
start
'
],
config
[
'
hits
'
][
'
bins
'
][
'
end
'
],
config
[
'
hits
'
][
'
bins
'
][
'
n_bins
'
])
x
,
y
,
clusters
=
clusters
(
config
[
'
clusters
'
][
'
centers
'
],
config
[
'
clusters
'
][
'
std
'
],
config
[
'
clusters
'
][
'
n_samples
'
],
config
[
'
clusters
'
][
'
n_samples
'
],
bins
,
config
[
'
clusters
'
][
'
csv_file
'
]).
getHitsAndClusters
()
bins
=
np
.
linspace
(
config
[
'
hits
'
][
'
bins
'
][
'
start
'
],
...
...
This diff is collapsed.
Click to expand it.
run-workflow.sh
+
1
−
1
View file @
2e157987
...
...
@@ -32,7 +32,7 @@ parse_yml() {
}
print_step
"Sourcing the LCG environment"
source
/cvmfs/sft.cern.ch/lcg/views/LCG_10
2
/x86_64-
centos8
-gcc11-opt/setup.sh
source
/cvmfs/sft.cern.ch/lcg/views/LCG_10
5
/x86_64-
el9
-gcc11-opt/setup.sh
CURRENT_DIR
=
$(
pwd
)
CSV_PATH
=
$(
parse_yml
[
'csv_path'
]
|
tr
-d
\'
, |
awk
'{print $2}'
)
...
...
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