CMS 3D CMS Logo

TriggerExpressionOperators.h
Go to the documentation of this file.
1 #ifndef HLTrigger_HLTcore_TriggerExpressionOperators_h
2 #define HLTrigger_HLTcore_TriggerExpressionOperators_h
3 
4 #include <memory>
5 
7 
8 namespace triggerExpression {
9 
10  // abstract unary operator
11  class UnaryOperator : public Evaluator {
12  public:
14 
15  // initialize the depending modules
16  void init(const Data& data) override { m_arg->init(data); }
17 
18  // apply mask(s) to the Evaluator
19  void mask(Evaluator const& arg) override { m_arg->mask(arg); }
20 
21  // return the patterns from the depending modules
22  std::vector<std::string> patterns() const override { return m_arg->patterns(); }
23 
24  protected:
25  std::unique_ptr<Evaluator> m_arg;
26  };
27 
28  // abstract binary operator
29  class BinaryOperator : public Evaluator {
30  public:
31  BinaryOperator(Evaluator* arg1, Evaluator* arg2) : m_arg1(arg1), m_arg2(arg2) {}
32 
33  // initialize the depending modules
34  void init(const Data& data) override {
35  m_arg1->init(data);
36  m_arg2->init(data);
37  }
38 
39  // apply mask(s) to the Evaluators
40  void mask(Evaluator const& arg) override {
41  m_arg1->mask(arg);
42  m_arg2->mask(arg);
43  }
44 
45  // return the patterns from the depending modules
46  std::vector<std::string> patterns() const override {
47  std::vector<std::string> patterns = m_arg1->patterns();
48  auto patterns2 = m_arg2->patterns();
49  patterns.insert(
50  patterns.end(), std::make_move_iterator(patterns2.begin()), std::make_move_iterator(patterns2.end()));
51  return patterns;
52  }
53 
54  protected:
55  std::unique_ptr<Evaluator> m_arg1;
56  std::unique_ptr<Evaluator> m_arg2;
57  };
58 
59  // concrete operators
60 
61  class OperatorNot : public UnaryOperator {
62  public:
64 
65  bool operator()(const Data& data) const override { return not(*m_arg)(data); }
66 
67  void dump(std::ostream& out, bool const ignoreMasks = false) const override {
68  out << '(';
69  out << "NOT ";
70  m_arg->dump(out, ignoreMasks);
71  out << ')';
72  }
73  };
74 
75  class OperatorAnd : public BinaryOperator {
76  public:
77  OperatorAnd(Evaluator* arg1, Evaluator* arg2) : BinaryOperator(arg1, arg2) {}
78 
79  bool operator()(const Data& data) const override {
80  // force the execution of both arguments, otherwise prescalers won't work properly
81  bool r1 = (*m_arg1)(data);
82  bool r2 = (*m_arg2)(data);
83  return r1 and r2;
84  }
85 
86  void dump(std::ostream& out, bool const ignoreMasks = false) const override {
87  out << '(';
88  m_arg1->dump(out, ignoreMasks);
89  out << " AND ";
90  m_arg2->dump(out, ignoreMasks);
91  out << ')';
92  }
93  };
94 
95  class OperatorOr : public BinaryOperator {
96  public:
97  OperatorOr(Evaluator* arg1, Evaluator* arg2) : BinaryOperator(arg1, arg2) {}
98 
99  bool operator()(const Data& data) const override {
100  // force the execution of both arguments, otherwise prescalers won't work properly
101  bool r1 = (*m_arg1)(data);
102  bool r2 = (*m_arg2)(data);
103  return r1 or r2;
104  }
105 
106  void dump(std::ostream& out, bool const ignoreMasks = false) const override {
107  out << '(';
108  m_arg1->dump(out, ignoreMasks);
109  out << " OR ";
110  m_arg2->dump(out, ignoreMasks);
111  out << ')';
112  }
113  };
114 
115  class OperatorXor : public BinaryOperator {
116  public:
117  OperatorXor(Evaluator* arg1, Evaluator* arg2) : BinaryOperator(arg1, arg2) {}
118 
119  bool operator()(const Data& data) const override {
120  // force the execution of both arguments, otherwise prescalers won't work properly
121  bool r1 = (*m_arg1)(data);
122  bool r2 = (*m_arg2)(data);
123  return r1 xor r2;
124  }
125 
126  void dump(std::ostream& out, bool const ignoreMasks = false) const override {
127  out << '(';
128  m_arg1->dump(out, ignoreMasks);
129  out << " XOR ";
130  m_arg2->dump(out, ignoreMasks);
131  out << ')';
132  }
133  };
134 
136  public:
137  OperatorMasking(Evaluator* arg1, Evaluator* arg2) : BinaryOperator(arg1, arg2) {}
138 
139  bool operator()(const Data& data) const override { return (*m_arg1)(data); }
140 
141  void init(const Data& data) override {
142  m_arg1->init(data);
143  m_arg2->init(data);
144  m_arg1->mask(*m_arg2);
145  }
146 
147  // apply mask(s) only to the first Evaluator
148  // (the second Evaluator is not used in the decision of OperatorMasking)
149  void mask(Evaluator const& arg) override { m_arg1->mask(arg); }
150 
151  void dump(std::ostream& out, bool const ignoreMasks = false) const override {
152  out << '(';
153  // ignore masks on the first Evaluator to dump the full logical expression
154  m_arg1->dump(out, true);
155  out << " MASKING ";
156  m_arg2->dump(out, ignoreMasks);
157  out << ')';
158  }
159  };
160 
161 } // namespace triggerExpression
162 
163 #endif // HLTrigger_HLTcore_TriggerExpressionOperators_h
bool operator()(const Data &data) const override
void mask(Evaluator const &arg) override
std::vector< std::string > patterns() const override
bool operator()(const Data &data) const override
void init(const Data &data) override
void dump(std::ostream &out, bool const ignoreMasks=false) const override
BinaryOperator(Evaluator *arg1, Evaluator *arg2)
void mask(Evaluator const &arg) override
void mask(Evaluator const &arg) override
OperatorOr(Evaluator *arg1, Evaluator *arg2)
bool operator()(const Data &data) const override
A arg
Definition: Factorize.h:31
void init(const Data &data) override
void dump(std::ostream &out, bool const ignoreMasks=false) const override
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
OperatorMasking(Evaluator *arg1, Evaluator *arg2)
bool operator()(const Data &data) const override
void dump(std::ostream &out, bool const ignoreMasks=false) const override
bool operator()(const Data &data) const override
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
void dump(std::ostream &out, bool const ignoreMasks=false) const override
void dump(std::ostream &out, bool const ignoreMasks=false) const override
OperatorXor(Evaluator *arg1, Evaluator *arg2)
std::vector< std::string > patterns() const override
void init(const Data &data) override
OperatorAnd(Evaluator *arg1, Evaluator *arg2)