#ifndef __JTRIGGER__JPMTRUNBYRUNSIMULATOR__ #define __JTRIGGER__JPMTRUNBYRUNSIMULATOR__ #include "km3net-dataformat/online/JDAQSummaryFrame.hh" #include "JDetector/JPMTDefaultSimulator.hh" #include "JDetector/JPMTParametersMap.hh" #include "JDetector/JDetector.hh" #include "JDAQ/JHighRateVeto.hh" #include "JTrigger/JSummaryRouter.hh" #include "JTrigger/JTriggerToolkit.hh" /** * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { using JDETECTOR::JPMTIdentifier; using JDETECTOR::JPMTDefaultSimulator; using JDETECTOR::JPMTParametersMap; using JDETECTOR::JDetector; /** * PMT simulation based on run-by-run information. * * This class overwrites the method JPMTDefaultSimulator::getPMTStatus. * The actual PMT status is obtained from summary data. */ class JPMTRunByRunSimulator : public JPMTDefaultSimulator { public: /** * Constructor. * * \param router summary router * \param parameters PMT parameters * \param detector detector */ JPMTRunByRunSimulator(const JSummaryRouter& router, const JPMTParametersMap& parameters, const JDetector& detector) : JPMTDefaultSimulator(parameters, detector), summary_router(router), QE(parameters.getQE()) {} /** * Get PMT status. * * \param id PMT identifier * \param window time range * \param status PMT status * \return status */ virtual bool getPMTStatus(const JPMTIdentifier& id, const JTimeRange& window, const JStatus& status) const override { using KM3NETDAQ::getMaximalTime; using JTRIGGER::getDAQStatus; using JTRIGGER::getPMTStatus; if (summary_router.hasSummaryFrame(id.getModuleID())) { const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getModuleID()); const int pmt = id.getPMTAddress(); return (getPMTStatus(status) && getDAQStatus(frame, status) && window.getUpperLimit() <= getMaximalTime(getRate(frame,pmt) * QE)); } return false; } protected: const JSummaryRouter& summary_router; const double QE; }; } #endif