.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_online_example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_online_example.py: Reading Online Data =================== The following example shows how to access hits in a ROOT file which is coming from the detector and written by the `JDataWriter` application. Such a file is usually called "KM3NET_00000001_00000002.root", where the first number is the detector ID and the second the run number. .. GENERATED FROM PYTHON SOURCE LINES 11-14 .. code-block:: default import km3io as ki from km3net_testdata import data_path .. GENERATED FROM PYTHON SOURCE LINES 15-19 Accessing the event tree ------------------------ Just pass a filename to the reader class and get access to the event tree with: .. GENERATED FROM PYTHON SOURCE LINES 19-23 .. code-block:: default f = ki.OnlineReader(data_path("online/km3net_online.root")) .. GENERATED FROM PYTHON SOURCE LINES 24-28 Note that only some meta information is read into memory. Printing it will simply tell you how many events it has found. Again, nothing else is read yet: .. GENERATED FROM PYTHON SOURCE LINES 28-31 .. code-block:: default print(f.events) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Number of events: 3 .. GENERATED FROM PYTHON SOURCE LINES 32-33 Now let's look at the hits data: .. GENERATED FROM PYTHON SOURCE LINES 33-36 .. code-block:: default print(f.events[0].snapshot_hits.tot) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none [26 19 25 22 28 29 24 30 14 26 29 24 24 24 36 25 21 21 28 14 25 30 24 22 16 23 29 29 37 31 26 27 12 25 22 22 22 27 23 13 35 30 23 27 23 29 28 17 23 27 20 24 32 34 36 16 28 76 7 17 28 25 26 28 26 24 27 26 19 28 29 18 23 29 27 22 27 12 9 27 22 24 28 12 20 28 24 25 12 20 23 6 10 29 28 27] .. GENERATED FROM PYTHON SOURCE LINES 37-38 the resulting arrays are numpy arrays. .. GENERATED FROM PYTHON SOURCE LINES 40-44 Reading SummarySlices --------------------- The following example shows how to access summary slices, in particular the DOM IDs of the slice with the index 0: .. GENERATED FROM PYTHON SOURCE LINES 44-49 .. code-block:: default dom_ids = f.summaryslices.slices[0].dom_id print(dom_ids) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none [806451572 806455814 806465101 806483369 806487219 806487226 806487231 808432835 808435278 808447180 808447186 808451904 808451907 808469129 808472260 808472265 808488895 808488990 808489014 808489117 808493910 808946818 808951460 808956908 808959411 808961448 808961480 808961504 808961655 808964815 808964852 808969848 808969857 808972593 808972598 808972698 808974758 808974773 808974811 808974972 808976377 808979567 808979721 808979729 808981510 808981523 808981672 808981812 808981864 808982018 808982041 808982077 808982547 808984711 808996773 808997793 809006037 809007627 809503416 809521500 809524432 809526097 809544058 809544061] .. GENERATED FROM PYTHON SOURCE LINES 50-52 The .dtype attribute (or in general, completion) is useful to find out more about the field structure: .. GENERATED FROM PYTHON SOURCE LINES 52-55 .. code-block:: default print(f.summaryslices.headers.dtype) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none [(' cnt', '` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_online_example.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_