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 
46 
49 
51  virtual ~L1GtConditionEvaluation();
52 
53 public:
54 
57  inline int condMaxNumberObjects() const {
59  }
60 
61  inline void setCondMaxNumberObjects(int condMaxNumberObjectsValue) {
62  m_condMaxNumberObjects = condMaxNumberObjectsValue;
63  }
64 
66  inline bool condLastResult() const {
67  return m_condLastResult;
68  }
69 
73  }
74 
76  virtual const bool evaluateCondition() const = 0;
77 
79  virtual std::string getNumericExpression() {
80  if (m_condLastResult) {
81  return "1";
82  }
83  else {
84  return "0";
85  }
86  }
87 
90  return m_combinationsInCond;
91  }
92 
94  virtual void print(std::ostream& myCout) const;
95 
96  inline void setVerbosity(const int verbosity) {
98  }
99 
100 protected:
101 
104  template<class Type1, class Type2> const bool checkThreshold(const Type1& threshold,
105  const Type2& value, const bool condGEqValue) const;
106 
108  template<class Type1> const bool checkBit(const Type1& mask, const unsigned int bitNumber) const;
109 
110 protected:
111 
115 
118 
121 
124 
125 };
126 
127 // define templated methods
128 
129 // check if a value is greater than a threshold or
130 // greater-or-equal depending on the value of the condGEqValue flag
131 template<class Type1, class Type2> const bool L1GtConditionEvaluation::checkThreshold(
132  const Type1& threshold, const Type2& value, const bool condGEqValue) const {
133 
134  //if (value > 0) {
135  // LogTrace("L1GtConditionEvaluation") << " threshold check for condGEqValue = "
136  // << condGEqValue << "\n hex: " << std::hex << "threshold = " << threshold
137  // << " value = " << value << "\n dec: " << std::dec << "threshold = " << threshold
138  // << " value = " << value << std::endl;
139  //}
140 
141  if (condGEqValue) {
142  if (value >= threshold) {
143 
144  //LogTrace("L1GtConditionEvaluation") << " condGEqValue: value >= threshold"
145  // << std::endl;
146 
147  return true;
148  }
149 
150  return false;
151 
152  }
153  else {
154 
155  if (value == threshold) {
156 
157  //LogTrace("L1GtConditionEvaluation") << " condGEqValue: value = threshold"
158  // << std::endl;
159 
160  return true;
161  }
162 
163  return false;
164  }
165 }
166 
167 // check if a bit with a given number is set in a mask
168 template<class Type1> const bool L1GtConditionEvaluation::checkBit(const Type1& mask,
169  const unsigned int bitNumber) const {
170 
171  boost::uint64_t oneBit = 1ULL;
172 
173  if (bitNumber >= (sizeof(oneBit)*8)) {
174 
175  if (m_verbosity) {
176 
177  LogTrace("L1GtConditionEvaluation")
178  << " checkBit " << "\n Bit number = "
179  << bitNumber << " larger than maximum allowed " << sizeof ( oneBit ) * 8
180  << std::endl;
181  }
182 
183  return false;
184  }
185 
186  oneBit <<= bitNumber;
187 
188  //LogTrace("L1GtConditionEvaluation") << " checkBit " << "\n mask address = " << &mask
189  // << std::dec << "\n dec: " << "mask = " << mask << " oneBit = " << oneBit
190  // << " bitNumber = " << bitNumber << std::hex << "\n hex: " << "mask = " << mask
191  // << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
192  // << "\n mask & oneBit result = " << bool ( mask & oneBit ) << std::endl;
193 
194  return (mask & oneBit);
195 }
196 
197 #endif
CombinationsInCond * m_combinationsInCond
store all the object combinations evaluated to true in the condition
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
CombinationsInCond * getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
bool m_condLastResult
the last result of evaluateCondition()
virtual const bool evaluateCondition() const =0
the core function to check if the condition matches
void setVerbosity(const int verbosity)
virtual std::string getNumericExpression()
get numeric expression
void evaluateConditionStoreResult()
call evaluateCondition and save last result
float threshold
Definition: crabWrap.py:319
const bool checkThreshold(const Type1 &threshold, const Type2 &value, const bool condGEqValue) const
#define LogTrace(id)
const int verbosity
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
virtual ~L1GtConditionEvaluation()
destructor
bool condLastResult() const
get the latest result for the condition