#ifndef __JRECONSTRUCTION__JMODULEL0__ #define __JRECONSTRUCTION__JMODULEL0__ #include #include #include "km3net-dataformat/online/JDAQSummaryFrame.hh" #include "km3net-dataformat/online/JDAQPMTIdentifier.hh" #include "JDetector/JModule.hh" #include "JPhysics/JK40Rates.hh" #include "JTrigger/JHitR0.hh" #include "JTrigger/JHitL0.hh" #include "JTrigger/JTriggerToolkit.hh" #include "JFit/JFitToolkit.hh" #include "JFit/JTimeRange.hh" #include "JReconstruction/JHitW0.hh" /** * \author mdejong */ namespace JRECONSTRUCTION {} namespace JPP { using namespace JRECONSTRUCTION; } namespace JRECONSTRUCTION { using KM3NETDAQ::JDAQEvent; using KM3NETDAQ::JDAQSummaryFrame; using JDETECTOR::JModule; using JDETECTOR::JPosition3D; using JDETECTOR::JPMT; using JTRIGGER::JHitR0; using JPHYSICS::JRateL0_t; using JPHYSICS::JRateL1_t; using JFIT::JTimeRange; /** * Auxiliary class for handling module response. */ struct JModuleL0 : std::vector { /** * Default constructor. */ JModuleL0() {} /** * Constructor. * * \param module module * \param frame frame * \param data data */ JModuleL0(const JModule& module, const JDAQSummaryFrame& frame, const std::vector& data) : std::vector(data), module(module), frame (frame) {} /** * Smart pointer. * * \return module */ const JModule* operator->() const { return &module; } /** * Get status of PMT. * * \param pmt PMT * \return true is valid; else false */ bool getStatus(const int pmt) const { using namespace JPP; return (getDAQStatus(frame, module, pmt) && getPMTStatus(frame, module, pmt) && frame[pmt].is_valid() && !module.getPMT(pmt).has(PMT_DISABLE)); } /** * Get probability of response in optical module due to random background. * * \param R_Hz multiples rates [Hz] * \param T_ns time window [ns] * \return probability */ inline double getProbability(const JRateL1_t& R_Hz, const JTimeRange& T_ns) const { using namespace std; using namespace JPP; multiset top; for (const_iterator hit = this->begin(); hit != this->end(); ++hit) { if (T_ns(hit->getT())) { top.insert(hit->getPMT()); } } size_t N = 0; // number of active PMTs size_t M = 0; // multiplicity double R = 0.0; // total rate for (size_t i = 0; i != module.size(); ++i) { if (getStatus(i)) { N += 1; M += top.count(i); R += frame.getRate(i); } } if (N != 0) return JFIT::getProbability(N, M, JK40Rates(R/N, R_Hz), (T_ns.getUpperLimit() - T_ns.getLowerLimit())); else return (M == 0 ? 1.0 : 0.0); } JModule module; JDAQSummaryFrame frame; }; } #endif