CMS 3D CMS Logo

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