Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hgcal10gLinkReceiver
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
Martina Manoni
Hgcal10gLinkReceiver
Commits
a7227431
Commit
a7227431
authored
5 months ago
by
Martina Manoni
Browse files
Options
Downloads
Patches
Plain Diff
finalising plotting
parent
4b0aed17
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hexplot.py
+12
-5
12 additions, 5 deletions
hexplot.py
plot_energy_diagram.py
+76
-7
76 additions, 7 deletions
plot_energy_diagram.py
with
88 additions
and
12 deletions
hexplot.py
+
12
−
5
View file @
a7227431
...
...
@@ -142,8 +142,8 @@ class DiamondF(Shape):
DiamondF
(
self
.
x
-
x_jump
+
base
,
self
.
y
+
height
,
base
)]
return
set
def
getCoarseDiamonds
(
base
=
1
,
offset_x
=
0
,
offset_y
=
0
):
b
=
base
def
getCoarseDiamonds
(
base
=
1
,
offset_x
=
0
,
offset_y
=
0
,
n
=
1
):
b
=
base
*
n
xj
=
b
/
2
h
=
np
.
sqrt
(
3
)
*
b
/
2
...
...
@@ -152,9 +152,15 @@ def getCoarseDiamonds(base=1, offset_x=0, offset_y=0):
cmap
=
matplotlib
.
cm
.
get_cmap
(
"
Spectral
"
)
diamonds
=
[
Diamond
(
0
,
0
,
b
),
Diamond
(
b
,
0
,
b
),
Diamond
(
xj
,
h
,
b
),
Diamond
(
b
+
xj
,
h
,
b
),
DiamondR
(
2
*
b
,
0
,
b
),
DiamondR
(
2.5
*
b
,
h
,
b
),
DiamondR
(
3
*
b
,
0
,
b
),
DiamondR
(
2.5
*
b
,
-
hr
/
2
,
b
),
DiamondF
(
xj
,
-
h
,
b
),
DiamondF
(
xj
+
b
,
-
h
,
b
),
DiamondF
(
xj
*
2
,
-
h
*
2
,
b
),
DiamondF
(
xj
*
2
+
b
,
-
h
*
2
,
b
)]
if
n
==
1
:
diamonds
=
[
Diamond
(
0
,
0
,
b
),
Diamond
(
b
,
0
,
b
),
Diamond
(
xj
,
h
,
b
),
Diamond
(
b
+
xj
,
h
,
b
),
DiamondR
(
2
*
b
,
0
,
b
),
DiamondR
(
2.5
*
b
,
h
,
b
),
DiamondR
(
3
*
b
,
0
,
b
),
DiamondR
(
2.5
*
b
,
-
hr
/
2
,
b
),
DiamondF
(
xj
,
-
h
,
b
),
DiamondF
(
xj
+
b
,
-
h
,
b
),
DiamondF
(
xj
*
2
,
-
h
*
2
,
b
),
DiamondF
(
xj
*
2
+
b
,
-
h
*
2
,
b
)]
else
:
diamonds
=
[
Diamond
(
0
,
0
,
b
/
2
),
DiamondR
(
b
/
2
,
0
,
b
/
2
),
DiamondF
(
xj
/
2
,
-
h
/
2
,
b
/
2
)]
for
dia
in
diamonds
:
dia
.
x
+=
offset_x
dia
.
y
+=
offset_y
...
...
@@ -211,3 +217,4 @@ def plotOutlines(shapes, fmt="k-", linewidth=1):
xc
=
np
.
concatenate
([
x
,
x
[:
1
]])
yc
=
np
.
concatenate
([
y
,
y
[:
1
]])
plt
.
plot
(
xc
,
yc
,
fmt
,
linewidth
=
linewidth
)
plt
.
savefig
(
"
provaSTC16.png
"
)
This diff is collapsed.
Click to expand it.
plot_energy_diagram.py
+
76
−
7
View file @
a7227431
...
...
@@ -31,7 +31,7 @@ def getMean(file_path, tree_name, leaf_name, BX):
else
:
return
np
.
mean
(
leaf_data
)
def
getMeanLocation
(
file_path
,
tree_name
,
STC_number
,
TCs
,
BX
,
data_type
):
def
getMeanLocation
(
file_path
,
tree_name
,
STC_number
,
TCs
,
BX
,
data_type
,
expected_values
):
# Check if the STC_number is within the valid range
# Open the ROOT file
if
STC_number
>=
6
:
...
...
@@ -45,7 +45,7 @@ def getMeanLocation(file_path, tree_name, STC_number, TCs, BX, data_type):
leaf_data
=
leaf_data
.
flatten
()
unique_values
,
counts
=
np
.
unique
(
leaf_data
,
return_counts
=
True
)
expected_values
=
np
.
array
([
0
,
1
,
2
,
3
])
#
expected_values = np.array([0, 1, 2, 3])
counts_dict
=
dict
.
fromkeys
(
expected_values
,
0
)
counts_dict
.
update
(
dict
(
zip
(
unique_values
,
counts
)))
...
...
@@ -55,7 +55,7 @@ def getMeanLocation(file_path, tree_name, STC_number, TCs, BX, data_type):
# Normalize counts
counts_sum
=
all_counts
.
sum
()
normalized_counts
=
all_counts
/
counts_sum
if
counts_sum
>
0
else
all_counts
# Compute weighted averages using TCs
x
=
sum
([
normalized_counts
[
i
]
*
TCs
[
i
].
getCenter
()[
0
]
for
i
in
range
(
len
(
TCs
))])
y
=
sum
([
normalized_counts
[
i
]
*
TCs
[
i
].
getCenter
()[
1
]
for
i
in
range
(
len
(
TCs
))])
...
...
@@ -81,9 +81,77 @@ def main():
pedastal_BX
=
0
#print("len stcs", len(STCs))
#if data_type== "STC16":
if
data_type
==
"
STC16
"
:
branch_energy
=
[
f
"
energyc_
{
data_type
}
_
{
STC
}
"
for
STC
in
range
(
3
)]
tree_name
=
"
tree
"
all_means
=
[[
getMean
(
file_path
,
tree_name
,
branch_name
,
BX
)
for
branch_name
in
branch_energy
]
for
BX
in
range
(
1
)]
#for now only considering BX=0
#ped_means = np.array([getMean(f, hist_name, pedastal_BX) for hist_name in hist_names])
all_means
=
all_means
#- ped_means #for now we are plotting only the mean energy (no pedestals)
all_means_maxes
=
[
max
(
means
)
for
means
in
all_means
]
nominal_BX
=
np
.
argmax
(
all_means_maxes
)
print
(
f
"
Chosen BX
{
nominal_BX
}
for Relay
{
relayNumber
}
"
)
means
=
all_means
[
nominal_BX
]
print
(
"
means STC16
"
,
means
)
base
=
166.8
/
(
2
*
np
.
sqrt
(
3
))
STCs16
=
hexplot
.
getCoarseDiamonds
(
base
=
base
*
2
,
offset_x
=-
2
*
base
,
n
=
2
)
print
(
"
len STC16
"
,
len
(
STCs16
))
nominal_BX
=
"
0
"
remapping
=
[
0
,
1
,
2
]
assert
len
(
np
.
unique
(
remapping
))
==
3
for
i
,
STC
in
enumerate
(
STCs16
):
STC
.
value
=
means
[
remapping
[
i
]]
STC
.
label
=
f
"
STC
{
remapping
[
i
]
}
"
hexplot
.
plotDiamonds
(
STCs16
)
hexplot
.
plotOutlines
(
STCs16
,
linewidth
=
0.5
)
for
i
,
STC16
in
enumerate
(
STCs16
):
STCs4
=
STC16
.
generateSet
()
STCs4
=
np
.
array
(
STCs4
).
flatten
()
all_TCs
=
[]
for
TCs
in
STCs4
:
TCs
=
TCs
.
generateSet
()
all_TCs
.
extend
(
np
.
array
(
TCs
).
flatten
())
expected_values
=
np
.
array
([
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
])
x
,
y
=
getMeanLocation
(
file_path
,
tree_name
,
i
,
all_TCs
,
nominal_BX
,
data_type
,
expected_values
)
print
(
"
x,y
"
,
x
,
y
)
hexplot
.
plotOutlines
(
all_TCs
,
linewidth
=
2
)
if
i
==
0
:
plt
.
scatter
([
x
],
[
y
],
color
=
"
k
"
,
marker
=
"
x
"
,
label
=
"
Average position of highest energy deposit
"
)
else
:
plt
.
scatter
([
x
],
[
y
],
color
=
"
k
"
,
marker
=
"
x
"
)
for
i
,
TC
in
enumerate
(
all_TCs
):
plt
.
text
(
TC
.
x
,
TC
.
y
,
f
"
TC
{
i
}
"
,
color
=
"
k
"
,
fontsize
=
8
,
horizontalalignment
=
"
left
"
,
verticalalignment
=
"
bottom
"
)
plt
.
ylim
(
top
=
plt
.
ylim
()[
1
]
+
10
)
plt
.
legend
()
for
i
,
STC
in
enumerate
(
STCs16
):
plt
.
text
(
STC
.
getCenter
()[
0
],
STC
.
getCenter
()[
1
],
STC
.
label
,
color
=
"
r
"
,
horizontalalignment
=
"
center
"
,
verticalalignment
=
"
center
"
)
#for TC_set in remapped_TCs:
# for i, TC in enumerate(TC_set):
# plt.text(TC.x, TC.y, f"TC{i}", color="k", fontsize=8, horizontalalignment="left", verticalalignment="bottom")
plt
.
title
(
f
"
Relay
{
relayNumber
}
Run
{
runNumber
}
\n
Chosen BX
{
nominal_BX
}
Econt
{
econtNumber
}
Data type
{
data_type
}
"
)
plt
.
savefig
(
f
"
{
outdir
}
_STC16_dai.png
"
)
plt
.
savefig
(
f
"
{
outdir
}
_STC16_dai.pdf
"
)
if
data_type
==
"
STC4
"
:
# choose between converted/decoded and "raw" values
...
...
@@ -133,7 +201,8 @@ def main():
print
(
"
TC set
"
,
TC_set
)
print
(
file_path
,
tree_name
,
i
,
TC_set
,
nominal_BX
,
data_type
)
x
,
y
=
getMeanLocation
(
file_path
,
tree_name
,
i
,
TC_set
,
nominal_BX
,
data_type
)
expected_values
=
np
.
array
([
0
,
1
,
2
,
3
])
x
,
y
=
getMeanLocation
(
file_path
,
tree_name
,
i
,
TC_set
,
nominal_BX
,
data_type
,
expected_values
)
print
(
"
x,y
"
,
x
,
y
)
if
i
==
0
:
plt
.
scatter
([
x
],
[
y
],
color
=
"
k
"
,
marker
=
"
x
"
,
label
=
"
Average position of highest energy deposit
"
)
...
...
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