Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:21

0001 /**
0002  * \class L1GtTscObjectKeysOnlineProd
0003  *
0004  *
0005  * Description: online producer for L1 GT record keys starting from TSC key.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  * \author: Vasile Mihai Ghete - HEPHY Vienna
0011  *
0012  *
0013  */
0014 
0015 // this class header
0016 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtTscObjectKeysOnlineProd.h"
0017 
0018 // system include files
0019 
0020 // user include files
0021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0022 
0023 // constructor
0024 L1GtTscObjectKeysOnlineProd::L1GtTscObjectKeysOnlineProd(const edm::ParameterSet& parSet)
0025     : L1ObjectKeysOnlineProdBase(parSet),
0026       m_enableL1GtParameters(parSet.getParameter<bool>("EnableL1GtParameters")),
0027       m_enableL1GtTriggerMenu(parSet.getParameter<bool>("EnableL1GtTriggerMenu")),
0028       m_enableL1GtPsbSetup(parSet.getParameter<bool>("EnableL1GtPsbSetup")) {
0029   // empty
0030 }
0031 
0032 // destructor
0033 L1GtTscObjectKeysOnlineProd::~L1GtTscObjectKeysOnlineProd() {
0034   // empty
0035 }
0036 
0037 // private methods
0038 
0039 std::string L1GtTscObjectKeysOnlineProd::keyL1GtParameters(const std::string& subsystemKey,
0040                                                            const std::string& gtSchema) {
0041   std::string objectKey;
0042 
0043   if (!subsystemKey.empty()) {
0044     // Execute SQL queries to get keys from OMDS.
0045 
0046     // SELECT GTFE_SETUP_FK FROM CMS_GT.GT_SETUP WHERE GT_SETUP.ID = MyKey
0047     l1t::OMDSReader::QueryResults objectKeyResults = m_omdsReader.basicQuery(
0048         "GTFE_SETUP_FK", gtSchema, "GT_SETUP", "GT_SETUP.ID", m_omdsReader.singleAttribute(subsystemKey));
0049 
0050     // check if query was successful
0051     if (objectKeyResults.queryFailed()) {
0052       edm::LogError("L1-O2O") << "Problem with key for record L1GtParametersRcd: query failed ";
0053       return objectKey;
0054     } else if ((objectKeyResults.numberRows() != 1)) {
0055       edm::LogError("L1-O2O") << "Problem with key for record L1GtParametersRcd: " << (objectKeyResults.numberRows())
0056                               << " rows were returned";
0057       return objectKey;
0058     }
0059 
0060     objectKeyResults.fillVariable(objectKey);
0061   }
0062 
0063   return objectKey;
0064 }
0065 
0066 std::string L1GtTscObjectKeysOnlineProd::keyL1GtTriggerMenu(const std::string& subsystemKey,
0067                                                             const std::string& gtSchema) {
0068   std::string objectKey;
0069 
0070   if (!subsystemKey.empty()) {
0071     // Execute SQL queries to get keys from OMDS.
0072 
0073     // SELECT L1T_MENU_FK FROM CMS_GT.GT_SETUP WHERE GT_SETUP.ID = MyKey
0074     l1t::OMDSReader::QueryResults objectKeyResults = m_omdsReader.basicQuery(
0075         "L1T_MENU_FK", gtSchema, "GT_SETUP", "GT_SETUP.ID", m_omdsReader.singleAttribute(subsystemKey));
0076 
0077     // check if query was successful
0078     if (objectKeyResults.queryFailed()) {
0079       edm::LogError("L1-O2O") << "Problem with key for record L1GtTriggerMenuRcd: query failed ";
0080       return objectKey;
0081     } else if ((objectKeyResults.numberRows() != 1)) {
0082       edm::LogError("L1-O2O") << "Problem with key for record L1GtTriggerMenuRcd: " << (objectKeyResults.numberRows())
0083                               << " rows were returned";
0084       return objectKey;
0085     }
0086 
0087     objectKeyResults.fillVariable(objectKey);
0088   }
0089 
0090   return objectKey;
0091 }
0092 
0093 std::string L1GtTscObjectKeysOnlineProd::keyL1GtPsbSetup(const std::string& subsystemKey, const std::string& gtSchema) {
0094   std::string objectKey;
0095 
0096   if (!subsystemKey.empty()) {
0097     // no need to query OMDS, one uses the GT_SETUP key to get the individual PSB keys.
0098     //     the L1GtPsbSetup key is GT_SETUP key
0099     objectKey = subsystemKey;
0100   }
0101 
0102   return objectKey;
0103 }
0104 
0105 // public methods
0106 void L1GtTscObjectKeysOnlineProd::fillObjectKeys(FillType pL1TriggerKey) {
0107   // kMYSUBSYSTEM = kCSCTF, kDTTF, kRPC, kGMT, kRCT, mkGCT, kGT, or kTSP0
0108   // subsystemKey = TRIGGERSUP_CONF.{CSCTF_KEY, DTTF_KEY, RPC_KEY, GMT_KEY, RCT_KEY, GCT_KEY, GT_KEY}
0109 
0110   std::string subsystemKey = pL1TriggerKey->subsystemKey(L1TriggerKey::kGT);
0111   const std::string gtSchema = "CMS_GT";
0112 
0113   //
0114   if (m_enableL1GtParameters) {
0115     const std::string& objectKey = keyL1GtParameters(subsystemKey, gtSchema);
0116     if (!objectKey.empty()) {
0117       pL1TriggerKey->add("L1GtParametersRcd", "L1GtParameters", objectKey);
0118     }
0119   }
0120 
0121   //
0122   if (m_enableL1GtTriggerMenu) {
0123     const std::string& objectKey = keyL1GtTriggerMenu(subsystemKey, gtSchema);
0124     if (!objectKey.empty()) {
0125       pL1TriggerKey->add("L1GtTriggerMenuRcd", "L1GtTriggerMenu", objectKey);
0126     }
0127   }
0128 
0129   //
0130   if (m_enableL1GtPsbSetup) {
0131     const std::string& objectKey = keyL1GtPsbSetup(subsystemKey, gtSchema);
0132     if (!objectKey.empty()) {
0133       pL1TriggerKey->add("L1GtPsbSetupRcd", "L1GtPsbSetup", objectKey);
0134     }
0135   }
0136 }
0137 
0138 DEFINE_FWK_EVENTSETUP_MODULE(L1GtTscObjectKeysOnlineProd);