#ifndef __JTRIGGER__JBUILDHELPER__ #define __JTRIGGER__JBUILDHELPER__ #include "km3net-dataformat/online/JDAQSuperFrame.hh" #include "km3net-dataformat/online/JDAQTimeslice.hh" #include "km3net-dataformat/online/JDAQEvent.hh" #include "JDetector/JModule.hh" #include "JDetector/JModuleRouter.hh" /** * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { using KM3NETDAQ::JDAQSuperFrame; using KM3NETDAQ::JDAQTimeslice; using KM3NETDAQ::JDAQEvent; using JDETECTOR::JModule; using JDETECTOR::JModuleRouter; /** * Auxiliary class to extend hit building functionality to all DAQ data types.\n * The implementation of this functionality is based on a static cast of * the given template parameter (known as "curiously recurring template pattern").\n * The template parameter should refer to a class which provides for * an implementation of the following operator: *
   *      template
   *      void operator()(const JDAQSuperFrame& super_frame,
   *                      const JModule&        module,
   *                      JOutput_t             out) const
   * 
* where out refers to an STL compatible output iterator.\n * The data type of the JBuild_t class corresponds to * the pointed-to element of the output iterator. */ template struct JBuildHelper { /** * Build hits from uncalibrated DAQ data. * * The time calibration is applied. * Note that the output data are not time sorted. * * \param timeslice DAQ time slice * \param router module router * \param out output data */ template void operator()(const JDAQTimeslice& timeslice, const JModuleRouter& router, JOutput_t out) const { for (JDAQTimeslice::const_iterator i = timeslice.begin(); i != timeslice.end(); ++i) { if (router.hasModule(i->getModuleID())) { static_cast(*this)(*i, router.getModule(i->getModuleID()), out); } } } /** * Build hits from uncalibrated DAQ data. * * The time calibration is applied. * Note that the output data are not time sorted. * * \param event DAQ event * \param router module router * \param snapshot use shapshot hits (else use triggered hits) * \param out output data */ template void operator()(const JDAQEvent& event, const JModuleRouter& router, const bool snapshot, JOutput_t out) const { static_cast(*this)(JDAQTimeslice(event, snapshot), router, out); } /** * Build hits from uncalibrated DAQ data. * * The snapshot data of the DAQ event are used. * The time calibration is applied. * Note that the output data are not time sorted. * * \param event DAQ event * \param router module router * \param out output data */ template void operator()(const JDAQEvent& event, const JModuleRouter& router, JOutput_t out) const { static_cast(*this)(JDAQTimeslice(event, true), router, out); } }; } #endif