#ifndef __JDAQEVENT__ #define __JDAQEVENT__ #include #include #include #include "Jeep/JPrint.hh" #include "JDAQ/JDAQRoot.hh" #include "JDAQ/JDAQPreamble.hh" #include "JDAQ/JDAQEventHeader.hh" #include "JDAQ/JDAQHit.hh" #include "JDAQ/JDAQKeyHit.hh" #include "JDAQ/JDAQTriggeredHit.hh" #include "JIO/JIOLibrary.hh" namespace KM3NETDAQ { namespace { using JIO::JReader; using JIO::JWriter; } typedef JDAQKeyHit JDAQSnapshotHit; /** * DAQ Event. */ class JDAQEvent : public JDAQPreamble, public JDAQEventHeader { public: /** * Default constructor. */ JDAQEvent() : JDAQPreamble(JLANG::JType()), JDAQEventHeader() {} /** * Constructor. * * \param chronometer DAQ chronometer * \param mask trigger mask */ JDAQEvent(const JDAQChronometer& chronometer, const JDAQTriggerMask& mask = JDAQTriggerMask()) : JDAQPreamble(JLANG::JType()), JDAQEventHeader(chronometer, mask) {} /** * Template const_iterator */ template class const_iterator : public std::vector::const_iterator { public: /** * Default constructor. */ const_iterator() : std::vector::const_iterator() {} /** * Copy constructor. * * \param i iterator */ const_iterator(const typename std::vector::const_iterator& i) : std::vector::const_iterator(i) {} }; /** * Template const_reverse_iterator */ template class const_reverse_iterator : public std::vector::const_reverse_iterator { public: /** * Default constructor. */ const_reverse_iterator() : std::vector::const_reverse_iterator() {} /** * Copy constructor. * * \param i iterator */ const_reverse_iterator(const typename std::vector::const_reverse_iterator& i) : std::vector::const_reverse_iterator(i) {} }; /** * Get container with hits. * * \return container with hits */ template const std::vector& getHits() const; /** * Get begin of data. * * \return begin of data */ template const_iterator begin() const; /** * Get end of data. * * \return end of data */ template const_iterator end() const; /** * Get reverse begin of data. * * \return begin of data */ template const_reverse_iterator rbegin() const; /** * Get reverse end of data. * * \return end of data */ template const_reverse_iterator rend() const; /** * Get number of hits. * * \return number of hits */ template unsigned int size() const; /** * Check emptyness of hit container. * * \return true if empty; else false */ template bool empty() const; /** * Read DAQ event from input. * * \param in JReader * \param event JDAQEvent * \return JReader */ friend inline JReader& operator>>(JReader& in, JDAQEvent& event) { in >> static_cast (event); in >> static_cast(event); in >> event.triggeredHits; in >> event.snapshotHits; return in; } /** * Write DAQ event to output. * * \param out JWriter * \param event JDAQEvent * \return JWriter */ friend inline JWriter& operator<<(JWriter& out, const JDAQEvent& event) { out << static_cast (event); out << static_cast(event); out << event.triggeredHits; out << event.snapshotHits; return out; } /** * Print DAQ Event. * * \param out output stream * \param lpr long print * \return output stream */ ostream& print(ostream& out, const bool lpr = false) const; /** * Get size of object. * * \return number of bytes */ virtual int getSize() const { return (JDAQPreamble ::sizeOf() + JDAQEventHeader::sizeOf() + sizeof(int) + triggeredHits.size() * JDAQTriggeredHit::sizeOf() + sizeof(int) + snapshotHits .size() * JDAQSnapshotHit ::sizeOf()); } ClassDef(JDAQEvent,1); protected: std::vector triggeredHits; std::vector snapshotHits; }; /** * Print DAQ Event. * * \param out output stream * \param event event * \return output stream */ inline ostream& operator<<(ostream& out, const JDAQEvent& event) { return event.print(out, getLongprint(out)); } } #endif