CMS 3D CMS Logo

L1GtConditionEvaluation.h
Go to the documentation of this file.
1 #ifndef GlobalTrigger_L1GtConditionEvaluation_h
2 #define GlobalTrigger_L1GtConditionEvaluation_h
3 
19 // system include files
20 #include <iostream>
21 
22 #include <string>
23 #include <vector>
24 
25 #include <boost/cstdint.hpp>
26 
27 // user include files
28 
29 // base class
30 
31 //
34 
35 // forward declarations
36 
37 // class interface
39 
40 public:
44 
47 
48 public:
51  inline int condMaxNumberObjects() const { return m_condMaxNumberObjects; }
52 
53  inline void setCondMaxNumberObjects(int condMaxNumberObjectsValue) {
54  m_condMaxNumberObjects = condMaxNumberObjectsValue;
55  }
56 
58  inline bool condLastResult() const { return m_condLastResult; }
59 
63  }
64 
66  virtual const bool evaluateCondition() const = 0;
67 
70  if (m_condLastResult) {
71  return "1";
72  } else {
73  return "0";
74  }
75  }
76 
78  inline CombinationsInCond const &getCombinationsInCond() const {
79  return m_combinationsInCond;
80  }
81 
83  virtual void print(std::ostream &myCout) const;
84 
85  inline void setVerbosity(const int verbosity) { m_verbosity = verbosity; }
86 
87 protected:
90  return m_combinationsInCond;
91  }
92 
95  template <class Type1, class Type2>
96  const bool checkThreshold(const Type1 &threshold, const Type2 &value,
97  const bool condGEqValue) const;
98 
100  template <class Type1>
101  const bool checkBit(const Type1 &mask, const unsigned int bitNumber) const;
102 
103 protected:
107 
110 
113 
116 };
117 
118 // define templated methods
119 
120 // check if a value is greater than a threshold or
121 // greater-or-equal depending on the value of the condGEqValue flag
122 template <class Type1, class Type2>
124  const Type1 &threshold, const Type2 &value, const bool condGEqValue) const {
125 
126  // if (value > 0) {
127  // LogTrace("L1GlobalTrigger") << " threshold check for condGEqValue = "
128  // << condGEqValue << "\n hex: " << std::hex << "threshold = " <<
129  // threshold
130  // << " value = " << value << "\n dec: " << std::dec << "threshold =
131  // " << threshold
132  // << " value = " << value << std::endl;
133  //}
134 
135  if (condGEqValue) {
136  if (value >= threshold) {
137 
138  // LogTrace("L1GlobalTrigger") << " condGEqValue: value >= threshold"
139  // << std::endl;
140 
141  return true;
142  }
143 
144  return false;
145 
146  } else {
147 
148  if (value == threshold) {
149 
150  // LogTrace("L1GlobalTrigger") << " condGEqValue: value = threshold"
151  // << std::endl;
152 
153  return true;
154  }
155 
156  return false;
157  }
158 }
159 
160 // check if a bit with a given number is set in a mask
161 template <class Type1>
162 const bool
164  const unsigned int bitNumber) const {
165 
166  boost::uint64_t oneBit = 1ULL;
167 
168  if (bitNumber >= (sizeof(oneBit) * 8)) {
169 
170  if (m_verbosity) {
171 
172  LogTrace("L1GlobalTrigger")
173  << " checkBit "
174  << "\n Bit number = " << bitNumber
175  << " larger than maximum allowed " << sizeof(oneBit) * 8 << std::endl;
176  }
177 
178  return false;
179  }
180 
181  oneBit <<= bitNumber;
182 
183  // LogTrace("L1GlobalTrigger") << " checkBit " << "\n mask address = "
184  // << &mask
185  // << std::dec << "\n dec: " << "mask = " << mask << " oneBit = " <<
186  // oneBit
187  // << " bitNumber = " << bitNumber << std::hex << "\n hex: " << "mask =
188  // " << mask
189  // << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
190  // << "\n mask & oneBit result = " << bool ( mask & oneBit ) <<
191  // std::endl;
192 
193  return (mask & oneBit);
194 }
195 
196 #endif
void setCondMaxNumberObjects(int condMaxNumberObjectsValue)
const bool checkBit(const Type1 &mask, const unsigned int bitNumber) const
check if a bit with a given number is set in a mask
bool m_condLastResult
the last result of evaluateCondition()
CombinationsInCond m_combinationsInCond
store all the object combinations evaluated to true in the condition
void setVerbosity(const int verbosity)
CombinationsInCond & combinationsInCond() const
get all the object combinations (to fill it...)
void evaluateConditionStoreResult()
call evaluateCondition and save last result
const bool checkThreshold(const Type1 &threshold, const Type2 &value, const bool condGEqValue) const
Definition: value.py:1
virtual std::string getNumericExpression() const
get numeric expression
#define LogTrace(id)
virtual ~L1GtConditionEvaluation()
destructor
virtual const bool evaluateCondition() const =0
the core function to check if the condition matches
unsigned long long uint64_t
Definition: Time.h:15
virtual void print(std::ostream &myCout) const
print condition
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
CombinationsInCond const & getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
bool condLastResult() const
get the latest result for the condition