File indexing completed on 2024-04-06 12:22:24
0001 #include <iostream>
0002 #include "CondTools/L1TriggerExt/interface/L1ObjectKeysOnlineProdBaseExt.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include "L1Trigger/L1TCommon/interface/TriggerSystem.h"
0005 #include "L1Trigger/L1TCommon/interface/XmlConfigParser.h"
0006 #include "OnlineDBqueryHelper.h"
0007
0008 class L1TMuonEndCapObjectKeysOnlineProd : public L1ObjectKeysOnlineProdBaseExt {
0009 private:
0010 bool transactionSafe;
0011
0012 public:
0013 void fillObjectKeys(L1TriggerKeyExt* pL1TriggerKey) override;
0014
0015 L1TMuonEndCapObjectKeysOnlineProd(const edm::ParameterSet&);
0016 ~L1TMuonEndCapObjectKeysOnlineProd(void) override {}
0017 };
0018
0019 L1TMuonEndCapObjectKeysOnlineProd::L1TMuonEndCapObjectKeysOnlineProd(const edm::ParameterSet& iConfig)
0020 : L1ObjectKeysOnlineProdBaseExt(iConfig) {
0021 transactionSafe = iConfig.getParameter<bool>("transactionSafe");
0022 }
0023
0024 void L1TMuonEndCapObjectKeysOnlineProd::fillObjectKeys(L1TriggerKeyExt* pL1TriggerKey) {
0025 std::string EMTFKey = pL1TriggerKey->subsystemKey(L1TriggerKeyExt::kEMTF);
0026
0027
0028 pL1TriggerKey->add("L1TMuonEndCapParamsO2ORcd", "L1TMuonEndCapParams", EMTFKey);
0029
0030 std::string tscKey = EMTFKey.substr(0, EMTFKey.find(':'));
0031
0032
0033
0034
0035 std::string algo_key, hw_key;
0036 std::string algo_payload, hw_payload;
0037 try {
0038 std::map<std::string, std::string> keys =
0039 l1t::OnlineDBqueryHelper::fetch({"HW", "ALGO"}, "EMTF_KEYS", tscKey, m_omdsReader);
0040
0041 hw_key = keys["HW"];
0042 algo_key = keys["ALGO"];
0043
0044 hw_payload = l1t::OnlineDBqueryHelper::fetch({"CONF"}, "EMTF_CLOBS", hw_key, m_omdsReader)["CONF"];
0045
0046 algo_payload = l1t::OnlineDBqueryHelper::fetch({"CONF"}, "EMTF_CLOBS", algo_key, m_omdsReader)["CONF"];
0047
0048 } catch (std::runtime_error& e) {
0049 edm::LogError("L1-O2O: L1TMuonEndCapObjectKeysOnlineProd") << e.what();
0050 if (transactionSafe)
0051 throw std::runtime_error("SummaryForFunctionManager: EMTF | Faulty | Broken key");
0052 else {
0053 edm::LogError("L1-O2O: L1TMuonEndCapObjectKeysOnlineProd")
0054 << "forcing L1TMuonEndCapForest key to be = '7' (known to exist)";
0055 pL1TriggerKey->add("L1TMuonEndCapForestO2ORcd", "L1TMuonEndCapForest", "7");
0056 return;
0057 }
0058 }
0059
0060 l1t::XmlConfigParser xmlRdr;
0061 l1t::TriggerSystem trgSys;
0062
0063 try {
0064 xmlRdr.readDOMFromString(hw_payload);
0065 xmlRdr.readRootElement(trgSys);
0066
0067 xmlRdr.readDOMFromString(algo_payload);
0068 xmlRdr.readRootElement(trgSys);
0069
0070 trgSys.setConfigured();
0071 } catch (std::runtime_error& e) {
0072 edm::LogError("L1-O2O: L1TMuonEndCapObjectKeysOnlineProd") << e.what();
0073 if (transactionSafe)
0074 throw std::runtime_error("SummaryForFunctionManager: EMTF | Faulty | Cannot parse XMLs");
0075 else {
0076 edm::LogError("L1-O2O: L1TMuonEndCapObjectKeysOnlineProd")
0077 << "forcing L1TMuonEndCapForest key to be = '7' (known to exist)";
0078 pL1TriggerKey->add("L1TMuonEndCapForestO2ORcd", "L1TMuonEndCapForest", "7");
0079 return;
0080 }
0081 }
0082
0083
0084 std::map<std::string, l1t::Parameter> conf = trgSys.getParameters("EMTFp1");
0085
0086
0087
0088
0089
0090 pL1TriggerKey->add("L1TMuonEndCapForestO2ORcd", "L1TMuonEndCapForest", conf["pt_lut_version"].getValueAsStr());
0091 }
0092
0093
0094 DEFINE_FWK_EVENTSETUP_MODULE(L1TMuonEndCapObjectKeysOnlineProd);