CMS 3D CMS Logo

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 protected:
00097 
00100     template<class Type1, class Type2> const bool checkThreshold(const Type1& threshold,
00101         const Type2& value, const bool condGEqValue) const;
00102 
00104     template<class Type1> const bool checkBit(const Type1& mask, const unsigned int bitNumber) const;
00105 
00106 protected:
00107 
00110     int m_condMaxNumberObjects;
00111 
00113     bool m_condLastResult;
00114 
00116     CombinationsInCond* m_combinationsInCond;
00117 
00118 };
00119 
00120 // define templated methods
00121 
00122 // check if a value is greater than a threshold or
00123 // greater-or-equal depending on the value of the condGEqValue flag
00124 template<class Type1, class Type2> const bool L1GtConditionEvaluation::checkThreshold(
00125     const Type1& threshold, const Type2& value, const bool condGEqValue) const {
00126 
00127     //if (value > 0) {
00128     //    LogTrace("L1GtConditionEvaluation") << "  threshold check for condGEqValue = "
00129     //        << condGEqValue << "\n    hex: " << std::hex << "threshold = " << threshold
00130     //        << " value = " << value << "\n    dec: " << std::dec << "threshold = " << threshold
00131     //        << " value = " << value << std::endl;
00132     //}
00133 
00134     if (condGEqValue) {
00135         if (value >= threshold) {
00136 
00137             //LogTrace("L1GtConditionEvaluation") << "    condGEqValue: value >= threshold"
00138             //    << std::endl;
00139 
00140             return true;
00141         }
00142 
00143         return false;
00144 
00145     }
00146     else {
00147 
00148         if (value == threshold) {
00149 
00150             //LogTrace("L1GtConditionEvaluation") << "    condGEqValue: value = threshold"
00151             //    << std::endl;
00152 
00153             return true;
00154         }
00155 
00156         return false;
00157     }
00158 }
00159 
00160 // check if a bit with a given number is set in a mask
00161 template<class Type1> const bool L1GtConditionEvaluation::checkBit(const Type1& mask,
00162     const unsigned int bitNumber) const {
00163 
00164     boost::uint64_t oneBit = 1ULL;
00165 
00166     if (bitNumber >= (sizeof(oneBit)*8)) {
00167 
00168         LogTrace("L1GtConditionEvaluation") << "    checkBit " << "\n     Bit number = "
00169             << bitNumber << " larger than maximum allowed " << sizeof(oneBit)*8 << std::endl;
00170 
00171         return false;
00172     }
00173 
00174     oneBit <<= bitNumber;
00175 
00176     //LogTrace("L1GtConditionEvaluation") << "    checkBit " << "\n     mask address = " << &mask
00177     //    << std::dec << "\n     dec: " << "mask = " << mask << " oneBit = " << oneBit
00178     //    << " bitNumber = " << bitNumber << std::hex << "\n     hex: " << "mask = " << mask
00179     //    << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
00180     //    << "\n     mask & oneBit result = " << bool ( mask & oneBit ) << std::endl;
00181 
00182     return (mask & oneBit);
00183 }
00184 
00185 #endif

Generated on Tue Jun 9 17:40:13 2009 for CMSSW by  doxygen 1.5.4