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 
20 // system include files
21 #include <iostream>
22 
23 #include <string>
24 #include <vector>
25 
26 #include <boost/cstdint.hpp>
27 
28 // user include files
29 
30 // base class
31 
32 //
35 
36 // forward declarations
37 
38 // class interface
40 {
41 
42 public:
43 
48  m_verbosity(0) {}
49 
50 
53 
54 public:
55 
58  inline int condMaxNumberObjects() const {
60  }
61 
62  inline void setCondMaxNumberObjects(int condMaxNumberObjectsValue) {
63  m_condMaxNumberObjects = condMaxNumberObjectsValue;
64  }
65 
67  inline bool condLastResult() const {
68  return m_condLastResult;
69  }
70 
74  }
75 
77  virtual const bool evaluateCondition() const = 0;
78 
80  virtual std::string getNumericExpression() const {
81  if (m_condLastResult) {
82  return "1";
83  }
84  else {
85  return "0";
86  }
87  }
88 
90  inline CombinationsInCond const & getCombinationsInCond() const {
91  return m_combinationsInCond;
92  }
93 
94 
96  virtual void print(std::ostream& myCout) const;
97 
98  inline void setVerbosity(const int verbosity) {
100  }
101 
102 protected:
103 
106  return m_combinationsInCond;
107  }
108 
111  template<class Type1, class Type2> const bool checkThreshold(const Type1& threshold,
112  const Type2& value, const bool condGEqValue) const;
113 
115  template<class Type1> const bool checkBit(const Type1& mask, const unsigned int bitNumber) const;
116 
117 protected:
118 
122 
125 
128 
131 
132 };
133 
134 // define templated methods
135 
136 // check if a value is greater than a threshold or
137 // greater-or-equal depending on the value of the condGEqValue flag
138 template<class Type1, class Type2> const bool L1GtConditionEvaluation::checkThreshold(
139  const Type1& threshold, const Type2& value, const bool condGEqValue) const {
140 
141  //if (value > 0) {
142  // LogTrace("L1GlobalTrigger") << " threshold check for condGEqValue = "
143  // << condGEqValue << "\n hex: " << std::hex << "threshold = " << threshold
144  // << " value = " << value << "\n dec: " << std::dec << "threshold = " << threshold
145  // << " value = " << value << std::endl;
146  //}
147 
148  if (condGEqValue) {
149  if (value >= threshold) {
150 
151  //LogTrace("L1GlobalTrigger") << " condGEqValue: value >= threshold"
152  // << std::endl;
153 
154  return true;
155  }
156 
157  return false;
158 
159  }
160  else {
161 
162  if (value == threshold) {
163 
164  //LogTrace("L1GlobalTrigger") << " condGEqValue: value = threshold"
165  // << std::endl;
166 
167  return true;
168  }
169 
170  return false;
171  }
172 }
173 
174 // check if a bit with a given number is set in a mask
175 template<class Type1> const bool L1GtConditionEvaluation::checkBit(const Type1& mask,
176  const unsigned int bitNumber) const {
177 
178  boost::uint64_t oneBit = 1ULL;
179 
180  if (bitNumber >= (sizeof(oneBit)*8)) {
181 
182  if (m_verbosity) {
183 
184  LogTrace("L1GlobalTrigger")
185  << " checkBit " << "\n Bit number = "
186  << bitNumber << " larger than maximum allowed " << sizeof ( oneBit ) * 8
187  << std::endl;
188  }
189 
190  return false;
191  }
192 
193  oneBit <<= bitNumber;
194 
195  //LogTrace("L1GlobalTrigger") << " checkBit " << "\n mask address = " << &mask
196  // << std::dec << "\n dec: " << "mask = " << mask << " oneBit = " << oneBit
197  // << " bitNumber = " << bitNumber << std::hex << "\n hex: " << "mask = " << mask
198  // << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
199  // << "\n mask & oneBit result = " << bool ( mask & oneBit ) << std::endl;
200 
201  return (mask & oneBit);
202 }
203 
204 #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
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