CMS 3D CMS Logo

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