CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GlobalTriggerReadoutRecord.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <iomanip>
20 
21 
22 // user include files
23 
24 
25 
26 
28 
29 // constructors
31 {
32 
33  // empty GTFE
35 
36  // no FDL, no PSB
37 }
38 
40 {
41 
43 
44  m_gtFdlWord.reserve(numberBxInEvent);
45  m_gtFdlWord.assign(numberBxInEvent, L1GtFdlWord());
46 
47  // min value of bxInEvent
48  int minBxInEvent = (numberBxInEvent + 1)/2 - numberBxInEvent;
49  //int maxBxInEvent = (numberBxInEvent + 1)/2 - 1; // not needed
50 
51  // matrix index [0, numberBxInEvent) -> bxInEvent [minBxInEvent, maxBxInEvent]
52  // warning: matrix index != bxInEvent
53  for (int iFdl = 0; iFdl < numberBxInEvent; ++iFdl) {
54  int iBxInEvent = minBxInEvent + iFdl;
55  m_gtFdlWord[iFdl].setBxInEvent(iBxInEvent);
56  }
57 
58  // PSBs
60  int totalNumberPsb = numberPsb*numberBxInEvent;
61 
62  m_gtPsbWord.reserve(totalNumberPsb);
63  m_gtPsbWord.assign(totalNumberPsb, L1GtPsbWord());
64 
65 
66 }
67 
69  const int numberBxInEvent,
70  const int numberFdlBoards,
71  const int numberPsbBoards)
72 {
73 
74  // GTFE board
76 
77  // FDL board
78  if (numberFdlBoards > 0) {
79  m_gtFdlWord.reserve(numberBxInEvent);
80  }
81 
82  // PSB boards
83  if (numberPsbBoards > 0) {
84  m_gtPsbWord.reserve(numberPsbBoards*numberBxInEvent);
85  }
86 
87 }
88 
89 // copy constructor
92 {
93 
94  m_gtfeWord = result.m_gtfeWord;
95  m_gtFdlWord = result.m_gtFdlWord;
96  m_gtPsbWord = result.m_gtPsbWord;
97 
99 
100 
101 }
102 
103 // destructor
105 {
106 
107  // empty now
108 
109 }
110 
111 // assignment operator
114 {
115 
116  if ( this != &result ) {
117 
118  m_gtfeWord = result.m_gtfeWord;
119  m_gtFdlWord = result.m_gtFdlWord;
120  m_gtPsbWord = result.m_gtPsbWord;
121 
123 
124  }
125 
126  return *this;
127 
128 }
129 
130 // equal operator
133 {
134 
135  if (m_gtfeWord != result.m_gtfeWord) {
136  return false;
137  }
138 
139  if (m_gtFdlWord != result.m_gtFdlWord) {
140  return false;
141  }
142 
143  if (m_gtPsbWord != result.m_gtPsbWord) {
144  return false;
145  }
146 
147  if (m_muCollRefProd != result.m_muCollRefProd) {
148  return false;
149  }
150 
151  // all members identical
152  return true;
153 
154 }
155 
156 // unequal operator
159 {
160 
161  return !( result == *this);
162 
163 }
164 // methods
165 
166 
167 // get Global Trigger decision
168 // general bxInEvent
169 const bool L1GlobalTriggerReadoutRecord::decision(int bxInEventValue) const
170 {
171 
172  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
173  itBx != m_gtFdlWord.end(); ++itBx) {
174 
175  if ( (*itBx).bxInEvent() == bxInEventValue ) {
176  return (*itBx).finalOR();
177  }
178  }
179 
180  // if bunch cross not found, throw exception (action: SkipEvent)
181  // TODO re-evaluate action
182 
183  // throw cms::Exception("NotFound")
184  LogTrace("L1GlobalTriggerReadoutRecord")
185  << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue
186  << " does not exist.\n"
187  << "Can not return global decision for this bx!\n"
188  << std::endl;
189 
190  return false;
191 }
192 
193 // bxInEvent = 0
195 {
196 
197  int bxInEventL1Accept = 0;
198  return decision(bxInEventL1Accept);
199 }
200 
201 // get final OR for all DAQ partitions
202 // general bxInEvent
204 {
205 
206  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
207  itBx != m_gtFdlWord.end(); ++itBx) {
208 
209  if ( (*itBx).bxInEvent() == bxInEventValue ) {
210  return (*itBx).finalOR();
211  }
212  }
213 
214  // if bunch cross not found, throw exception (action: SkipEvent)
215  // TODO re-evaluate action
216 
217  // throw cms::Exception("NotFound")
218  LogTrace("L1GlobalTriggerReadoutRecord")
219  << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue
220  << " does not exist.\n"
221  << "Can not return finalOR for this bx!\n"
222  << std::endl;
223 
224  return 0;
225 }
226 
227 // bxInEvent = 0
229 {
230 
231  int bxInEventL1Accept = 0;
232  return finalOR(bxInEventL1Accept);
233 }
234 
235 
236 // get Global Trigger decision word
237 
238 const DecisionWord &
240 {
241  const static DecisionWord emptyDecisionWord;
242 
243  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
244  itBx != m_gtFdlWord.end(); ++itBx) {
245 
246  if ( (*itBx).bxInEvent() == bxInEventValue ) {
247  return (*itBx).gtDecisionWord();
248  }
249  }
250 
251  // if bunch cross not found, throw exception (action: SkipEvent)
252  // TODO re-evaluate action
253 
254  // throw cms::Exception("NotFound")
255  LogTrace("L1GlobalTriggerReadoutRecord")
256  << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue
257  << " does not exist.\n"
258  << "Can not return decision word for this bx!\n"
259  << std::endl;
260 
261  return emptyDecisionWord;
262 }
263 
264 const DecisionWord &
266 {
267 
268  int bxInEventL1Accept = 0;
269  return decisionWord(bxInEventL1Accept);
270 }
271 
272 
273 
274 const TechnicalTriggerWord &
276  const static TechnicalTriggerWord emptyTechnicalTriggerWord;
277 
278  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
279  itBx != m_gtFdlWord.end(); ++itBx) {
280 
281  if ( (*itBx).bxInEvent() == bxInEventValue ) {
282  return (*itBx).gtTechnicalTriggerWord();
283  }
284  }
285 
286  // if bunch cross not found, throw exception (action: SkipEvent)
287  // TODO re-evaluate action
288 
289  // throw cms::Exception("NotFound")
290  LogTrace("L1GlobalTriggerReadoutRecord")
291  << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue
292  << " does not exist.\n"
293  << "Can not return technical trigger word for this bx!\n"
294  << std::endl;
295 
296  return emptyTechnicalTriggerWord;
297 }
298 
299 const TechnicalTriggerWord &
301 
302  int bxInEventL1Accept = 0;
303  return technicalTriggerWord(bxInEventL1Accept);
304 
305 }
306 
307 
308 // set global decision
309 // general
310 void L1GlobalTriggerReadoutRecord::setDecision(const bool& t, int bxInEventValue)
311 {
312 
313  for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin();
314  itBx != m_gtFdlWord.end(); ++itBx) {
315 
316  if ( (*itBx).bxInEvent() == bxInEventValue ) {
317 
318  // TODO FIXME when manipulating partitions
319  (*itBx).setFinalOR(static_cast<uint16_t> (t));
320  return;
321  }
322  }
323 
324  // if bunch cross not found, throw exception (action: SkipEvent)
325 
326  // throw cms::Exception("NotFound")
327  LogTrace("L1GlobalTriggerReadoutRecord")
328  << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue
329  << " does not exist.\n"
330  << "Can not set global decision for this bx!\n"
331  << std::endl;
332 
333 }
334 
335 // bxInEvent = 0
337 {
338 
339  int bxInEventL1Accept = 0;
340  setDecision(t, bxInEventL1Accept);
341 }
342 
343 // set decision word
345  const DecisionWord& decisionWordValue,
346  int bxInEventValue)
347 {
348 
349  for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin();
350  itBx != m_gtFdlWord.end(); ++itBx) {
351 
352  if ( (*itBx).bxInEvent() == bxInEventValue ) {
353 
354  (*itBx).setGtDecisionWord (decisionWordValue);
355  return;
356  }
357  }
358 
359  // if bunch cross not found, throw exception (action: SkipEvent)
360 
361  // throw cms::Exception("NotFound")
362  LogTrace("L1GlobalTriggerReadoutRecord")
363  << "\nError: requested GtFdlWord for bxInEvent = " << bxInEventValue
364  << " does not exist.\n"
365  << "Can not set decision word for this bx!\n"
366  << std::endl;
367 
368 }
369 
371  const DecisionWord& decisionWordValue)
372 {
373 
374  int bxInEventL1Accept = 0;
375  setDecisionWord(decisionWordValue, bxInEventL1Accept);
376 
377 }
378 
380  const TechnicalTriggerWord& ttWordValue, int bxInEventValue)
381 {
382 
383  for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin();
384  itBx != m_gtFdlWord.end(); ++itBx) {
385 
386  if ((*itBx).bxInEvent() == bxInEventValue) {
387 
388  (*itBx).setGtTechnicalTriggerWord(ttWordValue);
389  return;
390  }
391  }
392 
393  // if bunch cross not found, throw exception (action: SkipEvent)
394 
395  // throw cms::Exception("NotFound")
396  LogTrace("L1GlobalTriggerReadoutRecord")
397  << "\nError: requested GtFdlWord for bxInEvent = "
398  << bxInEventValue << " does not exist.\n"
399  << "Can not set technical trigger word for this bx!\n" << std::endl;
400 
401 }
402 
404  const TechnicalTriggerWord& ttWordValue)
405 {
406 
407  int bxInEventL1Accept = 0;
408  setTechnicalTriggerWord(ttWordValue, bxInEventL1Accept);
409 
410 }
411 
412 
413 
414 // print global decision and algorithm decision word
416  std::ostream& myCout, int bxInEventValue) const
417 {
418 
419  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
420  itBx != m_gtFdlWord.end(); ++itBx) {
421 
422  if ( (*itBx).bxInEvent() == bxInEventValue ) {
423 
424  myCout << "\nL1 Global Trigger Record: " << std::endl;
425 
426  myCout << " Bunch cross " << bxInEventValue
427  << std::endl
428  << " Global Decision = " << std::setw(5) << (*itBx).globalDecision()
429  << std::endl;
430 
431  (*itBx).printGtDecisionWord(myCout);
432 
433  }
434  }
435 
436  myCout << std::endl;
437 
438 }
439 
440 void L1GlobalTriggerReadoutRecord::printGtDecision(std::ostream& myCout) const
441 {
442 
443  int bxInEventL1Accept = 0;
444  printGtDecision(myCout, bxInEventL1Accept);
445 
446 }
447 
448 // print technical trigger word (reverse order for vector<bool>)
450  std::ostream& myCout, int bxInEventValue
451 ) const
452 {
453 
454  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
455  itBx != m_gtFdlWord.end(); ++itBx) {
456 
457  if ( (*itBx).bxInEvent() == bxInEventValue ) {
458 
459  myCout << "\nL1 Global Trigger Record: " << std::endl;
460 
461  myCout << " Bunch cross " << bxInEventValue
462  << std::endl;
463 
464  (*itBx).printGtTechnicalTriggerWord(myCout);
465  }
466  }
467 
468  myCout << std::endl;
469 
470 }
471 
473 {
474 
475  int bxInEventL1Accept = 0;
476  printTechnicalTrigger(myCout, bxInEventL1Accept);
477 
478 }
479 
480 
481 // get / set reference to L1MuGMTReadoutCollection
484 {
485 
486  return m_muCollRefProd;
487 }
488 
491 {
492 
494 
495 }
496 
498  const edm::RefProd<L1MuGMTReadoutCollection>& refProdMuGMT)
499 {
500 
501  m_muCollRefProd = refProdMuGMT;
502 
503 }
504 
505 
506 // get/set hardware-related words
507 
508 // get / set GTFE word (record) in the GT readout record
510 {
511 
512  return m_gtfeWord;
513 
514 }
515 
517 {
518 
519  m_gtfeWord = gtfeWordValue;
520 
521 }
522 
523 // get / set FDL word (record) in the GT readout record
525 {
526 
527  for (std::vector<L1GtFdlWord>::const_iterator itBx = m_gtFdlWord.begin();
528  itBx != m_gtFdlWord.end(); ++itBx) {
529 
530  if ( (*itBx).bxInEvent() == bxInEventValue ) {
531  return (*itBx);
532  }
533  }
534 
535  // if bunch cross not found, throw exception (action: SkipEvent)
536 
537  // throw cms::Exception("NotFound")
538  LogTrace("L1GlobalTriggerReadoutRecord")
539  << "\nError: requested L1GtFdlWord for bxInEvent = " << bxInEventValue
540  << " does not exist.\n"
541  << std::endl;
542 
543  // return empty record - actually does not arrive here
544  return L1GtFdlWord();
545 
546 }
547 
549 {
550 
551  int bxInEventL1Accept = 0;
552  return gtFdlWord(bxInEventL1Accept);
553 }
554 
556  const L1GtFdlWord& gtFdlWordValue, int bxInEventValue)
557 {
558 
559  // if a L1GtFdlWord exists for bxInEventValue, replace it
560  for (std::vector<L1GtFdlWord>::iterator itBx = m_gtFdlWord.begin();
561  itBx != m_gtFdlWord.end(); ++itBx) {
562 
563  if ( (*itBx).bxInEvent() == bxInEventValue ) {
564  *itBx = gtFdlWordValue;
565  LogTrace("L1GlobalTriggerReadoutRecord")
566  << "L1GlobalTriggerReadoutRecord: replacing L1GtFdlWord for bxInEvent = "
567  << bxInEventValue << "\n"
568  << std::endl;
569  return;
570  }
571  }
572 
573  // if bunch cross not found, throw exception (action: SkipEvent)
574  // all L1GtFdlWord are created in the record constructor for allowed bunch crosses
575 
576  // throw cms::Exception("NotFound")
577  LogTrace("L1GlobalTriggerReadoutRecord")
578  << "\nError: Cannot set L1GtFdlWord for bxInEvent = " << bxInEventValue
579  << std::endl;
580 
581 }
582 
584 {
585 
586  // just push back the new FDL block
587  m_gtFdlWord.push_back(gtFdlWordValue);
588 
589 }
590 
591 
592 // get / set PSB word (record) in the GT readout record
594  cms_uint16_t boardIdValue, int bxInEventValue) const
595 {
596 
597  for (std::vector<L1GtPsbWord>::const_iterator itBx = m_gtPsbWord.begin();
598  itBx != m_gtPsbWord.end(); ++itBx) {
599 
600  if (
601  ((*itBx).bxInEvent() == bxInEventValue) &&
602  ((*itBx).boardId() == boardIdValue)) {
603 
604  return (*itBx);
605 
606  }
607  }
608 
609  // if bunch cross or boardId not found, throw exception (action: SkipEvent)
610 
611  // throw cms::Exception("NotFound")
612  LogTrace("L1GlobalTriggerReadoutRecord")
613  << "\nError: requested L1GtPsbWord for boardId = "
614  << std::hex << boardIdValue << std::dec
615  << " and bxInEvent = " << bxInEventValue
616  << " does not exist.\n"
617  << std::endl;
618 
619  // return empty record - actually does not arrive here
620  return L1GtPsbWord();
621 
622 }
623 
625 {
626 
627  int bxInEventL1Accept = 0;
628  return gtPsbWord(boardIdValue, bxInEventL1Accept);
629 }
630 
632  const L1GtPsbWord& gtPsbWordValue, cms_uint16_t boardIdValue, int bxInEventValue)
633 {
634 
635  // if a L1GtPsbWord with the same bxInEventValue and boardIdValue exists, replace it
636  for (std::vector<L1GtPsbWord>::iterator itBx = m_gtPsbWord.begin();
637  itBx != m_gtPsbWord.end(); ++itBx) {
638 
639  if (
640  ((*itBx).bxInEvent() == bxInEventValue) &&
641  ((*itBx).boardId() == boardIdValue)) {
642 
643  *itBx = gtPsbWordValue;
644 
645  LogTrace("L1GlobalTriggerReadoutRecord")
646  << "\nL1GlobalTriggerReadoutRecord: replacing L1GtPsbWord with boardId = "
647  << std::hex << boardIdValue << std::dec
648  << " and bxInEvent = " << bxInEventValue
649  << "\n"
650  << std::endl;
651  return;
652  }
653  }
654 
655  // otherwise, write in the first empty PSB
656  // empty means: PSB with bxInEvent = 0, boardId = 0
657 
658  for (std::vector<L1GtPsbWord>::iterator itBx = m_gtPsbWord.begin();
659  itBx != m_gtPsbWord.end(); ++itBx) {
660 
661  if (
662  ((*itBx).bxInEvent() == 0) &&
663  ((*itBx).boardId() == 0)) {
664 
665  *itBx = gtPsbWordValue;
666 
667  LogTrace("L1GlobalTriggerReadoutRecord")
668  << "\nL1GlobalTriggerReadoutRecord: filling an empty L1GtPsbWord"
669  << " for PSB with boardId = "
670  << std::hex << boardIdValue << std::dec
671  << " and bxInEvent = " << bxInEventValue
672  << "\n"
673  << std::endl;
674  return;
675  }
676  }
677 
678  // no PSB to replace, no empty PSB: throw exception (action: SkipEvent)
679  // all L1GtPsbWord are created in the record constructor
680 
681  // throw cms::Exception("NotFound")
682  LogTrace("L1GlobalTriggerReadoutRecord")
683  << "\nError: Cannot set L1GtPsbWord for PSB with boardId = "
684  << std::hex << boardIdValue << std::dec
685  << " and bxInEvent = " << bxInEventValue
686  << "\n No PSB to replace and no empty PSB found!\n"
687  << std::endl;
688 
689 
690 }
691 
693  const L1GtPsbWord& gtPsbWordValue, cms_uint16_t boardIdValue)
694 {
695 
696  int bxInEventL1Accept = 0;
697  setGtPsbWord(gtPsbWordValue, boardIdValue, bxInEventL1Accept);
698 
699 }
700 
702 {
703  // just push back the new PSB block
704  m_gtPsbWord.push_back(gtPsbWordValue);
705 
706 }
707 
708 // other methods
709 
710 // clear the record
711 // it resets the content of the members only!
713 {
714 
715  m_gtfeWord.reset();
716 
717  for (std::vector<L1GtFdlWord>::iterator itFdl = m_gtFdlWord.begin();
718  itFdl != m_gtFdlWord.end(); ++itFdl) {
719 
720  itFdl->reset();
721 
722  }
723 
724  for (std::vector<L1GtPsbWord>::iterator itPsb = m_gtPsbWord.begin();
725  itPsb != m_gtPsbWord.end(); ++itPsb) {
726 
727  itPsb->reset();
728 
729  }
730 
731  // TODO FIXME reset m_muCollRefProd
732 
733 }
734 
736 void L1GlobalTriggerReadoutRecord::print(std::ostream& myCout) const
737 {
738 
739  myCout << "\n L1GlobalTriggerReadoutRecord::print \n" << std::endl;
740 
741  m_gtfeWord.print(myCout);
742 
743  for (std::vector<L1GtFdlWord>::const_iterator itFdl = m_gtFdlWord.begin();
744  itFdl != m_gtFdlWord.end(); ++itFdl) {
745 
746  itFdl->print(myCout);
747 
748  }
749 
750  for (std::vector<L1GtPsbWord>::const_iterator itPsb = m_gtPsbWord.begin();
751  itPsb != m_gtPsbWord.end(); ++itPsb) {
752 
753  itPsb->print(myCout);
754 
755  }
756 
757  // FIXME add L1MuGMTReadoutCollection printing
758  // edm::RefProd<L1MuGMTReadoutCollection> m_muCollRefProd;
759 
760 
761 
762 
763 }
764 
765 // output stream operator
766 std::ostream& operator<<(std::ostream& s, const L1GlobalTriggerReadoutRecord& result)
767 {
768  // TODO FIXME put together all prints
769  s << "Not available yet - sorry";
770 
771  return s;
772 
773 }
void setDecision(const bool &t, int bxInEventValue)
set global decision, decision word and technical trigger word
void print(std::ostream &myCout) const
pretty print the content of a L1GlobalTriggerReadoutRecord
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeWord
Definition: L1GtfeWord.cc:321
const DecisionWord & decisionWord() const
const L1GtfeWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
void setMuCollectionRefProd(edm::Handle< L1MuGMTReadoutCollection > &)
bool operator==(const L1GlobalTriggerReadoutRecord &) const
equal operator
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
static const int NumberPsbBoards
number of PSB boards in GT
void printGtDecision(std::ostream &myCout, int bxInEventValue) const
print global decision and algorithm decision word
void setGtFdlWord(const L1GtFdlWord &, int bxInEventValue)
virtual void reset()
reset the content of a L1GtfeWord
Definition: L1GtfeWord.cc:306
std::vector< L1GtPsbWord > m_gtPsbWord
void setDecisionWord(const DecisionWord &decisionWordValue, int bxInEventValue)
std::vector< bool > DecisionWord
typedefs
void setTechnicalTriggerWord(const TechnicalTriggerWord &ttWordValue, int bxInEventValue)
tuple result
Definition: query.py:137
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
unsigned short cms_uint16_t
Definition: typedefs.h:13
edm::RefProd< L1MuGMTReadoutCollection > m_muCollRefProd
const L1GtPsbWord gtPsbWord(cms_uint16_t boardIdValue, int bxInEventValue) const
get / set PSB word (record) in the GT readout record
std::vector< L1GtFdlWord > m_gtFdlWord
#define LogTrace(id)
const edm::RefProd< L1MuGMTReadoutCollection > muCollectionRefProd() const
get / set reference to L1MuGMTReadoutCollection
void setGtPsbWord(const L1GtPsbWord &, cms_uint16_t boardIdValue, int bxInEventValue)
const TechnicalTriggerWord & technicalTriggerWord() const
bool operator!=(const L1GlobalTriggerReadoutRecord &) const
unequal operator
void printTechnicalTrigger(std::ostream &myCout, int bxInEventValue) const
print technical triggers
L1GlobalTriggerReadoutRecord & operator=(const L1GlobalTriggerReadoutRecord &)
assignment operator