

.. _sphx_glr_auto_examples_realtime_analysis_event_dumper.py:


SyntaxError
===========

Example script with invalid Python syntax



.. code-block:: python

    #!/usr/bin/env python
    # coding=utf-8
    # vim: ts=4 sw=4 et
    """
    =================
    Live Event Dumper
    =================

    Recieves triggered events from the detector and dumps them to a file.

    """
    # Author: Tamas Gal <tgal@km3net.de>
    # License: MIT
    """Read & dump events through the CH Pump.
    """
    from km3pipe import Pipeline, Module
    from km3pipe.io.ch import CHPump
    from km3pipe.io.daq import DAQProcessor


    class Dumper(Module):
        def configure(self):
            self.counter = 0

        def process(self, blob):
    	tag = str(blob['CHPrefix'].tag)
    	data = blob['CHData']
    	self.dump(data, tag)
    	print(blob["Hits"])
            return blob

        def dump(self, data, tag):
            with open('{0}-{1:06}.dat'.format(tag, self.counter), 'bw') as f:
                self.counter += 1
                f.write(data)


    pipe = Pipeline()
    pipe.attach(CHPump, host='xxx.xxx.xxx.xxx',
                port=5553,
                tags='IO_EVT',
                timeout=60*60*24,
                max_queue=42)
    pipe.attach(DAQProcessor)
    pipe.attach(Dumper)
    pipe.drain()

**Total running time of the script:** ( 0 minutes  0.000 seconds)



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

     :download:`Download Python source code: event_dumper.py <event_dumper.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: event_dumper.ipynb <event_dumper.ipynb>`

.. rst-class:: sphx-glr-signature

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
