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);
Log< level::Info, true > LogVerbatim
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:165
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
std::string token(const std::string &tscKey) const
Log< level::Error, false > LogError
std::unique_ptr< L1TriggerKey > ReturnType
ReturnType produce(const L1TriggerKeyRcd &)
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
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:147
L1SubsystemKeysOnlineProd(const edm::ParameterSet &)