Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:18

0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 
0003 #include "CondTools/L1TriggerExt/plugins/L1SubsystemKeysOnlineProdExt.h"
0004 
0005 #include "CondTools/L1Trigger/interface/Exception.h"
0006 #include "CondTools/L1TriggerExt/interface/DataWriterExt.h"
0007 
0008 #include "CondFormats/L1TObjects/interface/L1TriggerKeyListExt.h"
0009 #include "CondFormats/DataRecord/interface/L1TriggerKeyListExtRcd.h"
0010 
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 
0013 L1SubsystemKeysOnlineProdExt::L1SubsystemKeysOnlineProdExt(const edm::ParameterSet& iConfig)
0014     : m_tscKey(iConfig.getParameter<std::string>("tscKey")),
0015       m_rsKey(iConfig.getParameter<std::string>("rsKey")),
0016       m_omdsReader(iConfig.getParameter<std::string>("onlineDB"),
0017                    iConfig.getParameter<std::string>("onlineAuthentication")),
0018       m_forceGeneration(iConfig.getParameter<bool>("forceGeneration")) {
0019   //the following line is needed to tell the framework what
0020   // data is being produced
0021   setWhatProduced(this, "SubsystemKeysOnly");
0022 
0023   //now do what ever other initialization is needed
0024 }
0025 
0026 L1SubsystemKeysOnlineProdExt::~L1SubsystemKeysOnlineProdExt() {
0027   // do anything here that needs to be done at desctruction time
0028   // (e.g. close files, deallocate resources etc.)
0029 }
0030 
0031 //
0032 // member functions
0033 //
0034 
0035 // ------------ method called to produce the data  ------------
0036 L1SubsystemKeysOnlineProdExt::ReturnType L1SubsystemKeysOnlineProdExt::produce(const L1TriggerKeyExtRcd& iRecord) {
0037   std::unique_ptr<L1TriggerKeyExt> pL1TriggerKey;
0038 
0039   // Get L1TriggerKeyListExt
0040   L1TriggerKeyListExt keyList;
0041   if (!m_forceGeneration) {
0042     l1t::DataWriterExt dataWriter;
0043     if (!dataWriter.fillLastTriggerKeyList(keyList)) {
0044       edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyListExt";
0045     }
0046   }
0047   // For RUN II the subsystem CondFormats for ALGO and RS are merged together -> we join ALGO and RS keys
0048 
0049   // combine the ALGO and RS keys:
0050   std::string delimeter = ":";
0051   std::string m_Key = m_tscKey + delimeter + m_rsKey;
0052 
0053   // If L1TriggerKeyListExt does not contain TSC key, token is empty
0054   if (keyList.token(m_Key).empty() || m_forceGeneration) {
0055     // Instantiate new L1TriggerKey
0056     pL1TriggerKey = std::make_unique<L1TriggerKeyExt>();
0057 
0058     pL1TriggerKey->setTSCKey(m_Key);
0059 
0060     edm::LogVerbatim("L1-O2O") << "TSC KEY: " << m_tscKey;
0061     edm::LogVerbatim("L1-O2O") << "RS_KEY:  " << m_rsKey;
0062 
0063     // Get subsystem keys from OMDS
0064 
0065     // select * from CMS_TRG_L1_CONF.L1_TRG_CONF_KEYS where ID = m_tscKey
0066     std::vector<std::string> queryStrings;
0067     queryStrings.push_back("UGT_KEY");
0068     queryStrings.push_back("UGMT_KEY");
0069     //       queryStrings.push_back( "CALO_KEY"   ) ;
0070     queryStrings.push_back("BMTF_KEY");
0071     queryStrings.push_back("OMTF_KEY");
0072     queryStrings.push_back("EMTF_KEY");
0073     queryStrings.push_back("TWINMUX_KEY");
0074 
0075     l1t::OMDSReader::QueryResults subkeyResults = m_omdsReader.basicQuery(queryStrings,
0076                                                                           "CMS_TRG_L1_CONF",
0077                                                                           "L1_TRG_CONF_KEYS",
0078                                                                           "L1_TRG_CONF_KEYS.ID",
0079                                                                           m_omdsReader.singleAttribute(m_tscKey));
0080 
0081     if (subkeyResults.queryFailed() || subkeyResults.numberRows() != 1)  // check query successful
0082     {
0083       edm::LogError("L1-O2O") << "Problem with subsystem TSC key: " << m_tscKey;
0084       return pL1TriggerKey;
0085     }
0086 
0087     std::string uGTKey, uGMTKey, CALOKey, BMTFKey, OMTFKey, EMTFKey, TWINMUXKey;
0088 
0089     subkeyResults.fillVariable("UGT_KEY", uGTKey);
0090     subkeyResults.fillVariable("UGMT_KEY", uGMTKey);
0091     //       subkeyResults.fillVariable( "CALO_KEY",    CALOKey   ) ;
0092     subkeyResults.fillVariable("BMTF_KEY", BMTFKey);
0093     subkeyResults.fillVariable("OMTF_KEY", OMTFKey);
0094     subkeyResults.fillVariable("EMTF_KEY", EMTFKey);
0095     subkeyResults.fillVariable("TWINMUX_KEY", TWINMUXKey);
0096 
0097     // For RUN II the subsystem CondFormats for ALGO and RS are merged together -> we join ALGO and RS keys
0098 
0099     queryStrings.clear();
0100     queryStrings.push_back("UGT_RS_KEY");
0101     queryStrings.push_back("UGMT_RS_KEY");
0102     //       queryStrings.push_back( "CALO_RS_KEY" );
0103     queryStrings.push_back("BMTF_RS_KEY");
0104     queryStrings.push_back("EMTF_RS_KEY");
0105     queryStrings.push_back("OMTF_RS_KEY");
0106     queryStrings.push_back("TWINMUX_RS_KEY");
0107 
0108     subkeyResults = m_omdsReader.basicQuery(
0109         queryStrings, "CMS_TRG_L1_CONF", "L1_TRG_RS_KEYS", "L1_TRG_RS_KEYS.ID", m_omdsReader.singleAttribute(m_rsKey));
0110 
0111     if (subkeyResults.queryFailed() || subkeyResults.numberRows() != 1)  // check query successful
0112     {
0113       edm::LogError("L1-O2O") << "Problem with subsystem RS key: " << m_rsKey;
0114       return pL1TriggerKey;
0115     }
0116 
0117     std::string uGTrsKey, uGMTrsKey, CALOrsKey, BMTFrsKey, OMTFrsKey, EMTFrsKey, TWINMUXrsKey;
0118 
0119     subkeyResults.fillVariable("UGT_RS_KEY", uGTrsKey);
0120     subkeyResults.fillVariable("UGMT_RS_KEY", uGMTrsKey);
0121     //       subkeyResults.fillVariable( "CALO_RS_KEY",    CALOrsKey ) ;
0122     subkeyResults.fillVariable("BMTF_RS_KEY", BMTFrsKey);
0123     subkeyResults.fillVariable("OMTF_RS_KEY", OMTFrsKey);
0124     subkeyResults.fillVariable("EMTF_RS_KEY", EMTFrsKey);
0125     subkeyResults.fillVariable("TWINMUX_RS_KEY", TWINMUXrsKey);
0126 
0127     // The offline CALO folks want to have CALOL1 and CALOL2 together -> provide the top level TSC key for the kCALO payload and let them handle the rest
0128     CALOKey = m_tscKey;
0129     CALOrsKey = m_rsKey;
0130 
0131     pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kuGT, uGTKey + delimeter + uGTrsKey);
0132     pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kuGMT, uGMTKey + delimeter + uGMTrsKey);
0133     pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kCALO, CALOKey + delimeter + CALOrsKey);
0134     pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kBMTF, BMTFKey + delimeter + BMTFrsKey);
0135     pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kOMTF, OMTFKey + delimeter + OMTFrsKey);
0136     pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kEMTF, EMTFKey + delimeter + EMTFrsKey);
0137     pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kTWINMUX, TWINMUXKey + delimeter + TWINMUXrsKey);
0138 
0139     edm::LogVerbatim("L1-O2O") << "UGT_KEY: " << uGTKey;
0140     edm::LogVerbatim("L1-O2O") << "UGT_RS_KEY:  " << uGTrsKey;
0141     edm::LogVerbatim("L1-O2O") << "UGMT_KEY:    " << uGMTKey;
0142     edm::LogVerbatim("L1-O2O") << "UGMT_RS_KEY: " << uGMTrsKey;
0143     edm::LogVerbatim("L1-O2O") << "CALO_KEY:    " << CALOKey;
0144     edm::LogVerbatim("L1-O2O") << "CALO_RS_KEY: " << CALOrsKey;
0145     edm::LogVerbatim("L1-O2O") << "BMTF_KEY:    " << BMTFKey;
0146     edm::LogVerbatim("L1-O2O") << "BMTF_RS_KEY: " << BMTFrsKey;
0147     edm::LogVerbatim("L1-O2O") << "OMTF_KEY:    " << OMTFKey;
0148     edm::LogVerbatim("L1-O2O") << "OMTF_RS_KEY: " << OMTFrsKey;
0149     edm::LogVerbatim("L1-O2O") << "EMTF_KEY:    " << EMTFKey;
0150     edm::LogVerbatim("L1-O2O") << "EMTF_RS_KEY: " << EMTFrsKey;
0151     edm::LogVerbatim("L1-O2O") << "TWINMUX_KEY: " << TWINMUXKey;
0152     edm::LogVerbatim("L1-O2O") << "TWINMUX_RS_KEY:  " << TWINMUXrsKey;
0153 
0154   } else {
0155     throw l1t::DataAlreadyPresentException("L1TriggerKeyExt for TSC key " + m_tscKey + " and RS key " + m_rsKey +
0156                                            " already in CondDB.");
0157   }
0158 
0159   return pL1TriggerKey;
0160 }
0161 
0162 //define this as a plug-in
0163 //DEFINE_FWK_EVENTSETUP_MODULE(L1SubsystemKeysOnlineProdExt);