CMS 3D CMS Logo

L1GctHfLutSetup.cc

Go to the documentation of this file.
00001 
00002 #include "CondFormats/L1TObjects/interface/L1GctHfLutSetup.h"
00003 
00004 L1GctHfLutSetup::L1GctHfLutSetup() :
00005   m_thresholds()
00006 {
00007 }
00008 
00009 L1GctHfLutSetup::~L1GctHfLutSetup() {}
00010 
00011 void L1GctHfLutSetup::setThresholds(const hfLutType type, const std::vector<unsigned> thr)
00012 {
00013   // Set thresholds for a particular Lut type.
00014   // Thresholds should (of course) be ordered - but no check is performed.
00015   // The number of thresholds is one fewer than the number of possible
00016   // output codes (e.g. 3 bits -> 7 thresholds)
00017   m_thresholds[type].resize(kHfOutputMaxValue);
00018   for (unsigned i=0; i<kHfOutputMaxValue; ++i) {
00019     if (i<thr.size()) {
00020       m_thresholds[type].at(i) = static_cast<uint16_t>(thr.at(i));
00021     } else {
00022       m_thresholds[type].at(i) = kHfEtSumMaxValue;
00023     }
00024   }
00025 }
00026 
00027 std::vector<unsigned> L1GctHfLutSetup::getThresholds(const hfLutType type) const
00028 {
00029   std::vector<unsigned> result;
00030   std::map<hfLutType, std::vector<uint16_t> >::const_iterator thrList = m_thresholds.find(type);
00031   if (thrList != m_thresholds.end()) {
00032     for (std::vector<uint16_t>::const_iterator thr = thrList->second.begin();
00033          thr != thrList->second.end(); thr++) {
00034       result.push_back(static_cast<unsigned>(*thr));
00035     }
00036   }
00037   return result;
00038 }
00039 
00040 uint16_t L1GctHfLutSetup::outputValue(const hfLutType type, const uint16_t inputValue) const
00041 {
00042   // Calculate Lut contents by comparison against a set of thresholds.
00043   // Check that the Lut type requested has actually been setup - otherwise
00044   // we return the max possible output value
00045   uint16_t result = kHfOutputMaxValue;
00046   std::map<hfLutType, std::vector<uint16_t> >::const_iterator thrList = m_thresholds.find(type);
00047   if (thrList != m_thresholds.end()) {
00048     for (unsigned i=0; i<kHfOutputMaxValue; ++i) {
00049       if (inputValue < (thrList->second).at(i)) {
00050         result = i;
00051         break;
00052       }
00053     }
00054   }
00055   return result;
00056 }

Generated on Tue Jun 9 17:26:38 2009 for CMSSW by  doxygen 1.5.4