#ifndef __JTRIGGER__JTIMESLICEL1__ #define __JTRIGGER__JTIMESLICEL1__ #include #include #include "km3net-dataformat/online/JDAQTimeslice.hh" #include "JTrigger/JTimeslice.hh" #include "JDetector/JModuleRouter.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JTimeRange.hh" #include "JTrigger/JTimesliceRouter.hh" #include "JTrigger/JHitToolkit.hh" /** * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { using KM3NETDAQ::JDAQTimeslice; using JDETECTOR::JModule; using JDETECTOR::JModuleRouter; using JDETECTOR::JTimeRange; using JDETECTOR::getTimeRange; /** * Auxiliary class to build JDAQTimeslice for L1 timeslice. */ template class JTimesliceL1 : public JDAQTimeslice_t { public: /** * Default constructor. */ JTimesliceL1() : JDAQTimeslice_t() {} /** * Constructor. * * The raw data referenced in the time slice router are sampled according * the triggered time slice data and the given time window.\n * The status of each frame is taken from the raw data. * * \param timeslice triggered timeslice (e.g.\ L1) * \param timesliceRouter timeslice router * \param moduleRouter module router * \param TMaxLocal_ns time window [ns] */ template JTimesliceL1(const JTimeslice& timeslice, const JTimesliceRouter& timesliceRouter, const JModuleRouter& moduleRouter, const double TMaxLocal_ns) : JDAQTimeslice_t() { using namespace std; this->setDAQChronometer(timeslice.getDAQChronometer()); vector buffer; for (typename JTimeslice::const_iterator frame = timeslice.begin(); frame != timeslice.end(); ++frame) { const JModule& module = moduleRouter.getModule(frame->getModuleID()); const JTimeRange timeOffset = getTimeRange(JTimeRange(0,0), module); buffer.clear(); for (typename JFrame::const_iterator p = frame->begin(); p != frame->end(); ) { double Tmin = frame->getT(*p); double Tmax = Tmin + TMaxLocal_ns; while (++p != frame->end() && frame->getT(*p) <= Tmax) { Tmax = frame->getT(*p) + TMaxLocal_ns; } const JDAQFrameSubset& subset = timesliceRouter.getFrameSubset(frame->getModuleID(), JTimeRange(Tmin, Tmax).add(timeOffset)); for (JDAQFrameSubset::const_iterator i = subset.begin(); i != subset.end(); ++i) { const JCalibration& calibration = module.getPMT(i->getPMT()).getCalibration(); const double t1 = getTime(*i, calibration); if (t1 >= Tmin && t1 <= Tmax) { buffer.push_back(*i); } } } this->push_back(JDAQSuperFrame(timesliceRouter.getSuperFrame(frame->getModuleID()).getDAQSuperFrameHeader())); this->rbegin()->add(buffer.size(), buffer.data()); } } }; } #endif