Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JEventOverlap.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JEVENTOVERLAP__
2 #define __JTRIGGER__JEVENTOVERLAP__
3 
4 #include <functional>
5 
6 #include "JTrigger/JEvent.hh"
7 
8 
9 /**
10  * \author mdejong
11  */
12 
13 namespace JTRIGGER {}
14 namespace JPP { using namespace JTRIGGER; }
15 
16 namespace JTRIGGER {
17 
18 
19  /**
20  * Match of two events considering overlap in time.
21  */
22  class JEventOverlap :
23  std::binary_function<JEvent, JEvent, bool>
24  {
25  public:
26  /**
27  * Constructor.
28  *
29  * \param Tmax_ns maximal time difference between two consecutive events [ns]
30  */
31  JEventOverlap(const double Tmax_ns) :
32  tmax_ns(Tmax_ns)
33  {}
34 
35 
36  /**
37  * Match criterion.
38  *
39  * \param first first event
40  * \param second second event
41  * \return true if two events overlap in time; else false
42  */
43  bool operator()(const JEvent& first, const JEvent& second) const
44  {
45  if (first .empty()) return false;
46  if (second.empty()) return false;
47 
48  return (first.rbegin()->getT() >= second. begin()->getT() - tmax_ns &&
49  first. begin()->getT() <= second.rbegin()->getT() + tmax_ns);
50  }
51 
52 
53  /**
54  * Get time window.
55  *
56  * \return maximal time difference between two consecutive events [ns]
57  */
58  double getTmax() const
59  {
60  return tmax_ns;
61  }
62 
63  protected:
64  double tmax_ns;
65  };
66 }
67 
68 #endif
Match of two events considering overlap in time.
bool operator()(const JEvent &first, const JEvent &second) const
Match criterion.
double getTmax() const
Get time window.
JEventOverlap(const double Tmax_ns)
Constructor.
Triggered event.
Definition: JEvent.hh:31