#ifndef __JMATCH3G__ #define __JMATCH3G__ #include "JTools/JConstants.hh" #include "JTrigger/JMatch.hh" namespace JTRIGGER { namespace { using JTOOLS::getInverseSpeedOfLight; using JTOOLS::getIndexOfRefraction; } /** * 3G match criterion. * This match algorithm is intented for shower signals. */ template class JMatch3G : public JMatch { public: /** * Constructor. * * \param Dmax_m maximal distance between PMTs [m] * \param Tmax_ns maximal extra time [ns] */ JMatch3G(const double Dmax_m, const double Tmax_ns = 0.0) : DMax_m (Dmax_m), TMaxExtra_ns(Tmax_ns) { TMax_ns = DMax_m * getIndexOfRefraction() * getInverseSpeedOfLight() + TMaxExtra_ns; } /** * Clone object. * * \return match result */ JMatch* clone() const { return new JMatch3G(*this); } /** * Match operator. * * \param first hit * \param second hit * \return match result */ virtual bool operator()(const JHit_t& first, const JHit_t& second) const { t = fabs(first.getT() - second.getT()); if (t > TMax_ns) return false; x = first.getX() - second.getX(); y = first.getY() - second.getY(); z = first.getZ() - second.getZ(); d = sqrt(x*x + y*y + z*z); return d <= DMax_m && t <= d * getIndexOfRefraction() * getInverseSpeedOfLight() + TMaxExtra_ns; } double DMax_m; double TMax_ns; double TMaxExtra_ns; private: mutable double x; mutable double y; mutable double z; mutable double d; mutable double t; }; } #endif