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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EIC
benchmarks
reconstruction_benchmarks
Commits
d111afee
Commit
d111afee
authored
3 years ago
by
Chao Peng
Browse files
Options
Downloads
Patches
Plain Diff
add support for negative ids
parent
26f750fc
No related branches found
No related tags found
1 merge request
!128
add benchmark for pion0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
benchmarks/imaging_ecal/scripts/get_layerids.py
+14
-10
14 additions, 10 deletions
benchmarks/imaging_ecal/scripts/get_layerids.py
with
14 additions
and
10 deletions
benchmarks/imaging_ecal/scripts/get_layerids.py
+
14
−
10
View file @
d111afee
...
...
@@ -21,7 +21,13 @@ class AthenaDecoder:
def
get
(
self
,
idvals
,
field
):
start
,
width
=
self
.
fieldsmap
[
field
]
return
np
.
bitwise_and
(
np
.
right_shift
(
idvals
,
start
),
(
1
<<
width
)
-
1
)
if
width
>=
0
:
return
np
.
bitwise_and
(
np
.
right_shift
(
idvals
,
start
),
(
1
<<
width
)
-
1
)
# first bit is sign bit
else
:
width
=
abs
(
width
)
-
1
vals
=
np
.
bitwise_and
(
np
.
right_shift
(
idvals
,
start
),
(
1
<<
width
)
-
1
)
return
np
.
where
(
np
.
bitwise_and
(
np
.
right_shift
(
idvals
,
start
+
width
),
1
),
vals
-
(
1
<<
width
),
vals
)
@staticmethod
def
getReadouts
(
path
):
...
...
@@ -53,11 +59,11 @@ class AthenaDecoder:
for
field_bits
in
id_str
.
split
(
'
,
'
):
elements
=
field_bits
.
split
(
'
:
'
)
field_name
=
elements
[
0
]
bit_width
=
abs
(
int
(
elements
[
-
1
])
)
bit_width
=
int
(
elements
[
-
1
])
if
len
(
elements
)
==
3
:
curr_bit
=
int
(
elements
[
1
])
res
[
field_name
]
=
(
curr_bit
,
bit_width
)
curr_bit
+=
bit_width
curr_bit
+=
abs
(
bit_width
)
return
res
...
...
@@ -113,17 +119,15 @@ if __name__ == '__main__':
# kernel = DDG4.Kernel()
# description = kernel.detectorDescription()
# kernel.loadGeometry("file:{}".format(args.compact))
# decoder = description.readout(args.readout).idSpec().decoder()
# lindex = decoder.index('layer')
# get_layer_id = np.vectorize(lambda cid: decoder.get(cid, lindex))
# dd4hep_decoder = description.readout(args.readout).idSpec().decoder()
# lindex = dd4hep_decoder.index('x')
# get_layer_id = np.vectorize(lambda cid: dd4hep_decoder.get(cid, lindex))
# df.loc[:, 'layerID'] = get_layer_id(df['cellID'].astype(int).values)
# print(df[['cellID', 'layerID', 'position.x', 'position.y', 'position.z', 'energy']])
# always terminate dd4hep kernel
# kernel.terminate()
# faster way to get layerids
df
.
loc
[:,
'
layerID
'
]
=
decoder
.
get
(
df
[
'
cellID
'
].
values
,
'
layer
'
)
print
(
df
[[
'
cellID
'
,
'
layerID
'
,
'
position.x
'
,
'
position.y
'
,
'
position.z
'
,
'
energy
'
]])
df
.
loc
[:,
'
xID
'
]
=
decoder
.
get
(
df
[
'
cellID
'
].
values
,
'
x
'
)
print
(
df
[[
'
cellID
'
,
'
layerID
'
,
'
xID
'
,
'
position.x
'
,
'
position.y
'
,
'
position.z
'
,
'
energy
'
]])
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