#ifndef __JTRIGGEREDFILESCANNER__ #define __JTRIGGEREDFILESCANNER__ #include "JLang/JTypeList.hh" #include "JLang/JNullType.hh" #include "JLang/JMultiPointer.hh" #include "km3net-dataformat/offline/Evt.hh" #include "km3net-dataformat/online/JDAQEvent.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JParallelFileScanner.hh" #include "JSupport/JTreeScanner.hh" #include "JSupport/JSupport.hh" /** * \file * * Synchronously read DAQ events and Monte Carlo events (and optionally other events). * \author mdejong */ namespace JSUPPORT {} namespace JPP { using namespace JSUPPORT; } namespace JSUPPORT { using JLANG::JTypeList; using JLANG::JNullType; using JLANG::JMultiPointer; using KM3NETDAQ::JDAQEvent; /** * Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events). * It is assumed that the TTree corresponding to the template argument and * the TTree with KM3NETDAQ::JDAQEvent can be read in parallel. */ template class JFileScanner_t = JMultipleFileScanner> struct JTriggeredFileScanner : public JParallelFileScanner, JFileScanner_t> { typedef JTypeList typelist; typedef JParallelFileScanner parallel_filescannner_type; typedef JMultiPointer< JTypeList > multi_pointer_type; /** * Default constructor. */ JTriggeredFileScanner() : parallel_filescannner_type() {} /** * Constructor. * * \param input input */ JTriggeredFileScanner(const typename parallel_filescannner_type::input_type& input) { this->configure(input, JLimit()); } /** * Constructor. * * \param input input * \param limit limit */ JTriggeredFileScanner(const typename parallel_filescannner_type::input_type& input, const JLimit& limit) { this->configure(input, limit); } /** * Check availability of next element. * * \return true if the iteration has more elements; else false */ virtual bool hasNext() override { bool has_next = parallel_filescannner_type::hasNext(); if (has_next && file_name != this->getFilename()) { in.configure(this->getFilename()); file_name = this->getFilename(); } return has_next; } /** * Get next element. * * \return multi-pointer to elements */ virtual const multi_pointer_type& next() override { static multi_pointer_type ps; typename parallel_filescannner_type::multi_pointer_type __p = parallel_filescannner_type::next(); JDAQEvent* tev = __p; Evt* event = in.getEntry(tev->getCounter()); ps.reset(event, __p); return ps; } protected: JTreeScanner in; std::string file_name; }; } #endif