CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/L1Trigger/GlobalTrigger/interface/L1GtConditionEvaluation.h

Go to the documentation of this file.
00001 #ifndef GlobalTrigger_L1GtConditionEvaluation_h
00002 #define GlobalTrigger_L1GtConditionEvaluation_h
00003 
00020 // system include files
00021 #include <iostream>
00022 
00023 #include <string>
00024 #include <vector>
00025 
00026 #include <boost/cstdint.hpp>
00027 
00028 // user include files
00029 
00030 //   base class
00031 
00032 //
00033 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapFwd.h"
00034 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00035 
00036 // forward declarations
00037 
00038 // class interface
00039 class L1GtConditionEvaluation
00040 {
00041 
00042 public:
00043 
00045     L1GtConditionEvaluation();
00046 
00048     L1GtConditionEvaluation(L1GtConditionEvaluation&);
00049 
00051     virtual ~L1GtConditionEvaluation();
00052 
00053 public:
00054 
00057     inline int condMaxNumberObjects() const {
00058         return m_condMaxNumberObjects;
00059     }
00060 
00061     inline void setCondMaxNumberObjects(int condMaxNumberObjectsValue) {
00062         m_condMaxNumberObjects = condMaxNumberObjectsValue;
00063     }
00064 
00066     inline bool condLastResult() const {
00067         return m_condLastResult;
00068     }
00069 
00071     inline void evaluateConditionStoreResult() {
00072         m_condLastResult = evaluateCondition();
00073     }
00074 
00076     virtual const bool evaluateCondition() const = 0;
00077 
00079     virtual std::string getNumericExpression() {
00080         if (m_condLastResult) {
00081             return "1";
00082         }
00083         else {
00084             return "0";
00085         }
00086     }
00087 
00089     inline CombinationsInCond* getCombinationsInCond() const {
00090         return m_combinationsInCond;
00091     }
00092 
00094     virtual void print(std::ostream& myCout) const;
00095 
00096     inline void setVerbosity(const int verbosity) {
00097         m_verbosity = verbosity;
00098     }
00099 
00100 protected:
00101 
00104     template<class Type1, class Type2> const bool checkThreshold(const Type1& threshold,
00105         const Type2& value, const bool condGEqValue) const;
00106 
00108     template<class Type1> const bool checkBit(const Type1& mask, const unsigned int bitNumber) const;
00109 
00110 protected:
00111 
00114     int m_condMaxNumberObjects;
00115 
00117     bool m_condLastResult;
00118 
00120     CombinationsInCond* m_combinationsInCond;
00121 
00123     int m_verbosity;
00124 
00125 };
00126 
00127 // define templated methods
00128 
00129 // check if a value is greater than a threshold or
00130 // greater-or-equal depending on the value of the condGEqValue flag
00131 template<class Type1, class Type2> const bool L1GtConditionEvaluation::checkThreshold(
00132     const Type1& threshold, const Type2& value, const bool condGEqValue) const {
00133 
00134     //if (value > 0) {
00135     //    LogTrace("L1GtConditionEvaluation") << "  threshold check for condGEqValue = "
00136     //        << condGEqValue << "\n    hex: " << std::hex << "threshold = " << threshold
00137     //        << " value = " << value << "\n    dec: " << std::dec << "threshold = " << threshold
00138     //        << " value = " << value << std::endl;
00139     //}
00140 
00141     if (condGEqValue) {
00142         if (value >= threshold) {
00143 
00144             //LogTrace("L1GtConditionEvaluation") << "    condGEqValue: value >= threshold"
00145             //    << std::endl;
00146 
00147             return true;
00148         }
00149 
00150         return false;
00151 
00152     }
00153     else {
00154 
00155         if (value == threshold) {
00156 
00157             //LogTrace("L1GtConditionEvaluation") << "    condGEqValue: value = threshold"
00158             //    << std::endl;
00159 
00160             return true;
00161         }
00162 
00163         return false;
00164     }
00165 }
00166 
00167 // check if a bit with a given number is set in a mask
00168 template<class Type1> const bool L1GtConditionEvaluation::checkBit(const Type1& mask,
00169     const unsigned int bitNumber) const {
00170 
00171     boost::uint64_t oneBit = 1ULL;
00172 
00173     if (bitNumber >= (sizeof(oneBit)*8)) {
00174 
00175         if (m_verbosity) {
00176 
00177             LogTrace("L1GtConditionEvaluation")
00178                 << "    checkBit " << "\n     Bit number = "
00179                 << bitNumber << " larger than maximum allowed " << sizeof ( oneBit ) * 8
00180                 << std::endl;
00181         }
00182 
00183         return false;
00184     }
00185 
00186     oneBit <<= bitNumber;
00187 
00188     //LogTrace("L1GtConditionEvaluation") << "    checkBit " << "\n     mask address = " << &mask
00189     //    << std::dec << "\n     dec: " << "mask = " << mask << " oneBit = " << oneBit
00190     //    << " bitNumber = " << bitNumber << std::hex << "\n     hex: " << "mask = " << mask
00191     //    << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
00192     //    << "\n     mask & oneBit result = " << bool ( mask & oneBit ) << std::endl;
00193 
00194     return (mask & oneBit);
00195 }
00196 
00197 #endif