#ifndef __JTRIGGERINPUT__ #define __JTRIGGERINPUT__ #include #include #include "JDAQ/JDAQChronometer.hh" #include "JTrigger/JTimeslice.hh" #include "JTrigger/JHitL0.hh" #include "JTrigger/JHitToolkit.hh" #include "JGeometry3D/JAxis3D.hh" namespace JTRIGGER { namespace { using std::vector; using std::distance; using std::less; using std::sort; using KM3NETDAQ::JDAQChronometer; using JGEOMETRY3D::JAxis3D; } /** * Data structure for input to trigger algorithm. * The input data for the trigger are time ordered and contain an end marker. * The member methods size() and end() refer to the position before the end marker. */ class JTriggerInput : public JDAQChronometer, public vector { public: /** * Constructor. * * \param input input data */ template JTriggerInput(const JTimeslice& input) : vector() { setDAQChronometer(input.getDAQChronometer()); int n = 0; for (typename JTimeslice::const_iterator frame = input.begin(); frame != input.end(); ++frame) n += frame->size(); this->resize(n + 1); // reserve space for end marker typedef JHitToolkit tool; iterator p = this->begin(); for (typename JTimeslice::const_iterator frame = input.begin(); frame != input.end(); ++frame) { const JDAQPMTIdentifier pmt(frame->getModuleID(), frame->getPMTAddress()); const JAxis3D& axis = frame->getAxis(); for (typename JFrame::const_iterator i = frame->begin(); i != frame->end(); ++i, ++p) *p = JHitL0(pmt, axis, tool::getJHit(*i)); } *p = JHitL0(JDAQPMTIdentifier(), JAxis3D(), tool::getEndMarker()); __end = vector::end(); --__end; sort(this->begin(), this->end(), less()); } const_iterator end() const { return __end; } iterator end() { return __end; } int size() const { return distance(this->begin(), this->end()); } bool empty() const { return size() == 0; } private: vector::iterator __end; }; } #endif