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 
21 // system include files
22 
23 // user include files
25 
27 
30 
33 
35 
36 //
37 // class declaration
38 //
39 
40 //
41 // constants, enums and typedefs
42 //
43 
44 //
45 // static data member definitions
46 //
47 
48 //
49 // constructors and destructor
50 //
52  : m_tscKey( iConfig.getParameter< std::string >( "tscKey" ) ),
53  m_omdsReader(
54  iConfig.getParameter< std::string >( "onlineDB" ),
55  iConfig.getParameter< std::string >( "onlineAuthentication" ) ),
56  m_forceGeneration( iConfig.getParameter< bool >( "forceGeneration" ) )
57 {
58  //the following line is needed to tell the framework what
59  // data is being produced
60  setWhatProduced(this, "SubsystemKeysOnly");
61 
62  //now do what ever other initialization is needed
63 }
64 
65 
67 {
68 
69  // do anything here that needs to be done at desctruction time
70  // (e.g. close files, deallocate resources etc.)
71 
72 }
73 
74 
75 //
76 // member functions
77 //
78 
79 // ------------ method called to produce the data ------------
82 {
83  using namespace edm::es;
84  std::unique_ptr<L1TriggerKey> pL1TriggerKey ;
85 
86  // Get L1TriggerKeyList
87  L1TriggerKeyList keyList ;
88  l1t::DataWriter dataWriter ;
89  if( !dataWriter.fillLastTriggerKeyList( keyList ) )
90  {
91  edm::LogError( "L1-O2O" )
92  << "Problem getting last L1TriggerKeyList" ;
93  }
94 
95  // If L1TriggerKeyList does not contain TSC key, token is empty
96  if( keyList.token( m_tscKey ) == std::string() ||
98  {
99  // Instantiate new L1TriggerKey
100  pL1TriggerKey = std::make_unique< L1TriggerKey >() ;
101  pL1TriggerKey->setTSCKey( m_tscKey ) ;
102 
103  edm::LogVerbatim( "L1-O2O" ) << "TSC KEY " << m_tscKey ;
104 
105  // Get subsystem keys from OMDS
106 
107  // 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
108  std::vector< std::string > queryStrings ;
109  queryStrings.push_back( "CSCTF_KEY" ) ;
110  queryStrings.push_back( "DTTF_KEY" ) ;
111  queryStrings.push_back( "RPC_KEY" ) ;
112  queryStrings.push_back( "GMT_KEY" ) ;
113  queryStrings.push_back( "RCT_KEY" ) ;
114  queryStrings.push_back( "GCT_KEY" ) ;
115  queryStrings.push_back( "GT_KEY" ) ;
116  // queryStrings.push_back( "TSP0_KEY" ) ;
117 
118  l1t::OMDSReader::QueryResults subkeyResults =
119  m_omdsReader.basicQuery( queryStrings,
120  "CMS_TRG_L1_CONF",
121  "TRIGGERSUP_CONF",
122  "TRIGGERSUP_CONF.TS_KEY",
124 
125  if( subkeyResults.queryFailed() ||
126  subkeyResults.numberRows() != 1 ) // check query successful
127  {
128  edm::LogError( "L1-O2O" ) << "Problem with subsystem keys." ;
129  return pL1TriggerKey ;
130  }
131 
132  std::string csctfKey, dttfKey, rpcKey, gmtKey, rctKey, gctKey, gtKey ;
133 
134  subkeyResults.fillVariable( "CSCTF_KEY", csctfKey ) ;
135  pL1TriggerKey->setSubsystemKey( L1TriggerKey::kCSCTF, csctfKey ) ;
136  edm::LogVerbatim( "L1-O2O" ) << "CSCTF_KEY " << csctfKey ;
137 
138  subkeyResults.fillVariable( "DTTF_KEY", dttfKey ) ;
139  pL1TriggerKey->setSubsystemKey( L1TriggerKey::kDTTF, dttfKey ) ;
140  edm::LogVerbatim( "L1-O2O" ) << "DTTF_KEY " << dttfKey ;
141 
142  subkeyResults.fillVariable( "RPC_KEY", rpcKey ) ;
143  pL1TriggerKey->setSubsystemKey( L1TriggerKey::kRPC, rpcKey ) ;
144  edm::LogVerbatim( "L1-O2O" ) << "RPC_KEY " << rpcKey ;
145 
146  subkeyResults.fillVariable( "GMT_KEY", gmtKey ) ;
147  pL1TriggerKey->setSubsystemKey( L1TriggerKey::kGMT, gmtKey ) ;
148  edm::LogVerbatim( "L1-O2O" ) << "GMT_KEY " << gmtKey ;
149 
150  subkeyResults.fillVariable( "RCT_KEY", rctKey ) ;
151  pL1TriggerKey->setSubsystemKey( L1TriggerKey::kRCT, rctKey ) ;
152  edm::LogVerbatim( "L1-O2O" ) << "RCT_KEY " << rctKey ;
153 
154  subkeyResults.fillVariable( "GCT_KEY", gctKey ) ;
155  pL1TriggerKey->setSubsystemKey( L1TriggerKey::kGCT, gctKey ) ;
156  edm::LogVerbatim( "L1-O2O" ) << "GCT_KEY " << gctKey ;
157 
158  subkeyResults.fillVariable( "GT_KEY", gtKey ) ;
159  pL1TriggerKey->setSubsystemKey( L1TriggerKey::kGT, gtKey ) ;
160  edm::LogVerbatim( "L1-O2O" ) << "GT_KEY " << gtKey ;
161 
162  // std::string tsp0Key = row[ "TSP0_KEY" ].data< std::string >() ;
163  std::string tsp0Key ;
164  pL1TriggerKey->setSubsystemKey( L1TriggerKey::kTSP0, tsp0Key ) ;
165  edm::LogVerbatim( "L1-O2O" ) << "TSP0_KEY " << tsp0Key ;
166  }
167  else
168  {
170  "L1TriggerKey for TSC key " + m_tscKey + " already in CondDB." ) ;
171  }
172 
173  return pL1TriggerKey ;
174 }
175 
176 //define this as a plug-in
177 //DEFINE_FWK_EVENTSETUP_MODULE(L1SubsystemKeysOnlineProd);
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:311
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:295
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
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:86
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:198
std::string token(const std::string &tscKey) const
L1SubsystemKeysOnlineProd(const edm::ParameterSet &)