CMS 3D CMS Logo

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