From 589cc961023039b76250067ef06f314caf1e9d8b Mon Sep 17 00:00:00 2001 From: Tamas Gal <himself@tamasgal.com> Date: Wed, 9 Feb 2022 18:19:16 +0100 Subject: [PATCH] Update docs on online stuff --- examples/plot_online_example.py | 36 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/examples/plot_online_example.py b/examples/plot_online_example.py index 72a38dd..9b664f0 100644 --- a/examples/plot_online_example.py +++ b/examples/plot_online_example.py @@ -40,29 +40,35 @@ print(f.events[0].snapshot_hits.tot) # Reading SummarySlices # --------------------- # The following example shows how to access summary slices, in particular the DOM -# IDs of the slice with the index 0: +# IDs of the slice with the index 0. +# The current implementation of the summaryslice I/O uses a chunked reading for +# better performance, which means that when you iterate through the `.slices`, +# you'll get chunks of summaryslices in each iteration instead of a single one. +# +# In the example below, we simulate a single iteration by using the `break` +# keyword and then use the data which has been "pulled out" of the ROOT file. -dom_ids = f.summaryslices.slices[0].dom_id -print(dom_ids) +for chunk in f.summaryslices.slices: + break ##################################################### -# The .dtype attribute (or in general, <TAB> completion) is useful to find out -# more about the field structure: +# `chunk` now contains the first set of summaryslices so `chunk.slice[0]` refers +# to the first summaryslice in the ROOT file. To access e.g. the DOM IDs, use +# the `.dom_id` attribute + +dom_ids = chunk.slices[0].dom_id -print(f.summaryslices.headers.dtype) +print(dom_ids) ##################################################### -# To read the frame index: +# The .type attribute (or in general, <TAB> completion) is useful to find out +# more about the field structure: -print(f.summaryslices.headers.frame_index) +print(chunks.slices.type) ##################################################### -# The resulting array is a ChunkedArray which is an extended version of a -# numpy array and behaves like one. +# Similar to the summaryslice data, the headers can be accessed the same way +# To read the frame index of all summaryslices in the obtained chunk: -##################################################### -# Reading TimeSlices -# ------------------ -# To be continued. -# +print(chunk.headers.frame_index) -- GitLab