Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:13

0001 //-------------------------------------------------
0002 //
0003 //   \class L1MuGMTParametersOnlineProd
0004 //
0005 //   Description:      A key producer to deduce the GMT LUT keys from the master
0006 //                     GMT configuration  key, closely following the example of
0007 //
0008 //   https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideL1ConfigOnlineProd r11
0009 //
0010 //
0011 //   Author :
0012 //   Thomas Themel
0013 //
0014 //--------------------------------------------------
0015 
0016 #include "CondTools/L1Trigger/interface/L1ObjectKeysOnlineProdBase.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 
0019 class L1MuTriggerScaleKeysOnlineProd : public L1ObjectKeysOnlineProdBase {
0020 public:
0021   L1MuTriggerScaleKeysOnlineProd(const edm::ParameterSet& iConfig)
0022       : L1ObjectKeysOnlineProdBase(iConfig),
0023         m_objectTypes(iConfig.getParameter<std::vector<std::string> >("objectTypes")),
0024         m_recordTypes(iConfig.getParameter<std::vector<std::string> >("recordTypes")) {
0025     if (m_objectTypes.size() != m_recordTypes.size()) {
0026       throw cond::Exception("mismatch: need equal number objectType and recordType entries!");
0027     }
0028   }
0029 
0030   ~L1MuTriggerScaleKeysOnlineProd() override {}
0031 
0032   void fillObjectKeys(FillType pL1TriggerKey) override;
0033 
0034 private:
0035   std::vector<std::string> m_objectTypes;
0036   std::vector<std::string> m_recordTypes;
0037 };
0038 
0039 void L1MuTriggerScaleKeysOnlineProd::fillObjectKeys(FillType pL1TriggerKey) {
0040   std::string subsystemKey = pL1TriggerKey->subsystemKey(L1TriggerKey::kGMT);
0041 
0042   if (!subsystemKey.empty()) {
0043     // Lookup GT scales key from GMT main config key
0044     l1t::OMDSReader::QueryResults scalesKeyResults = m_omdsReader.basicQuery(
0045         // SELECTed column
0046         "SCALES_KEY",
0047         // schema name
0048         "CMS_GMT",
0049         // table name
0050         "GMT_CONFIG",
0051         // WHERE lhs
0052         "GMT_CONFIG.KEY",
0053         // WHERE rhs
0054         m_omdsReader.singleAttribute(subsystemKey));
0055 
0056     if (scalesKeyResults.numberRows() != 1)  // check if query was successful
0057     {
0058       edm::LogError("L1-O2O") << "Problem extracting GMT scales key from GMT config key.";
0059       return;
0060     }
0061 
0062     std::string objectKey;
0063     scalesKeyResults.fillVariable(objectKey);
0064 
0065     edm::LogError("L1-O2O") << "Registering " << m_recordTypes.size() << " keys ";
0066     // register the scales key for all the scales types we need to produce
0067     for (unsigned i = 0; i < m_recordTypes.size(); ++i) {
0068       edm::LogError("L1-O2O") << "Registering scales key " << objectKey << " for " << m_recordTypes[i];
0069       pL1TriggerKey->add(m_recordTypes[i], m_objectTypes[i], objectKey);
0070     }
0071   }
0072 }
0073 
0074 DEFINE_FWK_EVENTSETUP_MODULE(L1MuTriggerScaleKeysOnlineProd);