#ifndef __JMATCH3D__ #define __JMATCH3D__ #include "JTools/JConstants.hh" #include "JTrigger/JMatch.hh" namespace JTRIGGER { namespace { using JTOOLS::getInverseSpeedOfLight; using JTOOLS::getIndexOfRefraction; } /** * 3D match criterion. * This match algorithm is intented for muon or shower signals. */ template class JMatch3D : public JMatch { public: /** * Constructor. * * \param Tmax_ns maximal extra time [ns] */ JMatch3D(const double Tmax_ns = 0.0) : TMaxExtra_ns(Tmax_ns) {} /** * Clone object. * * \return match result */ JMatch* clone() const { return new JMatch3D(*this); } /** * Match operator. * * \param first hit * \param second hit * \return match result */ virtual bool operator()(const JHit_t& first, const JHit_t& second) const { 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