#ifndef __JMATCH1D__ #define __JMATCH1D__ #include "JTools/JConstants.hh" #include "JTrigger/JMatch.hh" namespace JTRIGGER { namespace { using JTOOLS::getInverseSpeedOfLight; using JTOOLS::getIndexOfRefraction; } /** * 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 JMatch { public: /** * Constructor. * * \param road_width_m maximal road width [m] * \param Tmax_ns maximal extra time [ns] */ JMatch1D(const double road_width_m, const double Tmax_ns = 0.0) : roadWidth_m (road_width_m), TMaxExtra_ns(Tmax_ns) {} /** * Clone object. * * \return match result */ JMatch* clone() const { return new JMatch1D(*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(); if (x*x + y*y > roadWidth_m*roadWidth_m) return false; z = first.getZ() - second.getZ(); d = sqrt(x*x + y*y); t = fabs(first.getT() - second.getT() - z * getInverseSpeedOfLight()); return t <= d * getTanThetaC() * getInverseSpeedOfLight() + TMaxExtra_ns; } double roadWidth_m; double TMaxExtra_ns; private: mutable double x; mutable double y; mutable double z; mutable double d; mutable double t; }; } #endif