CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GtConditionEvaluation.h
Go to the documentation of this file.
1 #ifndef GlobalTrigger_L1GtConditionEvaluation_h
2 #define GlobalTrigger_L1GtConditionEvaluation_h
3 
18 // system include files
19 #include <iostream>
20 
21 #include <string>
22 #include <vector>
23 
24 #include <boost/cstdint.hpp>
25 
26 // user include files
27 
28 // base class
29 
30 //
33 
34 // forward declarations
35 
36 // class interface
38 {
39 
40 public:
41 
46  m_verbosity(0) {}
47 
48 
51 
52 public:
53 
56  inline int condMaxNumberObjects() const {
58  }
59 
60  inline void setCondMaxNumberObjects(int condMaxNumberObjectsValue) {
61  m_condMaxNumberObjects = condMaxNumberObjectsValue;
62  }
63 
65  inline bool condLastResult() const {
66  return m_condLastResult;
67  }
68 
72  }
73 
75  virtual const bool evaluateCondition() const = 0;
76 
79  if (m_condLastResult) {
80  return "1";
81  }
82  else {
83  return "0";
84  }
85  }
86 
88  inline CombinationsInCond const & getCombinationsInCond() const {
89  return m_combinationsInCond;
90  }
91 
92 
94  virtual void print(std::ostream& myCout) const;
95 
96  inline void setVerbosity(const int verbosity) {
98  }
99 
100 protected:
101 
104  return m_combinationsInCond;
105  }
106 
109  template<class Type1, class Type2> const bool checkThreshold(const Type1& threshold,
110  const Type2& value, const bool condGEqValue) const;
111 
113  template<class Type1> const bool checkBit(const Type1& mask, const unsigned int bitNumber) const;
114 
115 protected:
116 
120 
123 
126 
129 
130 };
131 
132 // define templated methods
133 
134 // check if a value is greater than a threshold or
135 // greater-or-equal depending on the value of the condGEqValue flag
136 template<class Type1, class Type2> const bool L1GtConditionEvaluation::checkThreshold(
137  const Type1& threshold, const Type2& value, const bool condGEqValue) const {
138 
139  //if (value > 0) {
140  // LogTrace("L1GlobalTrigger") << " threshold check for condGEqValue = "
141  // << condGEqValue << "\n hex: " << std::hex << "threshold = " << threshold
142  // << " value = " << value << "\n dec: " << std::dec << "threshold = " << threshold
143  // << " value = " << value << std::endl;
144  //}
145 
146  if (condGEqValue) {
147  if (value >= threshold) {
148 
149  //LogTrace("L1GlobalTrigger") << " condGEqValue: value >= threshold"
150  // << std::endl;
151 
152  return true;
153  }
154 
155  return false;
156 
157  }
158  else {
159 
160  if (value == threshold) {
161 
162  //LogTrace("L1GlobalTrigger") << " condGEqValue: value = threshold"
163  // << std::endl;
164 
165  return true;
166  }
167 
168  return false;
169  }
170 }
171 
172 // check if a bit with a given number is set in a mask
173 template<class Type1> const bool L1GtConditionEvaluation::checkBit(const Type1& mask,
174  const unsigned int bitNumber) const {
175 
176  boost::uint64_t oneBit = 1ULL;
177 
178  if (bitNumber >= (sizeof(oneBit)*8)) {
179 
180  if (m_verbosity) {
181 
182  LogTrace("L1GlobalTrigger")
183  << " checkBit " << "\n Bit number = "
184  << bitNumber << " larger than maximum allowed " << sizeof ( oneBit ) * 8
185  << std::endl;
186  }
187 
188  return false;
189  }
190 
191  oneBit <<= bitNumber;
192 
193  //LogTrace("L1GlobalTrigger") << " checkBit " << "\n mask address = " << &mask
194  // << std::dec << "\n dec: " << "mask = " << mask << " oneBit = " << oneBit
195  // << " bitNumber = " << bitNumber << std::hex << "\n hex: " << "mask = " << mask
196  // << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
197  // << "\n mask & oneBit result = " << bool ( mask & oneBit ) << std::endl;
198 
199  return (mask & oneBit);
200 }
201 
202 #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()
virtual const bool evaluateCondition() const =0
the core function to check if the condition matches
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
virtual std::string getNumericExpression() const
get numeric expression
#define LogTrace(id)
virtual ~L1GtConditionEvaluation()
destructor
unsigned long long uint64_t
Definition: Time.h:15
virtual void print(std::ostream &myCout) const
print condition
volatile std::atomic< bool > shutdown_flag false
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