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