Skip to content
Snippets Groups Projects
Commit de3db9e1 authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Massive readout performance upgrade of jpp timeslies

parent ab0c357c
No related branches found
No related tags found
No related merge requests found
Pipeline #6969 passed with warnings
......@@ -66,12 +66,23 @@ class JppTimeslices:
stream][b'KM3NETDAQ::JDAQTimeslice']
headers = tree[b'KM3NETDAQ::JDAQTimesliceHeader'][
b'KM3NETDAQ::JDAQHeader'][b'KM3NETDAQ::JDAQChronometer']
if len(headers) == 0:
continue
superframes = tree[b'vector<KM3NETDAQ::JDAQSuperFrame>']
self._timeslices[stream.decode("ascii")] = (headers, superframes)
hits_buffer = superframes[
b'vector<KM3NETDAQ::JDAQSuperFrame>.buffer'].lazyarray(
uproot.asjagged(uproot.astable(
uproot.asdtype([("pmt", "u1"), ("tdc", "u4"),
("tot", "u1")])),
skipbytes=6),
basketcache=uproot.cache.ThreadSafeArrayCache(
TIMESLICE_FRAME_BASKET_CACHE_SIZE))
self._timeslices[stream.decode("ascii")] = (headers, superframes,
hits_buffer)
def stream(self, stream, idx):
ts = self._timeslices[stream]
return JppTimeslice(ts[0], ts[1], idx)
return JppTimeslice(*ts, idx)
def __str__(self):
return "Available timeslice streams: {}".format(', '.join(
......@@ -83,10 +94,11 @@ class JppTimeslices:
class JppTimeslice:
"""A wrapper for a Jpp timeslice"""
def __init__(self, header, superframe, idx):
def __init__(self, header, superframe, hits_buffer, idx):
self.header = header
self._frames = {}
self._superframe = superframe
self._hits_buffer = hits_buffer
self._idx = idx
@property
......@@ -97,14 +109,7 @@ class JppTimeslice:
def _read_frames(self):
"""Populate a dictionary of frames with the module ID as key"""
hits_buffer = self._superframe[
b'vector<KM3NETDAQ::JDAQSuperFrame>.buffer'].lazyarray(
uproot.asjagged(uproot.astable(
uproot.asdtype([("pmt", "u1"), ("tdc", "u4"),
("tot", "u1")])),
skipbytes=6),
basketcache=uproot.cache.ThreadSafeArrayCache(
TIMESLICE_FRAME_BASKET_CACHE_SIZE))[self._idx]
hits_buffer = self._hits_buffer[self._idx]
n_hits = self._superframe[
b'vector<KM3NETDAQ::JDAQSuperFrame>.numberOfHits'].lazyarray()[
self._idx]
......
......@@ -123,10 +123,12 @@ class TestTimeslices(unittest.TestCase):
def test_data_lengths(self):
assert 3 == len(self.ts._timeslices["default"][0])
assert 0 == len(self.ts._timeslices["L0"][0])
assert 3 == len(self.ts._timeslices["L1"][0])
assert 0 == len(self.ts._timeslices["L2"][0])
assert 3 == len(self.ts._timeslices["SN"][0])
with self.assertRaises(KeyError):
assert 0 == len(self.ts._timeslices["L2"][0])
with self.assertRaises(KeyError):
assert 0 == len(self.ts._timeslices["L0"][0])
def test_reading_frames(self):
assert 8 == len(self.ts.stream("SN", 1).frames[808447186])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment