#include #include #include #include "km3net-dataformat/online/JDAQEvent.hh" #include "km3net-dataformat/online/JDAQSummaryslice.hh" #include "km3net-dataformat/online/JDAQTimeslice.hh" /** * \author mdejong */ namespace KM3NETDAQ { /** * Constructor. * * \param event DAQ event * \param snapshot use shapshot hits (else use triggered hits) */ JDAQTimeslice::JDAQTimeslice(const JDAQEvent& event, const bool snapshot) : JDAQPreamble(JDAQType()), JDAQTimesliceHeader(event.getDAQChronometer()), std::vector() { using namespace std; map > buffer; if (snapshot) { for (vector::const_iterator hit = event.begin (); hit != event.end (); ++hit) { buffer[hit->getModuleID()].push_back(*hit); } } else { for (vector::const_iterator hit = event.begin(); hit != event.end(); ++hit) { buffer[hit->getModuleID()].push_back(*hit); } } for (map >::iterator entry = buffer.begin(); entry != buffer.end(); ++entry) { sort(entry->second.begin(), entry->second.end()); this->push_back(JDAQSuperFrame(JDAQSuperFrameHeader(getDAQChronometer(), entry->first))); this->rbegin()->add(entry->second.size(), entry->second.data()); } } /** * Constructor. * * \param event DAQ event * \param summary summary * \param snapshot use shapshot hits (else use triggered hits) */ JDAQTimeslice::JDAQTimeslice(const JDAQEvent& event, const JDAQSummaryslice& summary, const bool snapshot) : JDAQPreamble(JDAQType()), JDAQTimesliceHeader(event.getDAQChronometer()), std::vector() { using namespace std; using namespace JPP; map > buffer; if (snapshot) { for (vector::const_iterator hit = event.begin (); hit != event.end (); ++hit) { buffer[hit->getModuleID()].push_back(*hit); } } else { for (vector::const_iterator hit = event.begin(); hit != event.end(); ++hit) { buffer[hit->getModuleID()].push_back(*hit); } } map sumo; for (JDAQSummaryslice::const_iterator i = summary.begin(); i != summary.end(); ++i) { sumo[i->getModuleID()] = i->getDAQFrameStatus(); } for (map >::iterator entry = buffer.begin(); entry != buffer.end(); ++entry) { sort(entry->second.begin(), entry->second.end()); JDAQFrameStatus status = JDAQFrameStatus::getInstance(); map::const_iterator ps = sumo.find(entry->first); if (ps != sumo.end()) { status = ps->second; } this->push_back(JDAQSuperFrame(JDAQSuperFrameHeader(getDAQChronometer(), entry->first, status))); this->rbegin()->add(entry->second.size(), entry->second.data()); } } }