.. 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_offline_analysis_plot_evt_readout.py: ============================= Reading and Parsing EVT files ============================= This example shows how to read and parse EVT files, which are used in our Monte Carlo productions. .. image:: /auto_examples/offline_analysis/images/sphx_glr_plot_evt_readout_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Loading style definitions from '/home/docs/checkouts/readthedocs.org/user_builds/km3pipe/conda/stable/lib/python3.5/site-packages/km3pipe/kp-data/stylelib/km3pipe.mplstyle' km3pipe.io.evt.EvtPump.EvtPump: Opening ../data/numu_cc.evt Detector: Parsing the DETX header Detector: Reading PMT information... Detector: Done. Pipeline and module initialisation took 14.153s (CPU 9.082s). ================================[ . ]================================ ============================================================ 5 cycles drained in 16.588095s (CPU 10.499719s). Memory peak: 504.93 MB wall mean: 0.319837s medi: 0.317185s min: 0.255827s max: 0.359272s std: 0.038155s CPU mean: 0.198055s medi: 0.194548s min: 0.189173s max: 0.214967s std: 0.008855s | .. code-block:: python from __future__ import absolute_import, print_function, division # Author: Tamas Gal , Moritz Lotze >mlotze@km3net.de> # License: BSD-3 import matplotlib.pyplot as plt import numpy as np from km3modules.common import StatusBar from km3pipe import Module, Pipeline from km3pipe.dataclasses import Table from km3pipe.calib import Calibration from km3pipe.io import EvtPump from km3pipe.math import pld3 import km3pipe.style km3pipe.style.use("km3pipe") filename = "../data/numu_cc.evt" detx = "../data/km3net_jul13_90m_r1494_corrected.detx" class VertexHitDistanceCalculator(Module): """Calculate vertex-hit-distances""" def configure(self): self.distances = [] def process(self, blob): tracks = blob['TrackIns'] muons = tracks[tracks.type == 5] muon = Table(muons[np.argmax(muons.energy)]) hits = blob['CalibHits'] dist = pld3(hits.pos, muon.pos, muon.dir) self.distances.append(dist) return blob def finish(self): dist_flat = np.concatenate(self.distances) plt.hist(dist_flat) plt.savefig('dists.pdf') pipe = Pipeline() pipe.attach(EvtPump, filename=filename, parsers=['km3']) pipe.attach(StatusBar, every=100) pipe.attach(Calibration, filename=detx) pipe.attach(VertexHitDistanceCalculator) pipe.drain(5) **Total running time of the script:** ( 0 minutes 16.607 seconds) .. _sphx_glr_download_auto_examples_offline_analysis_plot_evt_readout.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_evt_readout.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_evt_readout.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_