CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GlobalTriggerEvmReadoutRecord.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <iomanip>
20 #include <bitset>
21 #include <stdint.h>
22 
23 // user include files
24 
25 
28 
29 // constructors
31 {
32 
34  m_tcsWord = L1TcsWord();
35 
36  // reserve just one L1GtFdlWord
37  m_gtFdlWord.reserve(1);
38 
39 }
40 
42 {
43 
45  m_tcsWord = L1TcsWord();
46 
47  m_gtFdlWord.reserve(NumberBxInEvent);
48  m_gtFdlWord.assign(NumberBxInEvent, L1GtFdlWord());
49 
50  // min value of bxInEvent
51  int minBxInEvent = (NumberBxInEvent + 1)/2 - NumberBxInEvent;
52  //int maxBxInEvent = (NumberBxInEvent + 1)/2 - 1; // not needed
53 
54  // matrix index [0, NumberBxInEvent) -> bxInEvent [minBxInEvent, maxBxInEvent]
55  // warning: matrix index != bxInEvent
56  for (int iFdl = 0; iFdl < NumberBxInEvent; ++iFdl) {
57  int iBxInEvent = minBxInEvent + iFdl;
58  m_gtFdlWord[iFdl].setBxInEvent(iBxInEvent);
59  }
60 
61 }
62 
64  const int numberBxInEvent,
65  const int numberFdlBoards)
66 {
67 
68  // GTFE board
70 
71  // TCS board
72  m_tcsWord = L1TcsWord();
73 
74  // FDL board
75  if (numberFdlBoards > 0) {
76  m_gtFdlWord.reserve(numberBxInEvent);
77  }
78 
79 }
80 
81 
82 // copy constructor
85 {
86 
87  m_gtfeWord = result.m_gtfeWord;
88  m_tcsWord = result.m_tcsWord;
89  m_gtFdlWord = result.m_gtFdlWord;
90 
91 }
92 
93 // destructor
95 {
96 
97  // empty now
98 
99 }
100 
101 // assignment operator
104 {
105 
106  if ( this != &result ) {
107 
108  m_gtfeWord = result.m_gtfeWord;
109  m_tcsWord = result.m_tcsWord;
110  m_gtFdlWord = result.m_gtFdlWord;
111 
112  }
113 
114  return *this;
115 
116 }
117 
118 // equal operator
121 {
122 
123  if (m_gtfeWord != result.m_gtfeWord) {
124  return false;
125  }
126 
127  if (m_tcsWord != result.m_tcsWord) {
128  return false;
129  }
130 
131  if (m_gtFdlWord != result.m_gtFdlWord) {
132  return false;
133  }
134 
135  // all members identical
136  return true;
137 
138 }
139 
140 // unequal operator
143 {
144 
145  return !( result == *this);
146 
147 }
148 // methods
149 
150 
151 // get Global Trigger decision and the decision word
152 // general bxInEvent
153 const bool L1GlobalTriggerEvmReadoutRecord::decision(int bxInEventValue) const
154 {
155 
156  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
157  itBx != m_gtFdlWord.end(); ++itBx) {
158 
159  if ( (*itBx).bxInEvent() == bxInEventValue ) {
160  return (*itBx).finalOR();
161  }
162  }
163 
164  // if bunch cross not found, throw exception (action: SkipEvent)
165 
166  throw cms::Exception("NotFound")
167  << "\nError: requested GtFdlWord for bx = " << bxInEventValue << " does not exist.\n"
168  << "Can not return global decision for this bx!\n"
169  << std::endl;
170 
171  return false;
172 }
173 
175  int bxInEventValue) const
176 {
177 
178  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
179  itBx != m_gtFdlWord.end(); ++itBx) {
180 
181  if ( (*itBx).bxInEvent() == bxInEventValue ) {
182  return (*itBx).gtDecisionWord();
183  }
184  }
185 
186  // if bunch cross not found, throw exception (action: SkipEvent)
187 
188  throw cms::Exception("NotFound")
189  << "\nError: requested GtFdlWord for bx = " << bxInEventValue << " does not exist.\n"
190  << "Can not return decision word for this bx!\n"
191  << std::endl;
192 
193  DecisionWord dW; // empty; it does not arrive here
194  return dW;
195 }
196 
197 // bxInEvent = 0
199 {
200 
201  int bxInEventL1Accept = 0;
202  return decision(bxInEventL1Accept);
203 }
204 
205 const DecisionWord
207 {
208 
209  int bxInEventL1Accept = 0;
210  return decisionWord(bxInEventL1Accept);
211 }
212 
213 
214 // set global decision and the decision word
215 // general
216 void L1GlobalTriggerEvmReadoutRecord::setDecision(bool t, int bxInEventValue)
217 {
218 
219  for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin();
220  itBx != m_gtFdlWord.end(); ++itBx) {
221 
222  if ( (*itBx).bxInEvent() == bxInEventValue ) {
223  (*itBx).setFinalOR(static_cast<uint16_t> (t)); // TODO FIXME when manipulating partitions
224  }
225  }
226 
227  // if bunch cross not found, throw exception (action: SkipEvent)
228 
229  throw cms::Exception("NotFound")
230  << "\nError: requested GtFdlWord for bx = " << bxInEventValue << " does not exist.\n"
231  << "Can not set global decision for this bx!\n"
232  << std::endl;
233 
234 }
235 
237  const DecisionWord& decisionWordValue,
238  int bxInEventValue)
239 {
240 
241  for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin();
242  itBx != m_gtFdlWord.end(); ++itBx) {
243 
244  if ( (*itBx).bxInEvent() == bxInEventValue ) {
245  (*itBx).setGtDecisionWord (decisionWordValue);
246  }
247  }
248 
249  // if bunch cross not found, throw exception (action: SkipEvent)
250 
251  throw cms::Exception("NotFound")
252  << "\nError: requested GtFdlWord for bx = " << bxInEventValue << " does not exist.\n"
253  << "Can not set decision word for this bx!\n"
254  << std::endl;
255 
256 }
257 
258 // bxInEvent = 0
260 {
261 
262  int bxInEventL1Accept = 0;
263  setDecision(t, bxInEventL1Accept);
264 }
265 
267  const DecisionWord& decisionWordValue)
268 {
269 
270  int bxInEventL1Accept = 0;
271  setDecisionWord(decisionWordValue, bxInEventL1Accept);
272 
273 }
274 
275 // print global decision and algorithm decision word
277  std::ostream& myCout, int bxInEventValue) const
278 {
279 
280  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
281  itBx != m_gtFdlWord.end(); ++itBx) {
282 
283  if ( (*itBx).bxInEvent() == bxInEventValue ) {
284 
285  myCout << "\nL1 Global Trigger Record: " << std::endl;
286 
287  myCout
288  << "\t Bunch cross " << bxInEventValue
289  << std::endl
290  << "\t Global Decision = " << std::setw(5) << (*itBx).globalDecision()
291  << std::endl
292  << "\t Decision word (bitset style) = ";
293 
294  (*itBx).printGtDecisionWord(myCout);
295  }
296  }
297 
298  myCout << std::endl;
299 
300 }
301 
302 void L1GlobalTriggerEvmReadoutRecord::printGtDecision(std::ostream& myCout) const
303 {
304 
305  int bxInEventL1Accept = 0;
306  printGtDecision(myCout, bxInEventL1Accept);
307 
308 }
309 
310 // print technical trigger word (reverse order for vector<bool>)
312  std::ostream& myCout, int bxInEventValue
313 ) const
314 {
315 
316  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
317  itBx != m_gtFdlWord.end(); ++itBx) {
318 
319  if ( (*itBx).bxInEvent() == bxInEventValue ) {
320 
321  myCout << "\nL1 Global Trigger Record: " << std::endl;
322 
323  myCout
324  << "\t Bunch cross " << bxInEventValue
325  << std::endl
326  << "\t Technical Trigger word (bitset style) = ";
327 
328  (*itBx).printGtTechnicalTriggerWord(myCout);
329  }
330  }
331 
332  myCout << std::endl;
333 
334 }
335 
337 {
338 
339  int bxInEventL1Accept = 0;
340  printTechnicalTrigger(myCout, bxInEventL1Accept);
341 
342 }
343 
344 // get/set hardware-related words
345 
346 // get / set GTFE word (record) in the GT readout record
348 {
349 
350  return m_gtfeWord;
351 
352 }
353 
355 {
356 
357  m_gtfeWord = gtfeWordValue;
358 
359 }
360 
361 // get / set TCS word (record) in the GT readout record
363 {
364 
365  return m_tcsWord;
366 
367 }
368 
370 {
371 
372  m_tcsWord = tcsWordValue;
373 
374 }
375 
376 // get / set FDL word (record) in the GT readout record
378 {
379 
380  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
381  itBx != m_gtFdlWord.end(); ++itBx) {
382 
383  if ( (*itBx).bxInEvent() == bxInEventValue ) {
384  return (*itBx);
385  }
386  }
387 
388  // if bunch cross not found, throw exception (action: SkipEvent)
389 
390  throw cms::Exception("NotFound")
391  << "\nError: requested L1GtFdlWord for bx = " << bxInEventValue << " does not exist.\n"
392  << std::endl;
393 
394  // return empty record - actually does not arrive here
395  return L1GtFdlWord();
396 
397 }
398 
400 {
401 
402  int bxInEventL1Accept = 0;
403  return gtFdlWord(bxInEventL1Accept);
404 }
405 
407  const L1GtFdlWord& gtFdlWordValue, int bxInEventValue)
408 {
409 
410  // if a L1GtFdlWord exists for bxInEventValue, replace it
411  for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin();
412  itBx != m_gtFdlWord.end(); ++itBx) {
413 
414  if ( (*itBx).bxInEvent() == bxInEventValue ) {
415  *itBx = gtFdlWordValue;
416  LogDebug("L1GlobalTriggerEvmReadoutRecord")
417  << "Replacing L1GtFdlWord for bunch bx = " << bxInEventValue << "\n"
418  << std::endl;
419  return;
420  }
421  }
422 
423  // if bunch cross not found, throw exception (action: SkipEvent)
424  // all L1GtFdlWord are created in the record constructor for allowed bunch crosses
425 
426  throw cms::Exception("NotFound")
427  << "\nError: Cannot set L1GtFdlWord for bx = " << bxInEventValue
428  << std::endl;
429 
430 }
431 
433 {
434 
435  // just push back the new FDL block
436  m_gtFdlWord.push_back(gtFdlWordValue);
437 
438 }
439 
440 
441 // other methods
442 
443 // clear the record
445 {
446 
447  // TODO FIXME clear GTFE, TCS, FDL?
448 
449 }
450 
452 void L1GlobalTriggerEvmReadoutRecord::print(std::ostream& myCout) const
453 {
454 
455  myCout << "\n L1GlobalTriggerEvmReadoutRecord::print \n" << std::endl;
456 
457  m_gtfeWord.print(myCout);
458 
459  m_tcsWord.print(myCout);
460 
461  for (std::vector<L1GtFdlWord>::const_iterator itFdl = m_gtFdlWord.begin();
462  itFdl != m_gtFdlWord.end(); ++itFdl) {
463 
464  itFdl->print(myCout);
465 
466  }
467 
468 }
469 
470 
471 // output stream operator
472 std::ostream& operator<<(std::ostream& s, const L1GlobalTriggerEvmReadoutRecord& result)
473 {
474  // TODO FIXME put together all prints
475  s << "Not available yet - sorry";
476 
477  return s;
478 
479 }
#define LogDebug(id)
void printTechnicalTrigger(std::ostream &myCout, int bxInEventValue) const
print technical triggers
const L1GtfeExtWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
const L1TcsWord tcsWord() const
get / set TCS word (record) in the GT readout record
bool operator==(const L1GlobalTriggerEvmReadoutRecord &) const
equal operator
void print(std::ostream &myCout) const
pretty print the content of a L1GlobalTriggerEvmReadoutRecord
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
void setDecisionWord(const DecisionWord &decisionWordValue, int bxInEvent)
bool operator!=(const L1GlobalTriggerEvmReadoutRecord &) const
unequal operator
void print(std::ostream &myCout) const
pretty print the content of a L1TcsWord
Definition: L1TcsWord.cc:403
L1GlobalTriggerEvmReadoutRecord & operator=(const L1GlobalTriggerEvmReadoutRecord &)
assignment operator
std::vector< bool > DecisionWord
typedefs
void setDecision(bool t, int bxInEvent)
set global decision and the decision word
tuple result
Definition: query.py:137
void setGtFdlWord(const L1GtFdlWord &, int bxInEvent)
void printGtDecision(std::ostream &myCout, int bxInEventValue) const
print global decision and algorithm decision word
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeExtWord