#ifndef __JTRIGGER__JMATCH1D__ #define __JTRIGGER__JMATCH1D__ #include "JPhysics/JConstants.hh" #include "JTrigger/JMatch.hh" /** * \file * * Match operator for Cherenkov light from muon with given direction. * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { using JPHYSICS::getInverseSpeedOfLight; using JPHYSICS::getIndexOfRefraction; using JPHYSICS::getTanThetaC; /** * 1D match criterion. * This match algorithm is intented for muon signals. * It is assumed that the muon direction is along the z-axis. */ template class JMatch1D : public JClonable< JMatch, JMatch1D > { public: /** * Constructor. * * \param roadWidth_m maximal road width [m] * \param Tmax_ns maximal extra time [ns] */ JMatch1D(const double roadWidth_m, const double Tmax_ns = 0.0) : RMax_m (roadWidth_m), TMaxExtra_ns(Tmax_ns), x(0.0), y(0.0), z(0.0), d(0.0), t(0.0) { TMax_ns = 0.5 * RMax_m * getTanThetaC() * 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 { z = first.getZ() - second.getZ(); t = fabs(first.getT() - second.getT() - z * getInverseSpeedOfLight()); if (t > TMax_ns) { return false; } x = first.getX() - second.getX(); y = first.getY() - second.getY(); d = sqrt(x*x + y*y); if (d <= 0.5 * RMax_m) return t <= d * getTanThetaC() * getInverseSpeedOfLight() + TMaxExtra_ns; else if (d <= RMax_m) return t <= (RMax_m - d) * getTanThetaC() * getInverseSpeedOfLight() + TMaxExtra_ns; return false; } double RMax_m; double TMax_ns; double TMaxExtra_ns; private: mutable double x; mutable double y; mutable double z; mutable double d; mutable double t; }; } #endif