CMS 3D CMS Logo

L1GtParametersConfigOnlineProd.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include "boost/lexical_cast.hpp"
20 
21 // user include files
23 
24 // constructor
27 
28  // empty
29 
30 }
31 
32 // destructor
34 
35  // empty
36 
37 }
38 
39 // public methods
40 
41 std::unique_ptr<L1GtParameters> L1GtParametersConfigOnlineProd::newObject(
42  const std::string& objectKey) {
43 
44  auto pL1GtParameters = std::make_unique<L1GtParameters>();
45 
46  // l1GtParameters: parameters in table GTFE_SETUP_FK
47 
48  const std::string gtSchema = "CMS_GT";
49 
50  // SQL query:
51  // SELECT EVM_INCLUDE_TCS,
52  // EVM_INCLUDE_FDL,
53  // DAQ_INCLUDE_FDL,
54  // DAQ_INCLUDE_PSB0,
55  // DAQ_INCLUDE_PSB1,
56  // DAQ_INCLUDE_PSB2,
57  // DAQ_INCLUDE_PSB3,
58  // DAQ_INCLUDE_PSB4,
59  // DAQ_INCLUDE_PSB5,
60  // DAQ_INCLUDE_PSB6,
61  // DAQ_INCLUDE_GMT,
62  // DAQ_INCLUDE_TIM,
63  // DAQ_NB_BC_PER_EVENT_FDL,
64  // BST_DATA_NB_BYTES
65  // FROM CMS_GT.GT_GTFE_SETUP
66  // WHERE GT_GTFE_SETUP.ID = objectKey
67 
68  std::vector<std::string> columns;
69  columns.push_back("EVM_INCLUDE_TCS");
70  columns.push_back("EVM_INCLUDE_FDL");
71  columns.push_back("DAQ_INCLUDE_FDL");
72  columns.push_back("DAQ_INCLUDE_PSB0");
73  columns.push_back("DAQ_INCLUDE_PSB1");
74  columns.push_back("DAQ_INCLUDE_PSB2");
75  columns.push_back("DAQ_INCLUDE_PSB3");
76  columns.push_back("DAQ_INCLUDE_PSB4");
77  columns.push_back("DAQ_INCLUDE_PSB5");
78  columns.push_back("DAQ_INCLUDE_PSB6");
79  columns.push_back("DAQ_INCLUDE_GMT");
80  columns.push_back("DAQ_INCLUDE_TIM");
81  columns.push_back("DAQ_NB_BC_PER_EVENT_FDL");
82  columns.push_back("DAQ_NB_BC_PER_EVENT_PSB0");
83  columns.push_back("DAQ_NB_BC_PER_EVENT_PSB1");
84  columns.push_back("DAQ_NB_BC_PER_EVENT_PSB2");
85  columns.push_back("DAQ_NB_BC_PER_EVENT_PSB3");
86  columns.push_back("DAQ_NB_BC_PER_EVENT_PSB4");
87  columns.push_back("DAQ_NB_BC_PER_EVENT_PSB5");
88  columns.push_back("DAQ_NB_BC_PER_EVENT_PSB6");
89  columns.push_back("DAQ_NB_BC_PER_EVENT_GMT");
90  columns.push_back("DAQ_NB_BC_PER_EVENT_TIM");
91  columns.push_back("BST_DATA_NB_BYTES");
92 
93 
95  columns, gtSchema, "GT_GTFE_SETUP", "GT_GTFE_SETUP.ID", m_omdsReader.singleAttribute(
96  objectKey));
97 
98  // check if query was successful
99  if (results.queryFailed()) {
100  edm::LogError("L1-O2O") << "Problem with L1GtParameters key:" << objectKey;
101  return pL1GtParameters;
102  }
103 
104  bool activeBoardsEvmTCS = false;
105  results.fillVariable("EVM_INCLUDE_TCS", activeBoardsEvmTCS);
106 
107  bool activeBoardsEvmFDL = false;
108  results.fillVariable("EVM_INCLUDE_FDL", activeBoardsEvmFDL);
109 
110  bool activeBoardsDaqFDL = false;
111  results.fillVariable("DAQ_INCLUDE_FDL", activeBoardsDaqFDL);
112 
113  bool activeBoardsDaqPSB0 = false;
114  results.fillVariable("DAQ_INCLUDE_PSB0", activeBoardsDaqPSB0);
115 
116  bool activeBoardsDaqPSB1 = false;
117  results.fillVariable("DAQ_INCLUDE_PSB1", activeBoardsDaqPSB1);
118 
119  bool activeBoardsDaqPSB2 = false;
120  results.fillVariable("DAQ_INCLUDE_PSB2", activeBoardsDaqPSB2);
121 
122  bool activeBoardsDaqPSB3 = false;
123  results.fillVariable("DAQ_INCLUDE_PSB3", activeBoardsDaqPSB3);
124 
125  bool activeBoardsDaqPSB4;
126  results.fillVariable("DAQ_INCLUDE_PSB4", activeBoardsDaqPSB4);
127 
128  bool activeBoardsDaqPSB5 = false;
129  results.fillVariable("DAQ_INCLUDE_PSB5", activeBoardsDaqPSB5);
130 
131  bool activeBoardsDaqPSB6;
132  results.fillVariable("DAQ_INCLUDE_PSB6", activeBoardsDaqPSB6);
133 
134  bool activeBoardsDaqGMT;
135  results.fillVariable("DAQ_INCLUDE_GMT", activeBoardsDaqGMT);
136 
137  bool activeBoardsDaqTIM = false;
138  results.fillVariable("DAQ_INCLUDE_TIM", activeBoardsDaqTIM);
139 
140  std::string totalBxInEventStr;
141  results.fillVariable("DAQ_NB_BC_PER_EVENT_FDL", totalBxInEventStr);
142 
143  //
144  std::string daqNrBxBoardStrFDL;
145  results.fillVariable("DAQ_NB_BC_PER_EVENT_FDL", daqNrBxBoardStrFDL);
146 
147  std::string daqNrBxBoardStrPSB0;
148  results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB0", daqNrBxBoardStrPSB0);
149 
150  std::string daqNrBxBoardStrPSB1;
151  results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB1", daqNrBxBoardStrPSB1);
152 
153  std::string daqNrBxBoardStrPSB2;
154  results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB2", daqNrBxBoardStrPSB2);
155 
156  std::string daqNrBxBoardStrPSB3;
157  results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB3", daqNrBxBoardStrPSB3);
158 
159  std::string daqNrBxBoardStrPSB4;
160  results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB4", daqNrBxBoardStrPSB4);
161 
162  std::string daqNrBxBoardStrPSB5;
163  results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB5", daqNrBxBoardStrPSB5);
164 
165  std::string daqNrBxBoardStrPSB6;
166  results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB6", daqNrBxBoardStrPSB6);
167 
168  std::string daqNrBxBoardStrGMT;
169  results.fillVariable("DAQ_NB_BC_PER_EVENT_GMT", daqNrBxBoardStrGMT);
170 
171  std::string daqNrBxBoardStrTIM;
172  results.fillVariable("DAQ_NB_BC_PER_EVENT_TIM", daqNrBxBoardStrTIM);
173 
174  std::string bstLengthBytesStr;
175  results.fillVariable("BST_DATA_NB_BYTES", bstLengthBytesStr);
176 
177  // fill the record
178 
179  // total Bx's in the event
180  int totalBxInEventVal = boost::lexical_cast<int>(totalBxInEventStr);
181  pL1GtParameters->setGtTotalBxInEvent(totalBxInEventVal);
182 
183  // FIXME: need board maps in DB, with active bit number...
184  // now, they are hardwired
185 
186  // get the mapping of boards to active bits
187 
188  // active boards in the L1 DAQ record & number of BXs per board
189  boost::uint16_t daqActiveBoardsVal = 0;
190 
191  int daqActiveBoardsLength = 16; // ...hard...
192  std::vector<int> daqNrBxBoard(daqActiveBoardsLength, 0);
193 
194  int iActiveBit = 0;
195  if (activeBoardsDaqFDL) {
196  daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
197  }
198  daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrFDL);
199 
200  iActiveBit = 1;
201  if (activeBoardsDaqPSB0) {
202  daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
203  }
204  daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB0);
205 
206  iActiveBit = 2;
207  if (activeBoardsDaqPSB1) {
208  daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
209  }
210  daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB1);
211 
212  iActiveBit = 3;
213  if (activeBoardsDaqPSB2) {
214  daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
215  }
216  daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB2);
217 
218  iActiveBit = 4;
219  if (activeBoardsDaqPSB3) {
220  daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
221  }
222  daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB3);
223 
224  iActiveBit = 5;
225  if (activeBoardsDaqPSB4) {
226  daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
227  }
228  daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB4);
229 
230  iActiveBit = 6;
231  if (activeBoardsDaqPSB5) {
232  daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
233  }
234  daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB5);
235 
236  iActiveBit = 7;
237  if (activeBoardsDaqPSB6) {
238  daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
239  }
240  daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB6);
241 
242  iActiveBit = 8;
243  if (activeBoardsDaqGMT) {
244  daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
245  }
246  daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrGMT);
247 
248  // FIXME fix TIM active bit
249  //iActiveBit = 9;
250  //if (activeBoardsDaqTIM) {
251  // daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
252  //}
253  //daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrTIM);
254 
255  // active boards in the L1 EVM record
256  boost::uint16_t evmActiveBoardsVal = 0;
257 
258  int evmActiveBoardsLength = 16; // ...hard...
259  std::vector<int> evmNrBxBoard(evmActiveBoardsLength, 0);
260 
261  iActiveBit = 0;
262  if (activeBoardsEvmTCS) {
263  evmActiveBoardsVal = evmActiveBoardsVal | ( 1 << iActiveBit );
264  }
265  // always 1 TCS payload - hardcoded
266  evmNrBxBoard.at(iActiveBit) = 1;
267 
268  iActiveBit = 1;
269  if (activeBoardsEvmFDL) {
270  evmActiveBoardsVal = evmActiveBoardsVal | ( 1 << iActiveBit );
271  }
272  // FDL must have the same length in EVM and DAQ
273  evmNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrFDL);
274 
275 
276  //
277  pL1GtParameters->setGtDaqActiveBoards(daqActiveBoardsVal);
278  pL1GtParameters->setGtEvmActiveBoards(evmActiveBoardsVal);
279  pL1GtParameters->setGtDaqNrBxBoard(daqNrBxBoard);
280  pL1GtParameters->setGtEvmNrBxBoard(evmNrBxBoard);
281 
282  //
283  unsigned int bstLengthBytesVal = boost::lexical_cast<unsigned int>(bstLengthBytesStr);
284  pL1GtParameters->setGtBstLengthBytes(bstLengthBytesVal);
285 
286  if (edm::isDebugEnabled()) {
287  std::ostringstream myCoutStream;
288  pL1GtParameters->print(myCoutStream);
289  LogTrace("L1GtParametersConfigOnlineProd")
290  << "\nThe following L1GtParameters record was read from OMDS: \n"
291  << myCoutStream.str() << "\n" << std::endl;
292  }
293 
294  return pL1GtParameters;
295 }
296 
bool isDebugEnabled()
std::unique_ptr< L1GtParameters > newObject(const std::string &objectKey) override
public methods
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:311
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:295
L1GtParametersConfigOnlineProd(const edm::ParameterSet &)
constructor
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
#define LogTrace(id)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60