CMS 3D CMS Logo

TriggerExpressionOperators.h
Go to the documentation of this file.
1 #ifndef HLTrigger_HLTfilters_TriggerExpressionOperators_h
2 #define HLTrigger_HLTfilters_TriggerExpressionOperators_h
3 
4 #include <memory>
6 
7 namespace triggerExpression {
8 
9  // abstract unary operator
10  class UnaryOperator : public Evaluator {
11  public:
13 
14  // initialize the depending modules
15  void init(const Data& data) override { m_arg->init(data); }
16 
17  protected:
18  std::unique_ptr<Evaluator> m_arg;
19  };
20 
21  // abstract binary operator
22  class BinaryOperator : public Evaluator {
23  public:
24  BinaryOperator(Evaluator* arg1, Evaluator* arg2) : m_arg1(arg1), m_arg2(arg2) {}
25 
26  // initialize the depending modules
27  void init(const Data& data) override {
28  m_arg1->init(data);
29  m_arg2->init(data);
30  }
31 
32  protected:
33  std::unique_ptr<Evaluator> m_arg1;
34  std::unique_ptr<Evaluator> m_arg2;
35  };
36 
37  // concrete operators
38 
39  class OperatorNot : public UnaryOperator {
40  public:
42 
43  bool operator()(const Data& data) const override { return not(*m_arg)(data); }
44 
45  void dump(std::ostream& out) const override {
46  out << "NOT ";
47  m_arg->dump(out);
48  }
49  };
50 
51  class OperatorAnd : public BinaryOperator {
52  public:
53  OperatorAnd(Evaluator* arg1, Evaluator* arg2) : BinaryOperator(arg1, arg2) {}
54 
55  bool operator()(const Data& data) const override {
56  // force the execution af both arguments, otherwise precalers won't work properly
57  bool r1 = (*m_arg1)(data);
58  bool r2 = (*m_arg2)(data);
59  return r1 and r2;
60  }
61 
62  void dump(std::ostream& out) const override {
63  m_arg1->dump(out);
64  out << " AND ";
65  m_arg2->dump(out);
66  }
67  };
68 
69  class OperatorOr : public BinaryOperator {
70  public:
71  OperatorOr(Evaluator* arg1, Evaluator* arg2) : BinaryOperator(arg1, arg2) {}
72 
73  bool operator()(const Data& data) const override {
74  // force the execution af both arguments, otherwise precalers won't work properly
75  bool r1 = (*m_arg1)(data);
76  bool r2 = (*m_arg2)(data);
77  return r1 or r2;
78  }
79 
80  void dump(std::ostream& out) const override {
81  m_arg1->dump(out);
82  out << " OR ";
83  m_arg2->dump(out);
84  }
85  };
86 
87  class OperatorXor : public BinaryOperator {
88  public:
89  OperatorXor(Evaluator* arg1, Evaluator* arg2) : BinaryOperator(arg1, arg2) {}
90 
91  bool operator()(const Data& data) const override {
92  // force the execution af both arguments, otherwise precalers won't work properly
93  bool r1 = (*m_arg1)(data);
94  bool r2 = (*m_arg2)(data);
95  return r1 xor r2;
96  }
97 
98  void dump(std::ostream& out) const override {
99  m_arg1->dump(out);
100  out << " XOR ";
101  m_arg2->dump(out);
102  }
103  };
104 
105 } // namespace triggerExpression
106 
107 #endif // HLTrigger_HLTfilters_TriggerExpressionOperators_h
triggerExpression::OperatorOr
Definition: TriggerExpressionOperators.h:69
triggerExpression::BinaryOperator::m_arg1
std::unique_ptr< Evaluator > m_arg1
Definition: TriggerExpressionOperators.h:33
triggerExpression::Evaluator
Definition: TriggerExpressionEvaluator.h:10
triggerExpression::OperatorAnd
Definition: TriggerExpressionOperators.h:51
triggerExpression::OperatorAnd::operator()
bool operator()(const Data &data) const override
Definition: TriggerExpressionOperators.h:55
triggerExpression::BinaryOperator::init
void init(const Data &data) override
Definition: TriggerExpressionOperators.h:27
triggerExpression::BinaryOperator::m_arg2
std::unique_ptr< Evaluator > m_arg2
Definition: TriggerExpressionOperators.h:34
triggerExpression::UnaryOperator::m_arg
std::unique_ptr< Evaluator > m_arg
Definition: TriggerExpressionOperators.h:18
triggerExpression::BinaryOperator::BinaryOperator
BinaryOperator(Evaluator *arg1, Evaluator *arg2)
Definition: TriggerExpressionOperators.h:24
triggerExpression::UnaryOperator::init
void init(const Data &data) override
Definition: TriggerExpressionOperators.h:15
triggerExpression::OperatorXor::operator()
bool operator()(const Data &data) const override
Definition: TriggerExpressionOperators.h:91
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
triggerExpression::Data
Definition: TriggerExpressionData.h:23
triggerExpression::BinaryOperator
Definition: TriggerExpressionOperators.h:22
triggerExpression::OperatorNot::operator()
bool operator()(const Data &data) const override
Definition: TriggerExpressionOperators.h:43
triggerExpression::OperatorXor
Definition: TriggerExpressionOperators.h:87
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
triggerExpression::OperatorNot::OperatorNot
OperatorNot(Evaluator *arg)
Definition: TriggerExpressionOperators.h:41
TriggerExpressionEvaluator.h
triggerExpression::OperatorXor::dump
void dump(std::ostream &out) const override
Definition: TriggerExpressionOperators.h:98
or
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
triggerExpression
Definition: TriggerExpressionConstant.h:6
triggerExpression::UnaryOperator
Definition: TriggerExpressionOperators.h:10
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::arg
A arg
Definition: Factorize.h:31
triggerExpression::OperatorNot::dump
void dump(std::ostream &out) const override
Definition: TriggerExpressionOperators.h:45
triggerExpression::OperatorAnd::OperatorAnd
OperatorAnd(Evaluator *arg1, Evaluator *arg2)
Definition: TriggerExpressionOperators.h:53
triggerExpression::UnaryOperator::UnaryOperator
UnaryOperator(Evaluator *arg)
Definition: TriggerExpressionOperators.h:12
triggerExpression::OperatorOr::dump
void dump(std::ostream &out) const override
Definition: TriggerExpressionOperators.h:80
triggerExpression::OperatorXor::OperatorXor
OperatorXor(Evaluator *arg1, Evaluator *arg2)
Definition: TriggerExpressionOperators.h:89
triggerExpression::OperatorNot
Definition: TriggerExpressionOperators.h:39
triggerExpression::OperatorOr::OperatorOr
OperatorOr(Evaluator *arg1, Evaluator *arg2)
Definition: TriggerExpressionOperators.h:71
triggerExpression::OperatorAnd::dump
void dump(std::ostream &out) const override
Definition: TriggerExpressionOperators.h:62
triggerExpression::OperatorOr::operator()
bool operator()(const Data &data) const override
Definition: TriggerExpressionOperators.h:73