#ifndef __JTRIGGER__JCLBRUNBYRUNSIMULATOR__ #define __JTRIGGER__JCLBRUNBYRUNSIMULATOR__ #include "km3net-dataformat/online/JDAQSummaryFrame.hh" #include "km3net-dataformat/online/JDAQClock.hh" #include "JDetector/JCLBDefaultSimulator.hh" #include "JTrigger/JSummaryRouter.hh" #include "JTrigger/JTriggerToolkit.hh" /** * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { using JDETECTOR::JCLBDefaultSimulator; using JDETECTOR::JModuleIdentifier; using JDETECTOR::JPMTIdentifier; /** * CLB simulation based on run-by-run information. * * This class overwrites the method JCLBDefaultSimulator::getHighRateVeto. * The actual high-rate veto is obtained from summary data. */ class JCLBRunByRunSimulator : public JCLBDefaultSimulator { public: /** * Constructor. * * \param router summary router */ JCLBRunByRunSimulator(const JSummaryRouter& router) : JCLBDefaultSimulator(), summary_router(router) {} /** * Get number of received UDP packets. * * \param id module identifier * \return number of received UDP packets */ virtual int getUDPNumberOfReceivedPackets(const JModuleIdentifier& id) const override { using namespace KM3NETDAQ; if (summary_router.hasSummaryFrame(id.getID())) { const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getID()); return frame.getUDPNumberOfReceivedPackets(); } return 1; } /** * Get maximal sequence number of UDP packet. * * \param id module identifier * \return maximal sequence number */ virtual int getUDPMaximalSequenceNumber(const JModuleIdentifier& id) const override { using namespace KM3NETDAQ; if (summary_router.hasSummaryFrame(id.getID())) { const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getID()); return frame.getUDPMaximalSequenceNumber(); } return 0; } /** * Get UDP trailer status. * * \param id module identifier * \return true */ virtual bool hasUDPTrailer(const JModuleIdentifier& id) const override { using namespace KM3NETDAQ; if (summary_router.hasSummaryFrame(id.getID())) { const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getID()); return frame.hasUDPTrailer(); } return false; } /** * Get high-rate veto of given PMT. * * \param id PMT identifier * \return true if high-rate veto; else false */ virtual bool getHighRateVeto(const JPMTIdentifier& id) const override { using namespace KM3NETDAQ; if (summary_router.hasSummaryFrame(id.getModuleID())) { const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getModuleID()); return !getPMTStatus(frame, JStatus(), id.getPMTAddress()); } return false; } protected: const JSummaryRouter& summary_router; }; } #endif