CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/L1TriggerConfig/L1GtConfigProducers/src/L1GtTriggerMaskAlgoTrigConfigOnlineProd.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtTriggerMaskAlgoTrigConfigOnlineProd.h"
00019 
00020 // system include files
00021 #include <vector>
00022 
00023 #include "boost/lexical_cast.hpp"
00024 
00025 // user include files
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027 
00028 // constructor
00029 L1GtTriggerMaskAlgoTrigConfigOnlineProd::L1GtTriggerMaskAlgoTrigConfigOnlineProd(
00030         const edm::ParameterSet& parSet) :
00031     L1ConfigOnlineProdBase<L1GtTriggerMaskAlgoTrigRcd, L1GtTriggerMask> (parSet),
00032             m_partitionNumber(parSet.getParameter<int> ("PartitionNumber")) {
00033 
00034     // empty
00035 
00036 }
00037 
00038 // destructor
00039 L1GtTriggerMaskAlgoTrigConfigOnlineProd::~L1GtTriggerMaskAlgoTrigConfigOnlineProd() {
00040 
00041     // empty
00042 
00043 }
00044 
00045 // public methods
00046 
00047 boost::shared_ptr<L1GtTriggerMask> L1GtTriggerMaskAlgoTrigConfigOnlineProd::newObject(
00048         const std::string& objectKey) {
00049 
00050     // shared pointer for L1GtTriggerMask
00051     boost::shared_ptr<L1GtTriggerMask> pL1GtTriggerMask = boost::shared_ptr<L1GtTriggerMask>(
00052             new L1GtTriggerMask());
00053 
00054     // l1GtTriggerMaskAlgoTrig: FINOR_ALGO_FK key in GT_PARTITION_FINOR_ALGO
00055 
00056     const std::string gtSchema = "CMS_GT";
00057 
00058     // SQL query:
00059     // select * from CMS_GT.GT_PARTITION_FINOR_ALGO WHERE GT_PARTITION_FINOR_ALGO.ID = objectKey
00060 
00061     const std::vector<std::string>& columns = m_omdsReader.columnNames(
00062             gtSchema, "GT_PARTITION_FINOR_ALGO");
00063 
00064     if (edm::isDebugEnabled()) {
00065         for (std::vector<std::string>::const_iterator iter = columns.begin(); iter != columns.end(); iter++) {
00066             LogTrace("L1GtTriggerMaskAlgoTrigConfigOnlineProd") << ( *iter ) << std::endl;
00067 
00068         }
00069     }
00070 
00071     l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(
00072             columns, gtSchema, "GT_PARTITION_FINOR_ALGO", "GT_PARTITION_FINOR_ALGO.ID",
00073             m_omdsReader.singleAttribute(objectKey));
00074 
00075     // check if query was successful
00076     if (results.queryFailed()) {
00077         edm::LogError("L1-O2O") << "Problem with L1GtTriggerMaskAlgoTrigRcd key:" << objectKey;
00078         return pL1GtTriggerMask;
00079     }
00080 
00081     // mask for other partitions than m_partitionNumber set to 1 (algorithm masked)
00082     int maskSize = columns.size() - 1; // table ID is also in columns
00083     std::vector<bool> trigMaskBool(maskSize, false);
00084     std::vector<unsigned int> trigMask(maskSize, 0);
00085 
00086     for (int i = 0; i < maskSize; i++) {
00087         bool tMask = trigMaskBool[i];
00088         results.fillVariable(columns[i + 1], tMask);
00089         trigMask[i] = 0xFF & (~( static_cast<unsigned int> (tMask) << m_partitionNumber ));
00090     }
00091 
00092     // fill the record
00093     pL1GtTriggerMask->setGtTriggerMask(trigMask);
00094 
00095     if (edm::isDebugEnabled()) {
00096         std::ostringstream myCoutStream;
00097         pL1GtTriggerMask->print(myCoutStream);
00098         LogTrace("L1GtTriggerMaskAlgoTrigConfigOnlineProd")
00099                 << "\nThe following L1GtTriggerMaskAlgoTrigRcd record was read from OMDS: \n"
00100                 << myCoutStream.str() << "\n" << std::endl;
00101     }
00102 
00103     return pL1GtTriggerMask;
00104 }
00105 
00106 DEFINE_FWK_EVENTSETUP_MODULE( L1GtTriggerMaskAlgoTrigConfigOnlineProd);