CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtTriggerMaskTechTrigConfigOnlineProd.h"
00019 
00020 // system include files
00021 #include <vector>
00022 #include "boost/lexical_cast.hpp"
00023 
00024 // user include files
00025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00026 
00027 // constructor
00028 L1GtTriggerMaskTechTrigConfigOnlineProd::L1GtTriggerMaskTechTrigConfigOnlineProd(
00029         const edm::ParameterSet& parSet) :
00030     L1ConfigOnlineProdBase<L1GtTriggerMaskTechTrigRcd, L1GtTriggerMask> (parSet),
00031             m_partitionNumber(parSet.getParameter<int> ("PartitionNumber")) {
00032 
00033     // empty
00034 
00035 }
00036 
00037 // destructor
00038 L1GtTriggerMaskTechTrigConfigOnlineProd::~L1GtTriggerMaskTechTrigConfigOnlineProd() {
00039 
00040     // empty
00041 
00042 }
00043 
00044 // public methods
00045 
00046 boost::shared_ptr<L1GtTriggerMask> L1GtTriggerMaskTechTrigConfigOnlineProd::newObject(
00047         const std::string& objectKey) {
00048 
00049     // shared pointer for L1GtTriggerMask
00050     boost::shared_ptr<L1GtTriggerMask> pL1GtTriggerMask = boost::shared_ptr<L1GtTriggerMask>(
00051             new L1GtTriggerMask());
00052 
00053     // l1GtTriggerMaskTechTrig: FINOR_TT_FK key in GT_PARTITION_FINOR_TT
00054 
00055     const std::string gtSchema = "CMS_GT";
00056 
00057     // SQL query:
00058     //
00059     // select * from CMS_GT.GT_PARTITION_FINOR_TT WHERE GT_PARTITION_FINOR_TT.ID = objectKey
00060 
00061     const std::vector<std::string>& columns = m_omdsReader.columnNames(
00062             gtSchema, "GT_PARTITION_FINOR_TT");
00063 
00064     if (edm::isDebugEnabled()) {
00065         for (std::vector<std::string>::const_iterator iter = columns.begin(); iter != columns.end(); iter++) {
00066             LogTrace("L1GtTriggerMaskTechTrigConfigOnlineProd") << ( *iter ) << std::endl;
00067 
00068         }
00069     }
00070 
00071     l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(
00072             columns, gtSchema, "GT_PARTITION_FINOR_TT", "GT_PARTITION_FINOR_TT.ID",
00073             m_omdsReader.singleAttribute(objectKey));
00074 
00075     // check if query was successful
00076     if (results.queryFailed()) {
00077         edm::LogError("L1-O2O") << "Problem with L1GtTriggerMaskTechTrigRcd 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("L1GtTriggerMaskTechTrigConfigOnlineProd")
00099                 << "\nThe following L1GtTriggerMaskTechTrigRcd record was read from OMDS: \n"
00100                 << myCoutStream.str() << "\n" << std::endl;
00101     }
00102 
00103     return pL1GtTriggerMask;
00104 }
00105 
00106 DEFINE_FWK_EVENTSETUP_MODULE( L1GtTriggerMaskTechTrigConfigOnlineProd);