#ifndef __JSUPPORT__JSUMMARYFILEROUTER__ #define __JSUPPORT__JSUMMARYFILEROUTER__ #include #include "km3net-dataformat/online/JDAQSummaryslice.hh" #include "km3net-dataformat/online/JDAQHeader.hh" #include "JDAQ/JDAQEvaluator.hh" #include "JDAQ/JSupport.hh" #include "JSupport/JSummaryRouter.hh" #include "JSupport/JTreeScanner.hh" /** * \author mdejong */ namespace JSUPPORT {} namespace JPP { using namespace JSUPPORT; } namespace JSUPPORT { using KM3NETDAQ::JDAQSummaryslice; using KM3NETDAQ::JDAQEvaluator; using KM3NETDAQ::JDAQHeader; /** * File router for fast addressing of summary data. * * The member method update() should be used to update the internal router for a given event. * The member method getRate(const JDAQPMTIdentifier&) const can subsequently be used to obtain * the measured singles rate for a given PMT at the closest time of the event. */ class JSummaryFileRouter : public JSummaryRouter, public JTreeScanner { public: /** * Constructor. * * \param file_name file name */ JSummaryFileRouter(const std::string& file_name) : JSummaryRouter(), JTreeScanner(file_name) {} /** * Constructor. * * \param file_name file name * \param rate_Hz default singles rate [Hz] */ JSummaryFileRouter(const std::string& file_name, const double rate_Hz) : JSummaryRouter(rate_Hz), JTreeScanner(file_name) {} /** * Update router. * * \param header header */ void update(const JDAQHeader& header) { static Long64_t previous = -1; const Long64_t index = this->find(header); if (index != -1) { if (index != previous) { previous = index; JSummaryRouter::update(this->getEntry(index)); } } } }; } #endif