CMS 3D CMS Logo

L1SubsystemKeysOnlineProd.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1SubsystemKeysOnlineProd
4 // Class: L1SubsystemKeysOnlineProd
5 //
13 //
14 // Original Author: Werner Man-Li Sun
15 // Created: Thu Aug 21 20:00:59 CEST 2008
16 // $Id: L1SubsystemKeysOnlineProd.cc,v 1.5 2010/02/01 22:00:03 wsun Exp $
17 //
18 //
19 
20 // system include files
21 
22 // user include files
24 
26 
29 
32 
34 
35 //
36 // class declaration
37 //
38 
39 //
40 // constants, enums and typedefs
41 //
42 
43 //
44 // static data member definitions
45 //
46 
47 //
48 // constructors and destructor
49 //
51  : m_tscKey(iConfig.getParameter<std::string>("tscKey")),
52  m_omdsReader(iConfig.getParameter<std::string>("onlineDB"),
53  iConfig.getParameter<std::string>("onlineAuthentication")),
54  m_forceGeneration(iConfig.getParameter<bool>("forceGeneration")) {
55  //the following line is needed to tell the framework what
56  // data is being produced
57  setWhatProduced(this, "SubsystemKeysOnly");
58 
59  //now do what ever other initialization is needed
60 }
61 
63  // do anything here that needs to be done at desctruction time
64  // (e.g. close files, deallocate resources etc.)
65 }
66 
67 //
68 // member functions
69 //
70 
71 // ------------ method called to produce the data ------------
73  std::unique_ptr<L1TriggerKey> pL1TriggerKey;
74 
75  // Get L1TriggerKeyList
76  L1TriggerKeyList keyList;
77  l1t::DataWriter dataWriter;
78  if (!dataWriter.fillLastTriggerKeyList(keyList)) {
79  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyList";
80  }
81 
82  // If L1TriggerKeyList does not contain TSC key, token is empty
83  if (keyList.token(m_tscKey).empty() || m_forceGeneration) {
84  // Instantiate new L1TriggerKey
85  pL1TriggerKey = std::make_unique<L1TriggerKey>();
86  pL1TriggerKey->setTSCKey(m_tscKey);
87 
88  edm::LogVerbatim("L1-O2O") << "TSC KEY " << m_tscKey;
89 
90  // Get subsystem keys from OMDS
91 
92  // SELECT CSCTF_KEY, DTTF_KEY, RPC_KEY, GMT_KEY, RCT_KEY, GCT_KEY, GT_KEY FROM TRIGGERSUP_CONF WHERE TRIGGERSUP_CONF.TS_KEY = m_tscKey
93  std::vector<std::string> queryStrings;
94  queryStrings.push_back("CSCTF_KEY");
95  queryStrings.push_back("DTTF_KEY");
96  queryStrings.push_back("RPC_KEY");
97  queryStrings.push_back("GMT_KEY");
98  queryStrings.push_back("RCT_KEY");
99  queryStrings.push_back("GCT_KEY");
100  queryStrings.push_back("GT_KEY");
101  // queryStrings.push_back( "TSP0_KEY" ) ;
102 
103  l1t::OMDSReader::QueryResults subkeyResults = m_omdsReader.basicQuery(queryStrings,
104  "CMS_TRG_L1_CONF",
105  "TRIGGERSUP_CONF",
106  "TRIGGERSUP_CONF.TS_KEY",
108 
109  if (subkeyResults.queryFailed() || subkeyResults.numberRows() != 1) // check query successful
110  {
111  edm::LogError("L1-O2O") << "Problem with subsystem keys.";
112  return pL1TriggerKey;
113  }
114 
115  std::string csctfKey, dttfKey, rpcKey, gmtKey, rctKey, gctKey, gtKey;
116 
117  subkeyResults.fillVariable("CSCTF_KEY", csctfKey);
118  pL1TriggerKey->setSubsystemKey(L1TriggerKey::kCSCTF, csctfKey);
119  edm::LogVerbatim("L1-O2O") << "CSCTF_KEY " << csctfKey;
120 
121  subkeyResults.fillVariable("DTTF_KEY", dttfKey);
122  pL1TriggerKey->setSubsystemKey(L1TriggerKey::kDTTF, dttfKey);
123  edm::LogVerbatim("L1-O2O") << "DTTF_KEY " << dttfKey;
124 
125  subkeyResults.fillVariable("RPC_KEY", rpcKey);
126  pL1TriggerKey->setSubsystemKey(L1TriggerKey::kRPC, rpcKey);
127  edm::LogVerbatim("L1-O2O") << "RPC_KEY " << rpcKey;
128 
129  subkeyResults.fillVariable("GMT_KEY", gmtKey);
130  pL1TriggerKey->setSubsystemKey(L1TriggerKey::kGMT, gmtKey);
131  edm::LogVerbatim("L1-O2O") << "GMT_KEY " << gmtKey;
132 
133  subkeyResults.fillVariable("RCT_KEY", rctKey);
134  pL1TriggerKey->setSubsystemKey(L1TriggerKey::kRCT, rctKey);
135  edm::LogVerbatim("L1-O2O") << "RCT_KEY " << rctKey;
136 
137  subkeyResults.fillVariable("GCT_KEY", gctKey);
138  pL1TriggerKey->setSubsystemKey(L1TriggerKey::kGCT, gctKey);
139  edm::LogVerbatim("L1-O2O") << "GCT_KEY " << gctKey;
140 
141  subkeyResults.fillVariable("GT_KEY", gtKey);
142  pL1TriggerKey->setSubsystemKey(L1TriggerKey::kGT, gtKey);
143  edm::LogVerbatim("L1-O2O") << "GT_KEY " << gtKey;
144 
145  // std::string tsp0Key = row[ "TSP0_KEY" ].data< std::string >() ;
146  std::string tsp0Key;
147  pL1TriggerKey->setSubsystemKey(L1TriggerKey::kTSP0, tsp0Key);
148  edm::LogVerbatim("L1-O2O") << "TSP0_KEY " << tsp0Key;
149  } else {
150  throw l1t::DataAlreadyPresentException("L1TriggerKey for TSC key " + m_tscKey + " already in CondDB.");
151  }
152 
153  return pL1TriggerKey;
154 }
155 
156 //define this as a plug-in
157 //DEFINE_FWK_EVENTSETUP_MODULE(L1SubsystemKeysOnlineProd);
l1t::OMDSReader::QueryResults
Definition: OMDSReader.h:49
DataWriter.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
L1SubsystemKeysOnlineProd::~L1SubsystemKeysOnlineProd
~L1SubsystemKeysOnlineProd() override
Definition: L1SubsystemKeysOnlineProd.cc:62
L1TriggerKey::kRPC
Definition: L1TriggerKey.h:27
L1SubsystemKeysOnlineProd::ReturnType
std::unique_ptr< L1TriggerKey > ReturnType
Definition: L1SubsystemKeysOnlineProd.h:42
MessageLogger.h
L1SubsystemKeysOnlineProd::produce
ReturnType produce(const L1TriggerKeyRcd &)
Definition: L1SubsystemKeysOnlineProd.cc:72
Exception.h
L1TriggerKeyRcd
Definition: L1TriggerKeyRcd.h:30
L1TriggerKey::kGMT
Definition: L1TriggerKey.h:27
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
l1t::DataAlreadyPresentException
Definition: Exception.h:32
l1t::OMDSReader::singleAttribute
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
L1TriggerKey::kTSP0
Definition: L1TriggerKey.h:27
l1t::OMDSReader::QueryResults::fillVariable
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
L1TriggerKey::kRCT
Definition: L1TriggerKey.h:27
L1SubsystemKeysOnlineProd::L1SubsystemKeysOnlineProd
L1SubsystemKeysOnlineProd(const edm::ParameterSet &)
Definition: L1SubsystemKeysOnlineProd.cc:50
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1TriggerKeyList
Definition: L1TriggerKeyList.h:32
edm::ParameterSet
Definition: ParameterSet.h:47
L1TriggerKey::kDTTF
Definition: L1TriggerKey.h:27
L1SubsystemKeysOnlineProd::m_tscKey
std::string m_tscKey
Definition: L1SubsystemKeysOnlineProd.h:48
L1TriggerKey::kGCT
Definition: L1TriggerKey.h:27
l1t::OMDSReader::QueryResults::numberRows
int numberRows() const
Definition: OMDSReader.h:60
L1SubsystemKeysOnlineProd.h
L1TriggerKeyList.h
l1t::OMDSReader::basicQuery
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
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
L1SubsystemKeysOnlineProd::m_forceGeneration
bool m_forceGeneration
Definition: L1SubsystemKeysOnlineProd.h:50
L1TriggerKey::kGT
Definition: L1TriggerKey.h:27
l1t::DataWriter::fillLastTriggerKeyList
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:147
std
Definition: JetResolutionObject.h:76
L1SubsystemKeysOnlineProd::m_omdsReader
l1t::OMDSReader m_omdsReader
Definition: L1SubsystemKeysOnlineProd.h:49
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
EventSetup.h
L1TriggerKey::kCSCTF
Definition: L1TriggerKey.h:27
l1t::OMDSReader::QueryResults::queryFailed
bool queryFailed() const
Definition: OMDSReader.h:59
l1t::DataWriter
Definition: DataWriter.h:35
L1TriggerKeyList::token
std::string token(const std::string &tscKey) const
Definition: L1TriggerKeyList.cc:96
L1TriggerKeyListRcd.h