Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JMatch.hh
Go to the documentation of this file.
1#ifndef __JTRIGGER__JMATCH__
2#define __JTRIGGER__JMATCH__
3
4#include "JLang/JClonable.hh"
5
6
7/**
8 * \file
9 *
10 * Base class for match operations for cluster and hit-preprocessing methods.
11 * \author mdejong
12 */
13namespace JTRIGGER {}
14namespace JPP { using namespace JTRIGGER; }
15
16namespace JTRIGGER {
17
18 using JLANG::JClonable;
19
20
21 /**
22 * Function object interface for hit matching.
23 */
24 template<class JHit_t>
25 class JMatch :
26 public JClonable< JMatch<JHit_t> >
27 {
28 public:
29 /**
30 * Virtual destructor.
31 */
32 virtual ~JMatch()
33 {}
34
35
36 /**
37 * Match operator.
38 *
39 * \param first hit
40 * \param second hit
41 * \return match result
42 */
43 virtual bool operator()(const JHit_t& first, const JHit_t& second) const = 0;
44
45
46 /**
47 * Get number of matches between given hit and data.
48 *
49 * \param hit hit
50 * \param __begin begin of data
51 * \param __end end of data
52 * \return number of matches
53 */
54 template<class T>
55 int count(const JHit_t& hit, T __begin, T __end) const
56 {
57 int n = 0;
58
59 for (T i = __begin; i != __end; ++i) {
60 if ((*this)(hit,*i)) {
61 ++n;
62 }
63 }
64
65 return n;
66 }
67 };
68
69
70 /**
71 * Auxiliary class to handle pointer to match function.
72 */
73 template<class JHit_t>
75 public JClonable< JMatch<JHit_t> , JMatchHelper<JHit_t> >
76 {
77 public:
78
79 typedef bool (*pFun)(const JHit_t&, const JHit_t&); //!< pointer to match function
80
81 /**
82 * Constructor
83 *
84 * \param match pointer to match function
85 */
89
90
91 /**
92 * Match operator.
93 *
94 * \param first hit
95 * \param second hit
96 * \return match result
97 */
98 virtual bool operator()(const JHit_t& first, const JHit_t& second) const override
99 {
100 return match(first, second);
101 }
102
103 protected:
105 };
106
107
108 /**
109 * Auxiliary method to make JMatch object based on pointer to match function.
110 *
111 * \param match pointer to match function
112 * \return match object
113 */
114 template<class JHit_t>
115 JMatchHelper<JHit_t> make_match(bool (*match)(const JHit_t&, const JHit_t&))
116 {
117 return JMatchHelper<JHit_t>(match);
118 }
119}
120
121#endif
Auxiliary class to handle pointer to match function.
Definition JMatch.hh:76
virtual bool operator()(const JHit_t &first, const JHit_t &second) const override
Match operator.
Definition JMatch.hh:98
JMatchHelper(pFun match)
Constructor.
Definition JMatch.hh:86
bool(*) pFun(const JHit_t &, const JHit_t &)
pointer to match function
Definition JMatch.hh:79
Function object interface for hit matching.
Definition JMatch.hh:27
int count(const JHit_t &hit, T __begin, T __end) const
Get number of matches between given hit and data.
Definition JMatch.hh:55
virtual ~JMatch()
Virtual destructor.
Definition JMatch.hh:32
virtual bool operator()(const JHit_t &first, const JHit_t &second) const =0
Match operator.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for triggering.
JMatchHelper< JHit_t > make_match(bool(*match)(const JHit_t &, const JHit_t &))
Auxiliary method to make JMatch object based on pointer to match function.
Definition JMatch.hh:115
Template class for object cloning.
Definition JClonable.hh:59