CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1SubsystemKeysOnlineProdExt.cc
Go to the documentation of this file.
2 
4 
7 
10 
12 
14  : m_tscKey(iConfig.getParameter<std::string>("tscKey")),
15  m_rsKey(iConfig.getParameter<std::string>("rsKey")),
16  m_omdsReader(iConfig.getParameter<std::string>("onlineDB"),
17  iConfig.getParameter<std::string>("onlineAuthentication")),
18  m_forceGeneration(iConfig.getParameter<bool>("forceGeneration")) {
19  //the following line is needed to tell the framework what
20  // data is being produced
21  setWhatProduced(this, "SubsystemKeysOnly");
22 
23  //now do what ever other initialization is needed
24 }
25 
27  // do anything here that needs to be done at desctruction time
28  // (e.g. close files, deallocate resources etc.)
29 }
30 
31 //
32 // member functions
33 //
34 
35 // ------------ method called to produce the data ------------
37  std::unique_ptr<L1TriggerKeyExt> pL1TriggerKey;
38 
39  // Get L1TriggerKeyListExt
40  L1TriggerKeyListExt keyList;
41  if (!m_forceGeneration) {
42  l1t::DataWriterExt dataWriter;
43  if (!dataWriter.fillLastTriggerKeyList(keyList)) {
44  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyListExt";
45  }
46  }
47  // For RUN II the subsystem CondFormats for ALGO and RS are merged together -> we join ALGO and RS keys
48 
49  // combine the ALGO and RS keys:
50  std::string delimeter = ":";
51  std::string m_Key = m_tscKey + delimeter + m_rsKey;
52 
53  // If L1TriggerKeyListExt does not contain TSC key, token is empty
54  if (keyList.token(m_Key).empty() || m_forceGeneration) {
55  // Instantiate new L1TriggerKey
56  pL1TriggerKey = std::make_unique<L1TriggerKeyExt>();
57 
58  pL1TriggerKey->setTSCKey(m_Key);
59 
60  edm::LogVerbatim("L1-O2O") << "TSC KEY: " << m_tscKey;
61  edm::LogVerbatim("L1-O2O") << "RS_KEY: " << m_rsKey;
62 
63  // Get subsystem keys from OMDS
64 
65  // select * from CMS_TRG_L1_CONF.L1_TRG_CONF_KEYS where ID = m_tscKey
66  std::vector<std::string> queryStrings;
67  queryStrings.push_back("UGT_KEY");
68  queryStrings.push_back("UGMT_KEY");
69  // queryStrings.push_back( "CALO_KEY" ) ;
70  queryStrings.push_back("BMTF_KEY");
71  queryStrings.push_back("OMTF_KEY");
72  queryStrings.push_back("EMTF_KEY");
73  queryStrings.push_back("TWINMUX_KEY");
74 
75  l1t::OMDSReader::QueryResults subkeyResults = m_omdsReader.basicQuery(queryStrings,
76  "CMS_TRG_L1_CONF",
77  "L1_TRG_CONF_KEYS",
78  "L1_TRG_CONF_KEYS.ID",
80 
81  if (subkeyResults.queryFailed() || subkeyResults.numberRows() != 1) // check query successful
82  {
83  edm::LogError("L1-O2O") << "Problem with subsystem TSC key: " << m_tscKey;
84  return pL1TriggerKey;
85  }
86 
87  std::string uGTKey, uGMTKey, CALOKey, BMTFKey, OMTFKey, EMTFKey, TWINMUXKey;
88 
89  subkeyResults.fillVariable("UGT_KEY", uGTKey);
90  subkeyResults.fillVariable("UGMT_KEY", uGMTKey);
91  // subkeyResults.fillVariable( "CALO_KEY", CALOKey ) ;
92  subkeyResults.fillVariable("BMTF_KEY", BMTFKey);
93  subkeyResults.fillVariable("OMTF_KEY", OMTFKey);
94  subkeyResults.fillVariable("EMTF_KEY", EMTFKey);
95  subkeyResults.fillVariable("TWINMUX_KEY", TWINMUXKey);
96 
97  // For RUN II the subsystem CondFormats for ALGO and RS are merged together -> we join ALGO and RS keys
98 
99  queryStrings.clear();
100  queryStrings.push_back("UGT_RS_KEY");
101  queryStrings.push_back("UGMT_RS_KEY");
102  // queryStrings.push_back( "CALO_RS_KEY" );
103  queryStrings.push_back("BMTF_RS_KEY");
104  queryStrings.push_back("EMTF_RS_KEY");
105  queryStrings.push_back("OMTF_RS_KEY");
106  queryStrings.push_back("TWINMUX_RS_KEY");
107 
108  subkeyResults = m_omdsReader.basicQuery(
109  queryStrings, "CMS_TRG_L1_CONF", "L1_TRG_RS_KEYS", "L1_TRG_RS_KEYS.ID", m_omdsReader.singleAttribute(m_rsKey));
110 
111  if (subkeyResults.queryFailed() || subkeyResults.numberRows() != 1) // check query successful
112  {
113  edm::LogError("L1-O2O") << "Problem with subsystem RS key: " << m_rsKey;
114  return pL1TriggerKey;
115  }
116 
117  std::string uGTrsKey, uGMTrsKey, CALOrsKey, BMTFrsKey, OMTFrsKey, EMTFrsKey, TWINMUXrsKey;
118 
119  subkeyResults.fillVariable("UGT_RS_KEY", uGTrsKey);
120  subkeyResults.fillVariable("UGMT_RS_KEY", uGMTrsKey);
121  // subkeyResults.fillVariable( "CALO_RS_KEY", CALOrsKey ) ;
122  subkeyResults.fillVariable("BMTF_RS_KEY", BMTFrsKey);
123  subkeyResults.fillVariable("OMTF_RS_KEY", OMTFrsKey);
124  subkeyResults.fillVariable("EMTF_RS_KEY", EMTFrsKey);
125  subkeyResults.fillVariable("TWINMUX_RS_KEY", TWINMUXrsKey);
126 
127  // 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
128  CALOKey = m_tscKey;
129  CALOrsKey = m_rsKey;
130 
131  pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kuGT, uGTKey + delimeter + uGTrsKey);
132  pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kuGMT, uGMTKey + delimeter + uGMTrsKey);
133  pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kCALO, CALOKey + delimeter + CALOrsKey);
134  pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kBMTF, BMTFKey + delimeter + BMTFrsKey);
135  pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kOMTF, OMTFKey + delimeter + OMTFrsKey);
136  pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kEMTF, EMTFKey + delimeter + EMTFrsKey);
137  pL1TriggerKey->setSubsystemKey(L1TriggerKeyExt::kTWINMUX, TWINMUXKey + delimeter + TWINMUXrsKey);
138 
139  edm::LogVerbatim("L1-O2O") << "UGT_KEY: " << uGTKey;
140  edm::LogVerbatim("L1-O2O") << "UGT_RS_KEY: " << uGTrsKey;
141  edm::LogVerbatim("L1-O2O") << "UGMT_KEY: " << uGMTKey;
142  edm::LogVerbatim("L1-O2O") << "UGMT_RS_KEY: " << uGMTrsKey;
143  edm::LogVerbatim("L1-O2O") << "CALO_KEY: " << CALOKey;
144  edm::LogVerbatim("L1-O2O") << "CALO_RS_KEY: " << CALOrsKey;
145  edm::LogVerbatim("L1-O2O") << "BMTF_KEY: " << BMTFKey;
146  edm::LogVerbatim("L1-O2O") << "BMTF_RS_KEY: " << BMTFrsKey;
147  edm::LogVerbatim("L1-O2O") << "OMTF_KEY: " << OMTFKey;
148  edm::LogVerbatim("L1-O2O") << "OMTF_RS_KEY: " << OMTFrsKey;
149  edm::LogVerbatim("L1-O2O") << "EMTF_KEY: " << EMTFKey;
150  edm::LogVerbatim("L1-O2O") << "EMTF_RS_KEY: " << EMTFrsKey;
151  edm::LogVerbatim("L1-O2O") << "TWINMUX_KEY: " << TWINMUXKey;
152  edm::LogVerbatim("L1-O2O") << "TWINMUX_RS_KEY: " << TWINMUXrsKey;
153 
154  } else {
155  throw l1t::DataAlreadyPresentException("L1TriggerKeyExt for TSC key " + m_tscKey + " and RS key " + m_rsKey +
156  " already in CondDB.");
157  }
158 
159  return pL1TriggerKey;
160 }
161 
162 //define this as a plug-in
163 //DEFINE_FWK_EVENTSETUP_MODULE(L1SubsystemKeysOnlineProdExt);
Log< level::Info, true > LogVerbatim
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
bool fillLastTriggerKeyList(L1TriggerKeyListExt &output)
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
L1SubsystemKeysOnlineProdExt(const edm::ParameterSet &)
Log< level::Error, false > LogError
const QueryResults basicQuery(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
Definition: OMDSReader.cc:75
ReturnType produce(const L1TriggerKeyExtRcd &)
std::unique_ptr< L1TriggerKeyExt > ReturnType
std::string token(const std::string &tscKey) const