#ifndef __JTRIGGER__JMATCH3D__ #define __JTRIGGER__JMATCH3D__ #include "JPhysics/JConstants.hh" #include "JTrigger/JMatch.hh" /** * \file * * Match operator for Cherenkov light from muon in any direction. * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { using JPHYSICS::getInverseSpeedOfLight; using JPHYSICS::getIndexOfRefraction; /** * 3D match criterion. * This match algorithm is intented for muon or shower signals. */ template class JMatch3D : public JClonable< JMatch, JMatch3D > { public: /** * Constructor. * * \param Tmax_ns maximal extra time [ns] */ JMatch3D(const double Tmax_ns = 0.0) : TMaxExtra_ns(Tmax_ns), x(0.0), y(0.0), z(0.0), d(0.0), t(0.0) {} /** * Match operator. * * \param first hit * \param second hit * \return match result */ virtual bool operator()(const JHit_t& first, const JHit_t& second) const override { x = first.getX() - second.getX(); y = first.getY() - second.getY(); z = first.getZ() - second.getZ(); d = sqrt(x*x + y*y + z*z); t = fabs(first.getT() - second.getT()); return t <= d * getIndexOfRefraction() * getInverseSpeedOfLight() + TMaxExtra_ns; } double TMaxExtra_ns; private: mutable double x; mutable double y; mutable double z; mutable double d; mutable double t; }; } #endif