Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cmsgemonline
gem-daq
cmsgemos-analysis
Commits
e13c6386
Commit
e13c6386
authored
Oct 04, 2021
by
Yechan Kang
Browse files
Add script for sbit mapping test
parent
bcd18305
Pipeline
#3086351
passed with stages
in 4 minutes and 9 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
gemos/analysis/ana_cluster.py
0 → 100644
View file @
e13c6386
"""S-Bit cluster mapping analysis"""
import
argparse
import
pandas
as
pd
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
mplhep
as
hep
def
most_frequent
(
hits
):
counter
=
0
num
=
hits
[
0
]
for
i
in
hits
:
curr_frequency
=
hits
.
count
(
i
)
if
curr_frequency
>
counter
:
counter
=
curr_frequency
num
=
i
return
num
def
filter_and_plot
(
filename
,
ieta
,
plot_dir
,
use_size
):
tag
=
filename
.
split
(
"/"
)[
-
1
].
split
(
".txt"
)[
0
]
df
=
pd
.
read_csv
(
filename
,
sep
=
"
\t
"
)
df
=
df
.
drop
([
"index"
],
axis
=
1
)
df
=
df
.
values
.
flatten
()
df
=
pd
.
DataFrame
(
data
=
df
,
columns
=
[
"CL"
])
df
[
"CL_address"
]
=
df
.
CL
&
0b111111111
df
[
"CL_partition"
]
=
(
df
.
CL
//
2
**
9
)
&
0b111
df
[
"CL_size"
]
=
(
df
.
CL
//
2
**
12
)
&
0b111
df
=
df
.
drop
([
"CL"
],
axis
=
1
)
valid
=
df
[
"CL_address"
]
!=
511
plt
.
style
.
use
(
hep
.
style
.
CMS
)
validDf
=
df
[
valid
]
etaDf
=
validDf
[
validDf
[
"CL_partition"
]
==
ieta
]
hit
=
[]
for
address
,
part
,
size
in
etaDf
.
values
.
tolist
():
if
use_size
:
for
i
in
range
(
size
+
1
):
hit
.
append
(
address
+
i
)
else
:
hit
.
append
(
address
)
plt
.
xlabel
(
"sbit address"
)
plt
.
ylabel
(
"entries"
)
histlabel
=
"Eta Partition %d :: Entries:%d :: Max in %d"
%
(
ieta
,
len
(
hit
),
most_frequent
(
hit
),
)
hist
=
plt
.
hist
(
hit
,
bins
=
192
,
range
=
[
0
,
192
],
label
=
histlabel
)
plt
.
ylim
([
0
,
max
(
hist
[
0
])
*
1.5
])
plt
.
legend
(
fontsize
=
20
,
loc
=
"upper left"
)
plt
.
savefig
(
"%s/%s_test_plot_%d.png"
%
(
plot_dir
,
tag
,
ieta
))
plt
.
clf
()
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
"sbit cluster plotter with pandas"
)
parser
.
add_argument
(
"--fileName"
,
"-filename"
,
required
=
True
,
help
=
"data file name"
)
parser
.
add_argument
(
"--ieta"
,
"-eta"
,
type
=
int
,
default
=
0
,
help
=
"eta partition to draw"
)
parser
.
add_argument
(
"--plot_dir"
,
"-plot_dir"
,
required
=
True
,
help
=
"directory name to save plot"
)
parser
.
add_argemuet
(
"--use_size"
,
"-use_size"
,
type
=
bool
,
default
=
False
,
action
=
"store_true"
)
args
=
parser
.
parse_args
()
filter_and_plot
(
args
.
fileName
,
args
.
ieta
,
args
.
plot_dir
,
args
.
use_size
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment