#ifndef __JTRIGGER__JBUILDL0__ #define __JTRIGGER__JBUILDL0__ #include "JTrigger/JHitToolkit.hh" #include "JTrigger/JSuperFrame2D.hh" #include "JTrigger/JHit.hh" #include "JTrigger/JHitL0.hh" #include "JTrigger/JHitR0.hh" #include "JTrigger/JHitR1.hh" #include "JTrigger/JBuildHelper.hh" #include "JTrigger/JBuild.hh" #include "JGeometry3D/JAxis3D.hh" #include "km3net-dataformat/online/JDAQSuperFrame.hh" #include "JDetector/JModule.hh" /** * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { using KM3NETDAQ::JDAQSuperFrame; using JDETECTOR::JModule; /** * Template L0 hit builder. * * An L0 hit is a hit from a PMT. */ template class JBuildL0 : public JBuildHelper< JBuildL0 >, public JBuild { public: using JBuildHelper< JBuildL0 >::operator(); typedef JHit_t value_type; /** * Default constructor. */ JBuildL0() {} /** * Build hits from calibrated data. * * Note that the output data are not time sorted. * * \param input input L0 data * \param out output L0 data */ template void operator()(const JSuperFrame2D& input, JOutput_t out) const { for (typename JSuperFrame2D::const_iterator frame = input.begin(); frame != input.end(); ++frame) { int n = frame->size(); for (typename JSuperFrame2D::value_type::const_iterator i = frame->begin(); n != 0; ++i, --n) { *out = *i; ++out; } } } /** * Build hits from uncalibrated DAQ data. * * The time calibration is applied. * Note that the output data are not time sorted. * * \param input DAQ super frame * \param module module * \param out output L0 data */ template void operator()(const JDAQSuperFrame& input, const JModule& module, JOutput_t out) const { if (!input.empty()) { (*this)(this->demultiplex(input, module), out); } } }; /** * Template specialisation of L0 builder for JHitL0 data type. */ template<> class JBuildL0 : public JBuildHelper< JBuildL0 >, public JBuild { public: using JBuildHelper< JBuildL0 >::operator(); typedef JHitL0 value_type; /** * Default constructor. */ JBuildL0() {} /** * Build hits from calibrated data. * * Note that the output data are not time sorted. * * \param input input L0 data * \param out output L0 data */ template void operator()(const JSuperFrame2D& input, JOutput_t out) const { using namespace JPP; for (typename JSuperFrame2D::const_iterator frame = input.begin(); frame != input.end(); ++frame) { const JDAQPMTIdentifier& id = frame->getPMTIdentifier(); const JAxis3D& axis = frame->getAxis(); int n = frame->size(); for (typename JSuperFrame2D::value_type::const_iterator i = frame->begin(); n != 0; ++i, --n) { *out = JHitL0(id, axis, *i); ++out; } } } /** * Build hits from uncalibrated DAQ data. * * The time calibration is applied. * Note that the output data are not time sorted. * * \param input DAQ super frame * \param module module * \param out output L0 data */ template void operator()(const JDAQSuperFrame& input, const JModule& module, JOutput_t out) const { if (!input.empty()) { (*this)(this->demultiplex(input, module), out); } } }; /** * Template specialisation of L0 builder for JHitR0 data type. */ template<> class JBuildL0 : public JBuildHelper< JBuildL0 >, public JBuild { public: using JBuildHelper< JBuildL0 >::operator(); typedef JHitR0 value_type; /** * Default constructor. */ JBuildL0() {} /** * Build hits from calibrated data. * * Note that the output data are not time sorted. * * \param input input L0 data * \param out output L0 data */ template void operator()(const JSuperFrame2D& input, JOutput_t out) const { using namespace JPP; for (typename JSuperFrame2D::const_iterator frame = input.begin(); frame != input.end(); ++frame) { const JDAQPMTIdentifier& id = frame->getPMTIdentifier(); int n = frame->size(); for (typename JSuperFrame2D::value_type::const_iterator i = frame->begin(); n != 0; ++i, --n) { *out = JHitR0(id.getPMTAddress(), *i); ++out; } } } /** * Build hits from uncalibrated DAQ data. * * The time calibration is applied. * Note that the output data are not time sorted. * * \param input DAQ super frame * \param module module * \param out output L0 data */ template void operator()(const JDAQSuperFrame& input, const JModule& module, JOutput_t out) const { if (!input.empty()) { (*this)(this->demultiplex(input, module), out); } } }; /** * Template specialisation of L0 builder for JHitR1 data type. */ template<> class JBuildL0 : public JBuildHelper< JBuildL0 >, public JBuild { public: using JBuildHelper< JBuildL0 >::operator(); typedef JHitR1 value_type; /** * Default constructor. */ JBuildL0() {} /** * Build hits from calibrated data. * * Note that the output data are not time sorted. * * \param input input L0 data * \param out output L0 data */ template void operator()(const JSuperFrame2D& input, JOutput_t out) const { using namespace JPP; for (typename JSuperFrame2D::const_iterator frame = input.begin(); frame != input.end(); ++frame) { const JDAQModuleIdentifier& id = frame->getModuleIdentifier(); const JPosition3D& pos = frame->getPosition(); int n = frame->size(); for (typename JSuperFrame2D::value_type::const_iterator i = frame->begin(); n != 0; ++i, --n) { *out = JHitR1(id, pos, *i); ++out; } } } /** * Build hits from uncalibrated DAQ data. * * The time calibration is applied. * Note that the output data are not time sorted. * * \param input DAQ super frame * \param module module * \param out output L0 data */ template void operator()(const JDAQSuperFrame& input, const JModule& module, JOutput_t out) const { if (!input.empty()) { (*this)(this->demultiplex(input, module), out); } } }; } #endif