#ifndef __JTRIGGER__JSUPERFRAME2D__ #define __JTRIGGER__JSUPERFRAME2D__ #include #include #include "km3net-dataformat/online/JDAQ.hh" #include "km3net-dataformat/online/JDAQSuperFrame.hh" #include "JDetector/JModule.hh" #include "JTrigger/JModuleHeader.hh" #include "JTrigger/JFrame.hh" #include "JTrigger/JPreprocessor.hh" #include "JTrigger/JDAQHitSelector.hh" #include "JTrigger/JTriggerToolkit.hh" /** * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { using KM3NETDAQ::JDAQSuperFrame; using JDETECTOR::JModule; /** * 2-dimensional frame with time calibrated data from one optical module. * * For each PMT, data are stored in a separate frame. * In the following, the data of a single PMT are assumed to be time ordered. * * Note that the data of each PMT are terminated with an end marker (see class JFrame_t).\n * The data of a given PMT are cleared when the return value of * method JTRIGGER::getDAQStatus or JTRIGGER::getPMTStatus is false. * * The static data member JSuperFrame2D::demultiplex can be used as an I/O buffer. */ template > class JSuperFrame2D : public JModuleHeader, public std::vector< JFrame > { public: typedef JMatch match_type; typedef JFrame value_type; typedef typename std::vector::iterator iterator; typedef typename std::vector::const_iterator const_iterator; typedef typename std::vector::reverse_iterator reverse_iterator; typedef typename std::vector::const_reverse_iterator const_reverse_iterator; /** * Default constructor. */ JSuperFrame2D() {} /** * Process DAQ super frame. * * The time calibration is applied and an appropriate end marker is added. * * \param input DAQ super frame * \param module module data * \param selector DAQ hit selector * \return this 2D super frame */ JSuperFrame2D& operator()(const JDAQSuperFrame& input, const JModule& module, const JDAQHitSelector& selector = JDAQHitDefaultSelector()) { using KM3NETDAQ::NUMBER_OF_PMTS; using namespace JPP; this->setDAQChronometer (input.getDAQChronometer()); this->setModuleIdentifier(input.getModuleIdentifier()); this->setPosition (module.getPosition()); this->resize(NUMBER_OF_PMTS); for (int i = 0; i != NUMBER_OF_PMTS; ++i) { JFrame& frame = (*this)[i]; frame.clear(); frame.setDAQChronometer(this->getDAQChronometer()); frame.setPMTIdentifier (JDAQPMTIdentifier(this->getModuleID(), i)); frame.setAxis (module.getPMT(i).getAxis()); frame.setCalibration (module.getPMT(i).getCalibration()); } int n = input.size(); if (dynamic_cast(&selector) != NULL) { for (JDAQSuperFrame::const_iterator i = input.begin(); n != 0; --n, ++i) { (*this)[i->getPMT()].push_back(*i); } } else { for (JDAQSuperFrame::const_iterator i = input.begin(); n != 0; --n, ++i) { if (selector(*i)) { (*this)[i->getPMT()].push_back(*i); } } } for (int i = 0; i != NUMBER_OF_PMTS; ++i) { if (!getDAQStatus(input, module, i) || !getPMTStatus(input, module, i) || module.getPMT(i).has(PMT_DISABLE)) { (*this)[i].clear(); } } for (int i = 0; i != NUMBER_OF_PMTS; ++i) { (*this)[i].putEndMarker(); } return *this; } /** * Apply high-rate veto. * * \param rate_Hz high-rate veto [Hz] */ void applyHighRateVeto(const double rate_Hz) { for (iterator i = this->begin(); i != this->end(); ++i) { i->applyHighRateVeto(rate_Hz); } } /** * Pre-process data. * * \param option option * \param match match criterion */ void preprocess(JPreprocessor::JOption_t option, const match_type& match) { switch (option) { case JPreprocessor::join_t: for (iterator i = this->begin(); i != this->end(); ++i) { i->join(match); } break; case JPreprocessor::filter_t: for (iterator i = this->begin(); i != this->end(); ++i) { i->filter(match); } break; case JPreprocessor::remove_t: for (iterator i = this->begin(); i != this->end(); ++i) { i->remove(match); } break; default: break; } } /** * Demultiplexer. */ static JSuperFrame2D demultiplex; }; /** * Demultiplexer. */ template JSuperFrame2D JSuperFrame2D::demultiplex; } #endif