File indexing completed on 2024-04-06 12:19:59
0001 #ifndef GlobalTrigger_L1GtConditionEvaluation_h
0002 #define GlobalTrigger_L1GtConditionEvaluation_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <iostream>
0021
0022 #include <string>
0023 #include <vector>
0024
0025
0026
0027
0028
0029
0030 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapFwd.h"
0031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0032 #include <cstdint>
0033
0034
0035
0036
0037 class L1GtConditionEvaluation {
0038 public:
0039
0040 L1GtConditionEvaluation() : m_condMaxNumberObjects(0), m_condLastResult(false), m_verbosity(0) {}
0041
0042
0043 virtual ~L1GtConditionEvaluation() {}
0044
0045 public:
0046
0047
0048 inline int condMaxNumberObjects() const { return m_condMaxNumberObjects; }
0049
0050 inline void setCondMaxNumberObjects(int condMaxNumberObjectsValue) {
0051 m_condMaxNumberObjects = condMaxNumberObjectsValue;
0052 }
0053
0054
0055 inline bool condLastResult() const { return m_condLastResult; }
0056
0057
0058 inline void evaluateConditionStoreResult() { m_condLastResult = evaluateCondition(); }
0059
0060
0061 virtual const bool evaluateCondition() const = 0;
0062
0063
0064 virtual std::string getNumericExpression() const {
0065 if (m_condLastResult) {
0066 return "1";
0067 } else {
0068 return "0";
0069 }
0070 }
0071
0072
0073 inline CombinationsInCond const &getCombinationsInCond() const { return m_combinationsInCond; }
0074
0075
0076 virtual void print(std::ostream &myCout) const;
0077
0078 inline void setVerbosity(const int verbosity) { m_verbosity = verbosity; }
0079
0080 protected:
0081
0082 inline CombinationsInCond &combinationsInCond() const { return m_combinationsInCond; }
0083
0084
0085
0086 template <class Type1, class Type2>
0087 const bool checkThreshold(const Type1 &threshold, const Type2 &value, const bool condGEqValue) const;
0088
0089
0090 template <class Type1>
0091 const bool checkBit(const Type1 &mask, const unsigned int bitNumber) const;
0092
0093 protected:
0094
0095
0096 int m_condMaxNumberObjects;
0097
0098
0099 bool m_condLastResult;
0100
0101
0102 mutable CombinationsInCond m_combinationsInCond;
0103
0104
0105 int m_verbosity;
0106 };
0107
0108
0109
0110
0111
0112 template <class Type1, class Type2>
0113 const bool L1GtConditionEvaluation::checkThreshold(const Type1 &threshold,
0114 const Type2 &value,
0115 const bool condGEqValue) const {
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125 if (condGEqValue) {
0126 if (value >= threshold) {
0127
0128
0129
0130 return true;
0131 }
0132
0133 return false;
0134
0135 } else {
0136 if (value == threshold) {
0137
0138
0139
0140 return true;
0141 }
0142
0143 return false;
0144 }
0145 }
0146
0147
0148 template <class Type1>
0149 const bool L1GtConditionEvaluation::checkBit(const Type1 &mask, const unsigned int bitNumber) const {
0150 uint64_t oneBit = 1ULL;
0151
0152 if (bitNumber >= (sizeof(oneBit) * 8)) {
0153 if (m_verbosity) {
0154 LogTrace("L1GlobalTrigger") << " checkBit "
0155 << "\n Bit number = " << bitNumber << " larger than maximum allowed "
0156 << sizeof(oneBit) * 8 << std::endl;
0157 }
0158
0159 return false;
0160 }
0161
0162 oneBit <<= bitNumber;
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174 return (mask & oneBit);
0175 }
0176
0177 #endif