CMS 3D CMS Logo

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