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