#ifndef __JTRIGGER__JMATCH3G__ #define __JTRIGGER__JMATCH3G__ #include "JPhysics/JConstants.hh" #include "JTrigger/JMatch.hh" /** * \file * * Match operator for Cherenkov light from shower in any direction. * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { using JPHYSICS::getInverseSpeedOfLight; using JPHYSICS::getIndexOfRefraction; /** * 3G match criterion. * This match algorithm is intented for shower signals. */ template class JMatch3G : public JClonable< JMatch, JMatch3G > { public: /** * Constructor. * * \param Dmax_m maximal distance traveled by photon [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), x(0.0), y(0.0), z(0.0), d(0.0), t(0.0) { TMax_ns = 0.5 * DMax_m * getIndexOfRefraction() * getInverseSpeedOfLight() + TMaxExtra_ns; } /** * Match operator. * * \param first hit * \param second hit * \return match result */ virtual bool operator()(const JHit_t& first, const JHit_t& second) const override { 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); if (d <= 0.5 * DMax_m) return t <= d * getIndexOfRefraction() * getInverseSpeedOfLight() + TMaxExtra_ns; else if (d <= DMax_m) return t <= (DMax_m - d) * getIndexOfRefraction() * getInverseSpeedOfLight() + TMaxExtra_ns; return false; } 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