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
9effd675
Commit
9effd675
authored
5 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Preliminary reading of timeslice frames
parent
e517cf77
No related branches found
Branches containing commit
Tags
v0.5.0
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
km3io/jpp.py
+40
-7
40 additions, 7 deletions
km3io/jpp.py
tests/test_jpp.py
+9
-5
9 additions, 5 deletions
tests/test_jpp.py
with
49 additions
and
12 deletions
km3io/jpp.py
+
40
−
7
View file @
9effd675
...
@@ -49,8 +49,9 @@ class JppTimeslices:
...
@@ -49,8 +49,9 @@ class JppTimeslices:
def
_read_default_stream
(
self
):
def
_read_default_stream
(
self
):
"""
Read the default KM3NET_TIMESLICE stream
"""
"""
Read the default KM3NET_TIMESLICE stream
"""
tree
=
self
.
fobj
[
b
'
KM3NET_TIMESLICE
'
][
b
'
KM3NET_TIMESLICE
'
]
tree
=
self
.
fobj
[
b
'
KM3NET_TIMESLICE
'
][
b
'
KM3NET_TIMESLICE
'
]
header
=
tree
[
b
'
KM3NETDAQ::JDAQTimesliceHeader
'
]
headers
=
tree
[
b
'
KM3NETDAQ::JDAQTimesliceHeader
'
]
self
.
_timeslices
[
'
default
'
]
=
JppTimeslice
(
header
)
superframes
=
tree
[
b
'
vector<KM3NETDAQ::JDAQSuperFrame>
'
]
self
.
_timeslices
[
'
default
'
]
=
(
headers
,
superframes
)
def
_read_streams
(
self
):
def
_read_streams
(
self
):
"""
Read the L0, L1, L2 and SN streams if available
"""
"""
Read the L0, L1, L2 and SN streams if available
"""
...
@@ -61,13 +62,18 @@ class JppTimeslices:
...
@@ -61,13 +62,18 @@ class JppTimeslices:
for
stream
in
streams
:
for
stream
in
streams
:
tree
=
self
.
fobj
[
b
'
KM3NET_TIMESLICE_
'
+
tree
=
self
.
fobj
[
b
'
KM3NET_TIMESLICE_
'
+
stream
][
b
'
KM3NETDAQ::JDAQTimeslice
'
]
stream
][
b
'
KM3NETDAQ::JDAQTimeslice
'
]
header
=
tree
[
b
'
KM3NETDAQ::JDAQTimesliceHeader
'
][
header
s
=
tree
[
b
'
KM3NETDAQ::JDAQTimesliceHeader
'
][
b
'
KM3NETDAQ::JDAQHeader
'
][
b
'
KM3NETDAQ::JDAQChronometer
'
]
b
'
KM3NETDAQ::JDAQHeader
'
][
b
'
KM3NETDAQ::JDAQChronometer
'
]
self
.
_timeslices
[
stream
.
decode
(
"
ascii
"
)]
=
JppTimeslice
(
header
)
superframes
=
tree
[
b
'
vector<KM3NETDAQ::JDAQSuperFrame>
'
]
self
.
_timeslices
[
stream
.
decode
(
"
ascii
"
)]
=
(
headers
,
superframes
)
def
stream
(
self
,
stream
,
idx
):
ts
=
self
.
_timeslices
[
stream
]
return
JppTimeslice
(
ts
[
0
],
ts
[
1
],
idx
)
def
__str__
(
self
):
def
__str__
(
self
):
return
"
Available timeslice streams: {}
"
.
format
(
'
,
'
.
join
(
return
"
Available timeslice streams: {}
"
.
format
(
'
,
'
.
join
(
s
.
decode
(
"
ascii
"
)
for
s
in
self
.
_timeslices
.
keys
()))
s
for
s
in
self
.
_timeslices
.
keys
()))
def
__repr__
(
self
):
def
__repr__
(
self
):
return
str
(
self
)
return
str
(
self
)
...
@@ -75,8 +81,35 @@ class JppTimeslices:
...
@@ -75,8 +81,35 @@ class JppTimeslices:
class
JppTimeslice
:
class
JppTimeslice
:
"""
A wrapper for a Jpp timeslice
"""
"""
A wrapper for a Jpp timeslice
"""
def
__init__
(
self
,
header
):
def
__init__
(
self
,
header
,
superframe
,
idx
):
self
.
header
=
header
self
.
header
=
header
self
.
_frames
=
{}
self
.
_superframe
=
superframe
self
.
_idx
=
idx
@property
def
frames
(
self
):
if
not
self
.
_frames
:
self
.
_read_frames
()
return
self
.
_frames
def
_read_frames
(
self
):
"""
Populate a dictionary of frames with the module ID as key
"""
hits_buffer
=
self
.
_superframe
[
b
'
vector<KM3NETDAQ::JDAQSuperFrame>.buffer
'
].
array
(
uproot
.
asjagged
(
uproot
.
astable
(
uproot
.
asdtype
([(
"
pmt
"
,
"
u1
"
),
(
"
tdc
"
,
"
u4
"
),
(
"
tot
"
,
"
u1
"
)])),
skipbytes
=
6
))[
self
.
_idx
]
n_hits
=
self
.
_superframe
[
b
'
vector<KM3NETDAQ::JDAQSuperFrame>.numberOfHits
'
].
array
()[
self
.
_idx
]
module_ids
=
self
.
_superframe
[
b
'
vector<KM3NETDAQ::JDAQSuperFrame>.id
'
].
array
()[
self
.
_idx
]
idx
=
0
for
module_id
,
n_hits
in
zip
(
module_ids
,
n_hits
):
self
.
_frames
[
module_id
]
=
hits_buffer
[
idx
:
idx
+
n_hits
]
idx
+=
n_hits
def
__str__
(
self
):
def
__str__
(
self
):
return
"
Jpp timeslice
"
return
"
Jpp timeslice
"
...
...
This diff is collapsed.
Click to expand it.
tests/test_jpp.py
+
9
−
5
View file @
9effd675
...
@@ -120,9 +120,13 @@ class TestTimeslices(unittest.TestCase):
...
@@ -120,9 +120,13 @@ class TestTimeslices(unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
ts
=
JppReader
(
os
.
path
.
join
(
SAMPLES_DIR
,
self
.
ts
=
JppReader
(
os
.
path
.
join
(
SAMPLES_DIR
,
"
jpp_v12.0.0.root
"
)).
timeslices
"
jpp_v12.0.0.root
"
)).
timeslices
def
test_data_lengths
(
self
):
def
test_data_lengths
(
self
):
assert
3
==
len
(
self
.
ts
.
_timeslices
[
"
default
"
].
header
)
assert
3
==
len
(
self
.
ts
.
_timeslices
[
"
default
"
][
0
])
assert
0
==
len
(
self
.
ts
.
_timeslices
[
"
L0
"
].
header
)
assert
0
==
len
(
self
.
ts
.
_timeslices
[
"
L0
"
][
0
])
assert
3
==
len
(
self
.
ts
.
_timeslices
[
"
L1
"
].
header
)
assert
3
==
len
(
self
.
ts
.
_timeslices
[
"
L1
"
][
0
])
assert
0
==
len
(
self
.
ts
.
_timeslices
[
"
L2
"
].
header
)
assert
0
==
len
(
self
.
ts
.
_timeslices
[
"
L2
"
][
0
])
assert
3
==
len
(
self
.
ts
.
_timeslices
[
"
SN
"
].
header
)
assert
3
==
len
(
self
.
ts
.
_timeslices
[
"
SN
"
][
0
])
def
test_reading_frames
(
self
):
assert
8
==
len
(
self
.
ts
.
stream
(
"
SN
"
,
1
).
frames
[
808447186
])
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