#ifndef __JTRIGGER__JEVENTOVERLAP__ #define __JTRIGGER__JEVENTOVERLAP__ #include "JTrigger/JEvent.hh" /** * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { /** * Match of two events considering overlap in time. */ class JEventOverlap { public: /** * Constructor. * * \param Tmax_ns maximal time difference between two consecutive events [ns] */ JEventOverlap(const double Tmax_ns) : tmax_ns(Tmax_ns) {} /** * Match criterion. * * \param first first event * \param second second event * \return true if two events overlap in time; else false */ bool operator()(const JEvent& first, const JEvent& second) const { if (first .empty()) return false; if (second.empty()) return false; return (first.rbegin()->getT() >= second. begin()->getT() - tmax_ns - getExtraTime() && first. begin()->getT() <= second.rbegin()->getT() + tmax_ns + getExtraTime()); } /** * Get time window. * * \return maximal time difference between two consecutive events [ns] */ double getTmax() const { return tmax_ns; } /** * Get extra time. * * The extra time is used to accomodate small time gaps (sub-ns) due to numerical precision. * * \return extra time [ns] */ static inline double getExtraTime() { return 0.1; } protected: double tmax_ns; }; } #endif