CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 // user include files
26 
27 // base class
28 
29 //
32 #include <cstdint>
33 
34 // forward declarations
35 
36 // class interface
38 public:
41 
44 
45 public:
48  inline int condMaxNumberObjects() const { return m_condMaxNumberObjects; }
49 
50  inline void setCondMaxNumberObjects(int condMaxNumberObjectsValue) {
51  m_condMaxNumberObjects = condMaxNumberObjectsValue;
52  }
53 
55  inline bool condLastResult() const { return m_condLastResult; }
56 
59 
61  virtual const bool evaluateCondition() const = 0;
62 
65  if (m_condLastResult) {
66  return "1";
67  } else {
68  return "0";
69  }
70  }
71 
74 
76  virtual void print(std::ostream &myCout) const;
77 
78  inline void setVerbosity(const int verbosity) { m_verbosity = verbosity; }
79 
80 protected:
83 
86  template <class Type1, class Type2>
87  const bool checkThreshold(const Type1 &threshold, const Type2 &value, const bool condGEqValue) const;
88 
90  template <class Type1>
91  const bool checkBit(const Type1 &mask, const unsigned int bitNumber) const;
92 
93 protected:
97 
100 
103 
106 };
107 
108 // define templated methods
109 
110 // check if a value is greater than a threshold or
111 // greater-or-equal depending on the value of the condGEqValue flag
112 template <class Type1, class Type2>
114  const Type2 &value,
115  const bool condGEqValue) const {
116  // if (value > 0) {
117  // LogTrace("L1GlobalTrigger") << " threshold check for condGEqValue = "
118  // << condGEqValue << "\n hex: " << std::hex << "threshold = " <<
119  // threshold
120  // << " value = " << value << "\n dec: " << std::dec << "threshold =
121  // " << threshold
122  // << " value = " << value << std::endl;
123  //}
124 
125  if (condGEqValue) {
126  if (value >= threshold) {
127  // LogTrace("L1GlobalTrigger") << " condGEqValue: value >= threshold"
128  // << std::endl;
129 
130  return true;
131  }
132 
133  return false;
134 
135  } else {
136  if (value == threshold) {
137  // LogTrace("L1GlobalTrigger") << " condGEqValue: value = threshold"
138  // << std::endl;
139 
140  return true;
141  }
142 
143  return false;
144  }
145 }
146 
147 // check if a bit with a given number is set in a mask
148 template <class Type1>
149 const bool L1GtConditionEvaluation::checkBit(const Type1 &mask, const unsigned int bitNumber) const {
150  uint64_t oneBit = 1ULL;
151 
152  if (bitNumber >= (sizeof(oneBit) * 8)) {
153  if (m_verbosity) {
154  LogTrace("L1GlobalTrigger") << " checkBit "
155  << "\n Bit number = " << bitNumber << " larger than maximum allowed "
156  << sizeof(oneBit) * 8 << std::endl;
157  }
158 
159  return false;
160  }
161 
162  oneBit <<= bitNumber;
163 
164  // LogTrace("L1GlobalTrigger") << " checkBit " << "\n mask address = "
165  // << &mask
166  // << std::dec << "\n dec: " << "mask = " << mask << " oneBit = " <<
167  // oneBit
168  // << " bitNumber = " << bitNumber << std::hex << "\n hex: " << "mask =
169  // " << mask
170  // << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
171  // << "\n mask & oneBit result = " << bool ( mask & oneBit ) <<
172  // std::endl;
173 
174  return (mask & oneBit);
175 }
176 
177 #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...)
#define LogTrace(id)
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
virtual ~L1GtConditionEvaluation()
destructor
unsigned long long uint64_t
Definition: Time.h:13
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