Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
km3io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
km3py
km3io
Commits
2a3c1cdf
Commit
2a3c1cdf
authored
4 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Quick fixes
parent
0362b3e4
No related branches found
Branches containing commit
No related tags found
1 merge request
!39
WIP: Resolve "uproot4 integration"
Pipeline
#16039
failed
4 years ago
Stage: test
Stage: coverage
Stage: doc
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3io/offline.py
+18
-10
18 additions, 10 deletions
km3io/offline.py
tests/test_offline.py
+7
-6
7 additions, 6 deletions
tests/test_offline.py
with
25 additions
and
16 deletions
km3io/offline.py
+
18
−
10
View file @
2a3c1cdf
...
...
@@ -13,22 +13,22 @@ class OfflineReader:
item_name
=
"
OfflineEvent
"
skip_keys
=
[
"
t
"
,
"
AAObject
"
]
aliases
=
{
"
t_s
"
:
"
t.fSec
"
,
"
t_s
ec
"
:
"
t.fSec
"
,
"
t_ns
"
:
"
t.fNanoSec
"
,
"
usr
"
:
"
AAObject/usr
"
,
"
usr_names
"
:
"
AAObject/usr_names
"
,
}
special_branches
=
{
"
hits
"
:
{
"
id
"
:
"
hits.id
"
,
"
channel_id
"
:
"
hits.channel_id
"
,
"
dom_id
"
:
"
hits.dom_id
"
,
"
t
ime
"
:
"
hits.t
"
,
"
t
"
:
"
hits.t
"
,
"
tot
"
:
"
hits.tot
"
,
"
trig
gered
"
:
"
hits.trig
"
,
# non-zero if the hit is a triggered hit
"
trig
"
:
"
hits.trig
"
,
# non-zero if the hit is a triggered hit
},
"
mc_hits
"
:
{
"
id
"
:
"
mc_hits.id
"
,
"
pmt_id
"
:
"
mc_hits.pmt_id
"
,
"
t
ime
"
:
"
mc_hits.t
"
,
# hit time (MC truth)
"
t
"
:
"
mc_hits.t
"
,
# hit time (MC truth)
"
a
"
:
"
mc_hits.a
"
,
# hit amplitude (in p.e.)
"
origin
"
:
"
mc_hits.origin
"
,
# track id of the track that created this hit
"
pure_t
"
:
"
mc_hits.pure_t
"
,
# photon time before pmt simultion
...
...
@@ -92,6 +92,13 @@ class OfflineReader:
self
.
_keys
=
None
self
.
_grouped_counts
=
{}
# TODO: e.g. {"events": [3, 66, 34]}
if
"
E/Evt/AAObject/usr
"
in
self
.
_fobj
:
if
ak
.
count
(
f
[
"
E/Evt/AAObject/usr
"
].
array
())
>
0
:
self
.
aliases
.
update
({
"
usr
"
:
"
AAObject/usr
"
,
"
usr_names
"
:
"
AAObject/usr_names
"
,
})
self
.
_initialise_keys
()
self
.
_event_ctor
=
namedtuple
(
...
...
@@ -184,10 +191,11 @@ class OfflineReader:
group_counts
[
key
]
=
iter
(
self
[
key
])
for
event_set
,
*
special_sets
in
zip
(
events_it
,
*
specials
):
for
_event
,
*
special_items
in
zip
(
event_set
,
*
special_sets
):
data
=
{
**
{
k
:
_event
[
k
]
for
k
in
keys
},
**
{
k
:
i
for
(
k
,
i
)
in
zip
(
special_keys
,
special_items
)},
}
data
=
{}
for
k
in
keys
:
data
[
k
]
=
_event
[
k
]
for
(
k
,
i
)
in
zip
(
special_keys
,
special_items
):
data
[
k
]
=
i
for
tokey
,
fromkey
in
self
.
special_aliases
.
items
():
data
[
tokey
]
=
data
[
fromkey
]
for
key
in
group_counts
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_offline.py
+
7
−
6
View file @
2a3c1cdf
...
...
@@ -160,8 +160,8 @@ class TestOfflineEvents(unittest.TestCase):
self
.
assertListEqual
(
self
.
det_id
,
list
(
self
.
events
.
det_id
))
print
(
self
.
n_hits
)
print
(
self
.
events
.
hits
)
self
.
assertListEqual
(
self
.
n_hits
,
l
en
(
self
.
events
.
hits
))
self
.
assertListEqual
(
self
.
n_tracks
,
l
en
(
self
.
events
.
tracks
))
self
.
assertListEqual
(
self
.
n_hits
,
l
ist
(
self
.
events
.
n_
hits
))
self
.
assertListEqual
(
self
.
n_tracks
,
l
ist
(
self
.
events
.
n_
tracks
))
self
.
assertListEqual
(
self
.
t_sec
,
list
(
self
.
events
.
t_sec
))
self
.
assertListEqual
(
self
.
t_ns
,
list
(
self
.
events
.
t_ns
))
...
...
@@ -296,13 +296,14 @@ class TestOfflineHits(unittest.TestCase):
],
}
def
test_attributes
_available
(
self
):
for
key
in
self
.
hits
.
_keymap
.
keys
()
:
def
test_
fields_work_as_keys_and_
attributes
(
self
):
for
key
in
self
.
hits
.
fields
:
getattr
(
self
.
hits
,
key
)
self
.
hits
[
key
]
def
test_channel_ids
(
self
):
self
.
assertTrue
(
all
(
c
>=
0
for
c
in
self
.
hits
.
channel_id
.
min
(
)))
self
.
assertTrue
(
all
(
c
<
31
for
c
in
self
.
hits
.
channel_id
.
max
(
)))
self
.
assertTrue
(
all
(
c
>=
0
for
c
in
ak
.
min
(
self
.
hits
.
channel_id
,
axis
=
1
)))
self
.
assertTrue
(
all
(
c
<
31
for
c
in
ak
.
max
(
self
.
hits
.
channel_id
,
axis
=
1
)))
def
test_str
(
self
):
assert
str
(
self
.
n_hits
)
in
str
(
self
.
hits
)
...
...
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