CMS 3D CMS Logo

L1TMuonEndCapObjectKeysOnlineProd.cc
Go to the documentation of this file.
1 #include <iostream>
6 #include "OnlineDBqueryHelper.h"
7 
9 private:
11 
12 public:
13  void fillObjectKeys(L1TriggerKeyExt* pL1TriggerKey) override;
14 
17 };
18 
21  transactionSafe = iConfig.getParameter<bool>("transactionSafe");
22 }
23 
25  std::string EMTFKey = pL1TriggerKey->subsystemKey(L1TriggerKeyExt::kEMTF);
26 
27  // simply assign the algo key to the record
28  pL1TriggerKey->add("L1TMuonEndCapParamsO2ORcd", "L1TMuonEndCapParams", EMTFKey);
29 
30  std::string tscKey = EMTFKey.substr(0, EMTFKey.find(":"));
31 
33  // the block below reproduces L1TMuonEndCapParamsOnlineProd identically
34 
35  std::string algo_key, hw_key;
36  std::string algo_payload, hw_payload;
37  try {
38  std::map<std::string, std::string> keys =
39  l1t::OnlineDBqueryHelper::fetch({"HW", "ALGO"}, "EMTF_KEYS", tscKey, m_omdsReader);
40 
41  hw_key = keys["HW"];
42  algo_key = keys["ALGO"];
43 
44  hw_payload = l1t::OnlineDBqueryHelper::fetch({"CONF"}, "EMTF_CLOBS", hw_key, m_omdsReader)["CONF"];
45 
46  algo_payload = l1t::OnlineDBqueryHelper::fetch({"CONF"}, "EMTF_CLOBS", algo_key, m_omdsReader)["CONF"];
47 
48  } catch (std::runtime_error& e) {
49  edm::LogError("L1-O2O: L1TMuonEndCapObjectKeysOnlineProd") << e.what();
50  if (transactionSafe)
51  throw std::runtime_error("SummaryForFunctionManager: EMTF | Faulty | Broken key");
52  else {
53  edm::LogError("L1-O2O: L1TMuonEndCapObjectKeysOnlineProd")
54  << "forcing L1TMuonEndCapForest key to be = '7' (known to exist)";
55  pL1TriggerKey->add("L1TMuonEndCapForestO2ORcd", "L1TMuonEndCapForest", "7");
56  return;
57  }
58  }
59 
60  l1t::XmlConfigParser xmlRdr;
61  l1t::TriggerSystem trgSys;
62 
63  try {
64  xmlRdr.readDOMFromString(hw_payload);
65  xmlRdr.readRootElement(trgSys);
66 
67  xmlRdr.readDOMFromString(algo_payload);
68  xmlRdr.readRootElement(trgSys);
69 
70  trgSys.setConfigured();
71  } catch (std::runtime_error& e) {
72  edm::LogError("L1-O2O: L1TMuonEndCapObjectKeysOnlineProd") << e.what();
73  if (transactionSafe)
74  throw std::runtime_error("SummaryForFunctionManager: EMTF | Faulty | Cannot parse XMLs");
75  else {
76  edm::LogError("L1-O2O: L1TMuonEndCapObjectKeysOnlineProd")
77  << "forcing L1TMuonEndCapForest key to be = '7' (known to exist)";
78  pL1TriggerKey->add("L1TMuonEndCapForestO2ORcd", "L1TMuonEndCapForest", "7");
79  return;
80  }
81  }
82 
83  // Changed from "EMTF-1" to "EMTFp1", but is this backwards compatible? Does it need to be? - AWB 10.04.2018
84  std::map<std::string, l1t::Parameter> conf = trgSys.getParameters("EMTFp1"); // any processor will do
85  // if (conf still empty) conf = trgSys.getParameters("EMTF+1"); // Should add some conditional for backwards-compatibility
86 
88 
89  // simply assign the algo key to the record
90  pL1TriggerKey->add("L1TMuonEndCapForestO2ORcd", "L1TMuonEndCapForest", conf["pt_lut_version"].getValueAsStr());
91 }
92 
93 //define this as a plug-in
T getParameter(std::string const &) const
void setConfigured(bool state=true) noexcept
Definition: TriggerSystem.h:74
L1TMuonEndCapObjectKeysOnlineProd(const edm::ParameterSet &)
void add(const std::string &record, const std::string &type, const std::string &key)
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
static std::map< std::string, std::string > fetch(const std::vector< std::string > &queryColumns, const std::string &table, const std::string &key, l1t::OMDSReader &m_omdsReader)
const std::string & subsystemKey(L1Subsystems subsystem) const
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
const std::map< std::string, Parameter > & getParameters(const char *processor) const
void readRootElement(TriggerSystem &aTriggerSystem, const std::string &sysId="")
void fillObjectKeys(L1TriggerKeyExt *pL1TriggerKey) override