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 // 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
L1GtConditionEvaluation
Definition: L1GtConditionEvaluation.h:37
HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
L1GtConditionEvaluation::m_verbosity
int m_verbosity
verbosity level
Definition: L1GtConditionEvaluation.h:105
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
L1GtConditionEvaluation::combinationsInCond
CombinationsInCond & combinationsInCond() const
get all the object combinations (to fill it...)
Definition: L1GtConditionEvaluation.h:82
L1GtConditionEvaluation::checkBit
const bool checkBit(const Type1 &mask, const unsigned int bitNumber) const
check if a bit with a given number is set in a mask
Definition: L1GtConditionEvaluation.h:149
L1GtConditionEvaluation::setCondMaxNumberObjects
void setCondMaxNumberObjects(int condMaxNumberObjectsValue)
Definition: L1GtConditionEvaluation.h:50
L1GtConditionEvaluation::print
virtual void print(std::ostream &myCout) const
print condition
Definition: L1GtConditionEvaluation.cc:34
L1GtConditionEvaluation::m_combinationsInCond
CombinationsInCond m_combinationsInCond
store all the object combinations evaluated to true in the condition
Definition: L1GtConditionEvaluation.h:102
CombinationsInCond
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
Definition: L1GlobalTriggerObjectMapFwd.h:32
L1GtConditionEvaluation::checkThreshold
const bool checkThreshold(const Type1 &threshold, const Type2 &value, const bool condGEqValue) const
Definition: L1GtConditionEvaluation.h:113
L1GtConditionEvaluation::m_condLastResult
bool m_condLastResult
the last result of evaluateCondition()
Definition: L1GtConditionEvaluation.h:99
L1GtConditionEvaluation::condMaxNumberObjects
int condMaxNumberObjects() const
Definition: L1GtConditionEvaluation.h:48
L1GtConditionEvaluation::setVerbosity
void setVerbosity(const int verbosity)
Definition: L1GtConditionEvaluation.h:78
L1GtConditionEvaluation::getNumericExpression
virtual std::string getNumericExpression() const
get numeric expression
Definition: L1GtConditionEvaluation.h:64
L1GtConditionEvaluation::evaluateConditionStoreResult
void evaluateConditionStoreResult()
call evaluateCondition and save last result
Definition: L1GtConditionEvaluation.h:58
L1GtConditionEvaluation::L1GtConditionEvaluation
L1GtConditionEvaluation()
constructor
Definition: L1GtConditionEvaluation.h:40
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1GtConditionEvaluation::m_condMaxNumberObjects
int m_condMaxNumberObjects
Definition: L1GtConditionEvaluation.h:96
L1GtConditionEvaluation::getCombinationsInCond
const CombinationsInCond & getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
Definition: L1GtConditionEvaluation.h:73
value
Definition: value.py:1
L1GtConditionEvaluation::condLastResult
bool condLastResult() const
get the latest result for the condition
Definition: L1GtConditionEvaluation.h:55
L1GtConditionEvaluation::~L1GtConditionEvaluation
virtual ~L1GtConditionEvaluation()
destructor
Definition: L1GtConditionEvaluation.h:43
L1GlobalTriggerObjectMapFwd.h
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
L1TBPTX_cfi.bitNumber
bitNumber
Definition: L1TBPTX_cfi.py:26
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:426
L1GtConditionEvaluation::evaluateCondition
virtual const bool evaluateCondition() const =0
the core function to check if the condition matches