diff --git a/examples/plot_online_example.py b/examples/plot_online_example.py index 72a38ddfc9ccfefbe091d5a9632effa966c5c493..9b664f0175c85894fe6967fea3851cf8fdbeaf75 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)