CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GlobalTrigger.cc
Go to the documentation of this file.
1 
17 // this class header
19 
20 // system include files
21 #include <memory>
22 #include <iostream>
23 #include <iomanip>
24 #include <algorithm>
25 
26 #include <boost/cstdint.hpp>
27 
28 // user include files
29 //#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
33 
35 
39 
46 
50 
53 
56 
61 
65 
69 
72 
76 
80 
83 
86 
87 
88 
89 // constructors
90 
92  m_muGmtInputTag(parSet.getParameter<edm::InputTag> ("GmtInputTag")),
93  m_caloGctInputTag(parSet.getParameter<edm::InputTag> ("GctInputTag")),
94  m_castorInputTag(parSet.getParameter<edm::InputTag> ("CastorInputTag")),
95  m_technicalTriggersInputTags(parSet.getParameter<std::vector<edm::InputTag> > (
96  "TechnicalTriggersInputTags")),
97  m_produceL1GtDaqRecord(parSet.getParameter<bool> ("ProduceL1GtDaqRecord")),
98  m_produceL1GtEvmRecord(parSet.getParameter<bool> ("ProduceL1GtEvmRecord")),
99  m_produceL1GtObjectMapRecord(parSet.getParameter<bool> ("ProduceL1GtObjectMapRecord")),
100  m_writePsbL1GtDaqRecord(parSet.getParameter<bool> ("WritePsbL1GtDaqRecord")),
101  m_readTechnicalTriggerRecords(parSet.getParameter<bool> ("ReadTechnicalTriggerRecords")),
102  m_emulateBxInEvent(parSet.getParameter<int> ("EmulateBxInEvent")),
103  m_recordLength(parSet.getParameter<std::vector<int> > ("RecordLength")),
104  m_alternativeNrBxBoardDaq(parSet.getParameter<unsigned int> ("AlternativeNrBxBoardDaq")),
105  m_alternativeNrBxBoardEvm(parSet.getParameter<unsigned int> ("AlternativeNrBxBoardEvm")),
106  m_psBstLengthBytes(parSet.getParameter<int> ("BstLengthBytes")),
107  m_verbosity(parSet.getUntrackedParameter<int>("Verbosity", 0)),
108  m_isDebugEnabled(edm::isDebugEnabled())
109 
110 
111 {
112 
113  if (m_verbosity && m_isDebugEnabled) {
114 
115  LogTrace("L1GlobalTrigger")
116  << "\nInput tag for muon collection from GMT: " << m_muGmtInputTag
117  << "\nInput tag for calorimeter collections from GCT: " << m_caloGctInputTag
118  << "\nInput tag for CASTOR record: " << m_castorInputTag
119  << "\nInput tag for technical triggers: "
120  << std::endl;
121 
122  // loop over all producers of technical trigger records
123  for (std::vector<edm::InputTag>::const_iterator it = m_technicalTriggersInputTags.begin(); it
124  != m_technicalTriggersInputTags.end(); it++) {
125  LogTrace("L1GlobalTrigger") << "\n " << ( *it ) << std::endl;
126  }
127 
128  LogTrace("L1GlobalTrigger")
129  << "\nProduce the L1 GT DAQ readout record: " << m_produceL1GtDaqRecord
130  << "\nProduce the L1 GT EVM readout record: " << m_produceL1GtEvmRecord
131  << "\nProduce the L1 GT Object Map record: " << m_produceL1GtObjectMapRecord
132  << " \n"
133  << "\nWrite Psb content to L1 GT DAQ Record: " << m_writePsbL1GtDaqRecord
134  << " \n"
135  << "\nRead technical trigger records: " << m_readTechnicalTriggerRecords
136  << " \n"
137  << "\nNumber of BxInEvent to be emulated: " << m_emulateBxInEvent
138  << "\nNumber of BXs corresponding to alternative 0: " << m_recordLength.at(0)
139  << "\nNumber of BXs corresponding to alternative 1: " << m_recordLength.at(1)
140  << " \n"
141  << "\nAlternative for number of BX in GT DAQ record: 0x" << std::hex
143  << "\nAlternative for number of BX in GT EVM record: 0x" << std::hex
144  << m_alternativeNrBxBoardEvm << std::dec
145  << " \n"
146  << "\nLength of BST message [bytes]: " << m_psBstLengthBytes
147  << "\n"
148  << std::endl;
149  }
150 
151 
152  if ( ( m_emulateBxInEvent > 0 ) && ( ( m_emulateBxInEvent % 2 ) == 0 )) {
154 
155  if (m_verbosity) {
156  edm::LogWarning("L1GlobalTrigger")
157  << "\nWARNING: Number of bunch crossing to be emulated rounded to: "
158  << m_emulateBxInEvent << "\n The number must be an odd number!\n"
159  << std::endl;
160  }
161  }
162 
163  int requiredRecordLength = std::max(m_recordLength.at(0), m_recordLength.at(1));
164  if ((m_emulateBxInEvent >= 0) && (m_emulateBxInEvent < requiredRecordLength) ) {
165 
166  m_emulateBxInEvent = requiredRecordLength;
167 
168  if (m_verbosity) {
169  edm::LogWarning("L1GlobalTrigger")
170  << "\nWARNING: Number of bunch crossing required to be emulated ( "
171  << m_emulateBxInEvent << " BX) smaller as required in RecordLength:"
172  << "\n Number of BXs corresponding to alternative 0: " << m_recordLength.at(0)
173  << "\n Number of BXs corresponding to alternative 1: " << m_recordLength.at(1)
174  << "\nEmulating " << requiredRecordLength << " BX!"
175  << "\n"
176  << std::endl;
177  }
178 
179  }
180 
181  // register products
183  produces<L1GlobalTriggerReadoutRecord>();
184  }
185 
187  produces<L1GlobalTriggerEvmReadoutRecord>();
188  }
189 
191  produces<L1GlobalTriggerObjectMapRecord>();
192  }
193 
194  // create new PSBs
195  m_gtPSB = new L1GlobalTriggerPSB();
197 
198  // create new GTL
199  m_gtGTL = new L1GlobalTriggerGTL();
201 
202  // create new FDL
203  m_gtFDL = new L1GlobalTriggerFDL();
205 
206  // initialize cached IDs
207 
208  //
209  m_l1GtStableParCacheID = 0ULL;
210 
214 
215  m_nrL1Mu = 0;
216 
217  m_nrL1NoIsoEG = 0;
218  m_nrL1IsoEG = 0;
219 
220  m_nrL1CenJet = 0;
221  m_nrL1ForJet = 0;
222  m_nrL1TauJet = 0;
223 
224  m_nrL1JetCounts = 0;
225 
228 
229  //
230  m_l1GtParCacheID = 0ULL;
231 
232  m_totalBxInEvent = 0;
233 
236  m_bstLengthBytes = 0;
237 
238  //
239  m_l1GtBMCacheID = 0ULL;
240 
241  //
242  m_l1GtPfAlgoCacheID = 0ULL;
243  m_l1GtPfTechCacheID = 0ULL;
244 
245  m_l1GtTmAlgoCacheID = 0ULL;
246  m_l1GtTmTechCacheID = 0ULL;
247 
250 
251 }
252 
253 // destructor
255 {
256 
257  delete m_gtPSB;
258  delete m_gtGTL;
259  delete m_gtFDL;
260 }
261 
262 // member functions
263 
264 // method called to produce the data
266 {
267 
268  // process event iEvent
269 
270  // get / update the stable parameters from the EventSetup
271  // local cache & check on cacheIdentifier
272 
273  unsigned long long l1GtStableParCacheID =
274  evSetup.get<L1GtStableParametersRcd>().cacheIdentifier();
275 
276  if (m_l1GtStableParCacheID != l1GtStableParCacheID) {
277 
279  evSetup.get< L1GtStableParametersRcd >().get( l1GtStablePar );
280  m_l1GtStablePar = l1GtStablePar.product();
281 
282  // number of physics triggers
284 
285  // number of technical triggers
287 
288  // number of DAQ partitions
289  m_numberDaqPartitions = 8; // FIXME add it to stable parameters
290 
291  // number of objects of each type
292  m_nrL1Mu = static_cast<int> (m_l1GtStablePar->gtNumberL1Mu());
293 
294  m_nrL1NoIsoEG = static_cast<int> (m_l1GtStablePar->gtNumberL1NoIsoEG());
295  m_nrL1IsoEG = static_cast<int> (m_l1GtStablePar->gtNumberL1IsoEG());
296 
297  m_nrL1CenJet = static_cast<int> (m_l1GtStablePar->gtNumberL1CenJet());
298  m_nrL1ForJet = static_cast<int> (m_l1GtStablePar->gtNumberL1ForJet());
299  m_nrL1TauJet = static_cast<int> (m_l1GtStablePar->gtNumberL1TauJet());
300 
301  m_nrL1JetCounts = static_cast<int> (m_l1GtStablePar->gtNumberL1JetCounts());
302 
303  // ... the rest of the objects are global
304 
307 
308  // (re)initialize L1GlobalTriggerGTL
310 
311  // (re)initialize L1GlobalTriggerPSB
315 
316  //
317  m_l1GtStableParCacheID = l1GtStableParCacheID;
318 
319  }
320 
321  // get / update the parameters from the EventSetup
322  // local cache & check on cacheIdentifier
323 
324  unsigned long long l1GtParCacheID = evSetup.get<L1GtParametersRcd>().cacheIdentifier();
325 
326  if (m_l1GtParCacheID != l1GtParCacheID) {
327 
329  evSetup.get< L1GtParametersRcd >().get( l1GtPar );
330  m_l1GtPar = l1GtPar.product();
331 
332  // total number of Bx's in the event coming from EventSetup
334 
335  // active boards in L1 GT DAQ record and in L1 GT EVM record
338 
341 
342 
343  m_l1GtParCacheID = l1GtParCacheID;
344 
345  }
346 
347  // negative value: emulate TotalBxInEvent as given in EventSetup
348  if (m_emulateBxInEvent < 0) {
350  }
351 
352  int minBxInEvent = (m_emulateBxInEvent + 1)/2 - m_emulateBxInEvent;
353  int maxBxInEvent = (m_emulateBxInEvent + 1)/2 - 1;
354 
355  int recordLength0 = m_recordLength.at(0);
356  int recordLength1 = m_recordLength.at(1);
357 
358  if ((recordLength0 < 0) || (recordLength1 < 0) ) {
359 
360  // take them from event setup
361  // FIXME implement later - temporary solution
362 
363  recordLength0 = m_emulateBxInEvent;
364  recordLength1 = m_emulateBxInEvent;
365 
366  }
367 
368 
369 
370  if (m_verbosity) {
371 
372  LogDebug("L1GlobalTrigger")
373  << "\nTotal number of BX to emulate in the GT readout record: "
374  << m_emulateBxInEvent << " = " << "[" << minBxInEvent << ", " << maxBxInEvent
375  << "] BX\n"
376  << "\nNumber of BX for alternative 0: " << recordLength0
377  << "\nNumber of BX for alternative 1: " << recordLength1
378  << "\nActive boards in L1 GT DAQ record (hex format) = " << std::hex
379  << std::setw(sizeof(m_activeBoardsGtDaq) * 2) << std::setfill('0')
380  << m_activeBoardsGtDaq << std::dec << std::setfill(' ')
381  << "\nActive boards in L1 GT EVM record (hex format) = " << std::hex
382  << std::setw(sizeof(m_activeBoardsGtEvm) * 2) << std::setfill('0')
383  << m_activeBoardsGtEvm << std::dec << std::setfill(' ') << "\n"
384  << std::endl;
385  }
386 
387  // get / update the board maps from the EventSetup
388  // local cache & check on cacheIdentifier
389 
390  typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
391 
392  unsigned long long l1GtBMCacheID = evSetup.get<L1GtBoardMapsRcd>().cacheIdentifier();
393 
394  if (m_l1GtBMCacheID != l1GtBMCacheID) {
395 
397  evSetup.get< L1GtBoardMapsRcd >().get( l1GtBM );
398  m_l1GtBM = l1GtBM.product();
399 
400  m_l1GtBMCacheID = l1GtBMCacheID;
401 
402  }
403 
404  // TODO need changes in CondFormats to cache the maps
405  const std::vector<L1GtBoard>& boardMaps = m_l1GtBM->gtBoardMaps();
406 
407  // get / update the prescale factors from the EventSetup
408  // local cache & check on cacheIdentifier
409 
410  unsigned long long l1GtPfAlgoCacheID =
411  evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
412 
413  if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
414 
416  evSetup.get< L1GtPrescaleFactorsAlgoTrigRcd >().get( l1GtPfAlgo );
417  m_l1GtPfAlgo = l1GtPfAlgo.product();
418 
420 
421  m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
422 
423  }
424 
425  unsigned long long l1GtPfTechCacheID =
426  evSetup.get<L1GtPrescaleFactorsTechTrigRcd>().cacheIdentifier();
427 
428  if (m_l1GtPfTechCacheID != l1GtPfTechCacheID) {
429 
431  evSetup.get< L1GtPrescaleFactorsTechTrigRcd >().get( l1GtPfTech );
432  m_l1GtPfTech = l1GtPfTech.product();
433 
435 
436  m_l1GtPfTechCacheID = l1GtPfTechCacheID;
437 
438  }
439 
440 
441  // get / update the trigger mask from the EventSetup
442  // local cache & check on cacheIdentifier
443 
444  unsigned long long l1GtTmAlgoCacheID =
445  evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
446 
447  if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
448 
450  evSetup.get< L1GtTriggerMaskAlgoTrigRcd >().get( l1GtTmAlgo );
451  m_l1GtTmAlgo = l1GtTmAlgo.product();
452 
454 
455  m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
456 
457  }
458 
459 
460  unsigned long long l1GtTmTechCacheID =
461  evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
462 
463  if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
464 
466  evSetup.get< L1GtTriggerMaskTechTrigRcd >().get( l1GtTmTech );
467  m_l1GtTmTech = l1GtTmTech.product();
468 
470 
471  m_l1GtTmTechCacheID = l1GtTmTechCacheID;
472 
473  }
474 
475  unsigned long long l1GtTmVetoAlgoCacheID =
476  evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().cacheIdentifier();
477 
478  if (m_l1GtTmVetoAlgoCacheID != l1GtTmVetoAlgoCacheID) {
479 
480  edm::ESHandle< L1GtTriggerMask > l1GtTmVetoAlgo;
481  evSetup.get< L1GtTriggerMaskVetoAlgoTrigRcd >().get( l1GtTmVetoAlgo );
482  m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
483 
485 
486  m_l1GtTmVetoAlgoCacheID = l1GtTmVetoAlgoCacheID;
487 
488  }
489 
490 
491  unsigned long long l1GtTmVetoTechCacheID =
492  evSetup.get<L1GtTriggerMaskVetoTechTrigRcd>().cacheIdentifier();
493 
494  if (m_l1GtTmVetoTechCacheID != l1GtTmVetoTechCacheID) {
495 
496  edm::ESHandle< L1GtTriggerMask > l1GtTmVetoTech;
497  evSetup.get< L1GtTriggerMaskVetoTechTrigRcd >().get( l1GtTmVetoTech );
498  m_l1GtTmVetoTech = l1GtTmVetoTech.product();
499 
501 
502  m_l1GtTmVetoTechCacheID = l1GtTmVetoTechCacheID;
503 
504  }
505 
506  // loop over blocks in the GT DAQ record receiving data, count them if they are active
507  // all board type are defined in CondFormats/L1TObjects/L1GtFwd
508  // enum L1GtBoardType { GTFE, FDL, PSB, GMT, TCS, TIM };
509  // &
510  // set the active flag for each object type received from GMT and GCT
511  // all objects in the GT system are defined in enum L1GtObject from
512  // DataFormats/L1Trigger/L1GlobalTriggerReadoutSetupFwd
513 
514  int daqNrGtfeBoards = 0;
515 
516  int daqNrFdlBoards = 0;
517  int daqNrPsbBoards = 0;
518  int daqNrGmtBoards = 0;
519  int daqNrTcsBoards = 0;
520  int daqNrTimBoards = 0;
521 
522  //
523  bool receiveMu = false;
524  bool receiveNoIsoEG = false;
525  bool receiveIsoEG = false;
526  bool receiveCenJet = false;
527  bool receiveForJet = false;
528  bool receiveTauJet = false;
529  bool receiveETM = false;
530  bool receiveETT = false;
531  bool receiveHTT = false;
532  bool receiveHTM = false;
533  bool receiveJetCounts = false;
534  bool receiveHfBitCounts = false;
535  bool receiveHfRingEtSums = false;
536 
537  bool receiveCastor = false;
538  bool receiveBptx = false;
539  bool receiveExternal = false;
540 
541  bool receiveTechTr = false;
542 
543  for (CItBoardMaps
544  itBoard = boardMaps.begin();
545  itBoard != boardMaps.end(); ++itBoard) {
546 
547  int iPosition = itBoard->gtPositionDaqRecord();
548  if (iPosition > 0) {
549 
550  int iActiveBit = itBoard->gtBitDaqActiveBoards();
551  bool activeBoard = false;
552 
553  if (iActiveBit >= 0) {
554  activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
555  }
556 
557  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit < 0)
558  // in the record and ActiveBoardsMap, and active
559  if ((iActiveBit < 0) || activeBoard) {
560 
561  switch (itBoard->gtBoardType()) {
562 
563  case GTFE: {
564  daqNrGtfeBoards++;
565  }
566 
567  break;
568  case FDL: {
569  daqNrFdlBoards++;
570  }
571 
572  break;
573  case PSB: {
574  daqNrPsbBoards++;
575 
576  // get the objects coming to this PSB
577  std::vector<L1GtPsbQuad> quadInPsb = itBoard->gtQuadInPsb();
578  for (std::vector<L1GtPsbQuad>::const_iterator
579  itQuad = quadInPsb.begin();
580  itQuad != quadInPsb.end(); ++itQuad) {
581 
582  switch (*itQuad) {
583 
584  case TechTr: {
585  receiveTechTr = true;
586  }
587 
588  break;
589  case NoIsoEGQ: {
590  receiveNoIsoEG = true;
591  }
592 
593  break;
594  case IsoEGQ: {
595  receiveIsoEG = true;
596  }
597 
598  break;
599  case CenJetQ: {
600  receiveCenJet = true;
601  }
602 
603  break;
604  case ForJetQ: {
605  receiveForJet = true;
606  }
607 
608  break;
609  case TauJetQ: {
610  receiveTauJet = true;
611  }
612 
613  break;
614  case ESumsQ: {
615  receiveETM = true;
616  receiveETT = true;
617  receiveHTT = true;
618  receiveHTM = true;
619  }
620 
621  break;
622  case JetCountsQ: {
623  receiveJetCounts = true;
624  }
625 
626  break;
627  case CastorQ: {
628  receiveCastor = true;
629  }
630 
631  break;
632  case BptxQ: {
633  receiveBptx = true;
634  }
635 
636  break;
637  case GtExternalQ: {
638  receiveExternal = true;
639  }
640 
641  break;
642  case HfQ: {
643  receiveHfBitCounts = true;
644  receiveHfRingEtSums = true;
645  }
646 
647  break;
648  // FIXME add MIP/Iso bits
649  default: {
650  // do nothing
651  }
652 
653  break;
654  }
655 
656  }
657 
658  }
659 
660  break;
661  case GMT: {
662  daqNrGmtBoards++;
663  receiveMu = true;
664  }
665 
666  break;
667  case TCS: {
668  daqNrTcsBoards++;
669  }
670 
671  break;
672  case TIM: {
673  daqNrTimBoards++;
674  }
675 
676  break;
677  default: {
678  // do nothing, all blocks are given in GtBoardType enum
679  }
680 
681  break;
682  }
683  }
684  }
685 
686  }
687 
688  // produce the L1GlobalTriggerReadoutRecord now, after we found how many
689  // BxInEvent the record has and how many boards are active
690  std::auto_ptr<L1GlobalTriggerReadoutRecord> gtDaqReadoutRecord(
692  m_emulateBxInEvent, daqNrFdlBoards, daqNrPsbBoards) );
693 
694 
695  // * produce the L1GlobalTriggerEvmReadoutRecord
696  std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord(
698  // daqNrFdlBoards OK, just reserve memory at this point
699 
700  // * produce the L1GlobalTriggerObjectMapRecord
701  std::auto_ptr<L1GlobalTriggerObjectMapRecord> gtObjectMapRecord(
703 
704 
705  // fill the boards not depending on the BxInEvent in the L1 GT DAQ record
706  // GMT, PSB and FDL depend on BxInEvent
707 
708  // fill in emulator the same bunch crossing (12 bits - hardwired number of bits...)
709  // and the same local bunch crossing for all boards
710  int bxCross = iEvent.bunchCrossing();
711  boost::uint16_t bxCrossHw = 0;
712  if ((bxCross & 0xFFF) == bxCross) {
713  bxCrossHw = static_cast<boost::uint16_t> (bxCross);
714  }
715  else {
716  bxCrossHw = 0; // Bx number too large, set to 0!
717  if (m_verbosity) {
718 
719  LogDebug("L1GlobalTrigger")
720  << "\nBunch cross number [hex] = " << std::hex << bxCross
721  << "\n larger than 12 bits. Set to 0! \n" << std::dec
722  << std::endl;
723  }
724  }
725 
726 
728 
729  for (CItBoardMaps
730  itBoard = boardMaps.begin();
731  itBoard != boardMaps.end(); ++itBoard) {
732 
733  int iPosition = itBoard->gtPositionDaqRecord();
734  if (iPosition > 0) {
735 
736  int iActiveBit = itBoard->gtBitDaqActiveBoards();
737  bool activeBoard = false;
738 
739  if (iActiveBit >= 0) {
740  activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
741  }
742 
743  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit < 0)
744  // in the record and ActiveBoardsMap, and active
745  if ((iActiveBit < 0) || activeBoard) {
746 
747  switch (itBoard->gtBoardType()) {
748 
749  case GTFE: {
750  L1GtfeWord gtfeWordValue;
751 
752  gtfeWordValue.setBoardId( itBoard->gtBoardId() );
753 
754  // cast int to boost::uint16_t
755  // there are normally 3 or 5 BxInEvent
756  gtfeWordValue.setRecordLength(
757  static_cast<boost::uint16_t>(recordLength0));
758 
759  gtfeWordValue.setRecordLength1(
760  static_cast<boost::uint16_t>(recordLength1));
761 
762  // bunch crossing
763  gtfeWordValue.setBxNr(bxCrossHw);
764 
765  // set the list of active boards
766  gtfeWordValue.setActiveBoards(m_activeBoardsGtDaq);
767 
768  // set alternative for number of BX per board
769  gtfeWordValue.setAltNrBxBoard(
770  static_cast<boost::uint16_t> (m_alternativeNrBxBoardDaq));
771 
772  // set the TOTAL_TRIGNR as read from iEvent
773  // TODO check again - PTC stuff
774 
775  gtfeWordValue.setTotalTriggerNr(
776  static_cast<boost::uint32_t>(iEvent.id().event()));
777 
778  // ** fill L1GtfeWord in GT DAQ record
779 
780  gtDaqReadoutRecord->setGtfeWord(gtfeWordValue);
781  }
782 
783  break;
784  case TCS: {
785  // nothing
786  }
787 
788  break;
789  case TIM: {
790  // nothing
791  }
792 
793  break;
794  default: {
795  // do nothing, all blocks are given in GtBoardType enum
796  }
797 
798  break;
799  }
800  }
801  }
802 
803  }
804 
805  }
806 
807  // fill the boards not depending on the BxInEvent in the L1 GT EVM record
808 
809  int evmNrFdlBoards = 0;
810 
812 
813  // get the length of the BST message from parameter set or from event setup
814 
815  int bstLengthBytes = 0;
816 
817  if (m_psBstLengthBytes < 0) {
818  // length from event setup
819  bstLengthBytes = static_cast<int> (m_bstLengthBytes);
820 
821  } else {
822  // length from parameter set
823  bstLengthBytes = m_psBstLengthBytes;
824  }
825 
826  if (m_verbosity) {
827 
828  LogTrace("L1GlobalTrigger")
829  << "\n Length of BST message (in bytes): "
830  << bstLengthBytes << "\n"
831  << std::endl;
832  }
833 
834  for (CItBoardMaps
835  itBoard = boardMaps.begin();
836  itBoard != boardMaps.end(); ++itBoard) {
837 
838  int iPosition = itBoard->gtPositionEvmRecord();
839  if (iPosition > 0) {
840 
841  int iActiveBit = itBoard->gtBitEvmActiveBoards();
842  bool activeBoard = false;
843 
844  if (iActiveBit >= 0) {
845  activeBoard = m_activeBoardsGtEvm & (1 << iActiveBit);
846  }
847 
848  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit < 0)
849  // in the record and ActiveBoardsMap, and active
850  if ((iActiveBit < 0) || activeBoard) {
851 
852  switch (itBoard->gtBoardType()) {
853 
854  case GTFE: {
855  L1GtfeExtWord gtfeWordValue(bstLengthBytes);
856 
857  gtfeWordValue.setBoardId(itBoard->gtBoardId() );
858 
859  // cast int to boost::uint16_t
860  // there are normally 3 or 5 BxInEvent
861  gtfeWordValue.setRecordLength(
862  static_cast<boost::uint16_t>(recordLength0));
863 
864  gtfeWordValue.setRecordLength1(
865  static_cast<boost::uint16_t>(recordLength1));
866 
867  // bunch crossing
868  gtfeWordValue.setBxNr(bxCrossHw);
869 
870  // set the list of active boards
871  gtfeWordValue.setActiveBoards(m_activeBoardsGtEvm);
872 
873  // set alternative for number of BX per board
874  gtfeWordValue.setAltNrBxBoard(
875  static_cast<boost::uint16_t> (m_alternativeNrBxBoardEvm));
876 
877  // set the TOTAL_TRIGNR as read from iEvent
878  // TODO check again - PTC stuff
879 
880  gtfeWordValue.setTotalTriggerNr(
881  static_cast<boost::uint32_t>(iEvent.id().event()));
882 
883  // set the GPS time to the value read from Timestamp
884  edm::TimeValue_t evTime = iEvent.time().value();
885 
886  gtfeWordValue.setGpsTime(evTime);
887 
888  //LogDebug("L1GlobalTrigger")
889  //<< "\nEvent timestamp value [hex] = " << std::hex << evTime
890  //<< "\nBST retrieved value [hex] = " << gtfeWordValue.gpsTime()
891  //<< std::dec << std::endl;
892 
893  // source of BST message: DDDD simulated data
894  boost::uint16_t bstSourceVal = 0xDDDD;
895  gtfeWordValue.setBstSource(bstSourceVal);
896 
897  // ** fill L1GtfeWord in GT EVM record
898 
899  gtEvmReadoutRecord->setGtfeWord(gtfeWordValue);
900  }
901 
902  break;
903  case FDL: {
904  evmNrFdlBoards++;
905  }
906 
907  break;
908  case TCS: {
909 
910  L1TcsWord tcsWordValue;
911 
912  tcsWordValue.setBoardId( itBoard->gtBoardId() );
913 
914  // bunch crossing
915  tcsWordValue.setBxNr(bxCrossHw);
916 
917  boost::uint16_t trigType = 0x5; // 0101 simulated event
918  tcsWordValue.setTriggerType(trigType);
919 
920  // luminosity segment number
921  tcsWordValue.setLuminositySegmentNr(
922  static_cast<boost::uint16_t>(iEvent.luminosityBlock()));
923 
924 
925  // set the Event_Nr as read from iEvent
926  tcsWordValue.setEventNr(
927  static_cast<boost::uint32_t>(iEvent.id().event()));
928 
929  // orbit number
930  tcsWordValue.setOrbitNr(
931  static_cast<boost::uint64_t>(iEvent.orbitNumber()) );
932 
933  // ** fill L1TcsWord in the EVM record
934 
935  gtEvmReadoutRecord->setTcsWord(tcsWordValue);
936 
937  }
938 
939  break;
940  case TIM: {
941  // nothing
942  }
943 
944  break;
945  default: {
946  // do nothing, all blocks are given in GtBoardType enum
947  }
948 
949  break;
950  }
951  }
952  }
953 
954  }
955 
956  }
957 
958  // get the prescale factor set used in the actual luminosity segment
959  int pfAlgoSetIndex = 0; // FIXME
960  const std::vector<int>& prescaleFactorsAlgoTrig =
961  (*m_prescaleFactorsAlgoTrig).at(pfAlgoSetIndex);
962 
963  int pfTechSetIndex = 0; // FIXME
964  const std::vector<int>& prescaleFactorsTechTrig =
965  (*m_prescaleFactorsTechTrig).at(pfTechSetIndex);
966 
967  //
968 
969  // loop over BxInEvent
970  for (int iBxInEvent = minBxInEvent; iBxInEvent <= maxBxInEvent;
971  ++iBxInEvent) {
972 
973  // * receive GCT object data via PSBs
974  //LogDebug("L1GlobalTrigger")
975  //<< "\nL1GlobalTrigger : receiving PSB data for bx = " << iBxInEvent << "\n"
976  //<< std::endl;
977 
979  iEvent,
980  m_caloGctInputTag, iBxInEvent,
981  receiveNoIsoEG, m_nrL1NoIsoEG,
982  receiveIsoEG, m_nrL1IsoEG,
983  receiveCenJet, m_nrL1CenJet,
984  receiveForJet, m_nrL1ForJet,
985  receiveTauJet, m_nrL1TauJet,
986  receiveETM, receiveETT, receiveHTT, receiveHTM,
987  receiveJetCounts,
988  receiveHfBitCounts,
989  receiveHfRingEtSums);
990 
994  m_technicalTriggersInputTags, iBxInEvent, receiveTechTr,
996  }
997 
1000  iEvent, m_activeBoardsGtDaq, recordLength0, recordLength1,
1001  m_alternativeNrBxBoardDaq, boardMaps, iBxInEvent, gtDaqReadoutRecord);
1002  }
1003 
1004  // * receive GMT object data via GTL
1005  //LogDebug("L1GlobalTrigger")
1006  //<< "\nL1GlobalTrigger : receiving GMT data for bx = " << iBxInEvent << "\n"
1007  //<< std::endl;
1008 
1009  m_gtGTL->receiveGmtObjectData(iEvent, m_muGmtInputTag, iBxInEvent,
1010  receiveMu, m_nrL1Mu);
1011 
1012  // * run GTL
1013  //LogDebug("L1GlobalTrigger")
1014  //<< "\nL1GlobalTrigger : running GTL for bx = " << iBxInEvent << "\n"
1015  //<< std::endl;
1016 
1017  m_gtGTL->run(iEvent, evSetup, m_gtPSB,
1018  m_produceL1GtObjectMapRecord, iBxInEvent, gtObjectMapRecord,
1020  m_nrL1Mu,
1021  m_nrL1NoIsoEG,
1022  m_nrL1IsoEG,
1023  m_nrL1CenJet,
1024  m_nrL1ForJet,
1025  m_nrL1TauJet,
1029 
1030  //LogDebug("L1GlobalTrigger")
1031  //<< "\n AlgorithmOR\n" << m_gtGTL->getAlgorithmOR() << "\n"
1032  //<< std::endl;
1033 
1034  // * run FDL
1035  //LogDebug("L1GlobalTrigger")
1036  //<< "\nL1GlobalTrigger : running FDL for bx = " << iBxInEvent << "\n"
1037  //<< std::endl;
1038 
1039  m_gtFDL->run(iEvent,
1040  prescaleFactorsAlgoTrig, prescaleFactorsTechTrig,
1043  boardMaps, m_emulateBxInEvent, iBxInEvent,
1046  m_gtGTL, m_gtPSB,
1047  pfAlgoSetIndex,
1048  pfTechSetIndex);
1049 
1050  if (m_produceL1GtDaqRecord && ( daqNrFdlBoards > 0 )) {
1051  m_gtFDL->fillDaqFdlBlock(iBxInEvent,
1052  m_activeBoardsGtDaq, recordLength0, recordLength1, m_alternativeNrBxBoardDaq,
1053  boardMaps, gtDaqReadoutRecord);
1054  }
1055 
1056 
1057  if (m_produceL1GtEvmRecord && ( evmNrFdlBoards > 0 )) {
1058  m_gtFDL->fillEvmFdlBlock(iBxInEvent,
1059  m_activeBoardsGtEvm, recordLength0, recordLength1, m_alternativeNrBxBoardEvm,
1060  boardMaps, gtEvmReadoutRecord);
1061  }
1062 
1063  // reset
1064  m_gtPSB->reset();
1065  m_gtGTL->reset();
1066  m_gtFDL->reset();
1067 
1068  //LogDebug("L1GlobalTrigger") << "\n Reset PSB, GTL, FDL\n" << std::endl;
1069 
1070  }
1071 
1072 
1073  if ( receiveMu ) {
1074 
1075 
1076  //LogDebug("L1GlobalTrigger")
1077  //<< "\n**** "
1078  //<< "\n Persistent reference for L1MuGMTReadoutCollection with input tag: "
1079  //<< m_muGmtInputTag
1080  //<< "\n**** \n"
1081  //<< std::endl;
1082 
1083  // get L1MuGMTReadoutCollection reference and set it in GT record
1084 
1086  iEvent.getByLabel(m_muGmtInputTag, gmtRcHandle);
1087 
1088 
1089 
1090  if (!gmtRcHandle.isValid()) {
1091  if (m_verbosity) {
1092  edm::LogWarning("L1GlobalTrigger")
1093  << "\nWarning: L1MuGMTReadoutCollection with input tag " << m_muGmtInputTag
1094  << "\nrequested in configuration, but not found in the event.\n"
1095  << std::endl;
1096  }
1097  } else {
1098 
1099  gtDaqReadoutRecord->setMuCollectionRefProd(gmtRcHandle);
1100 
1101  }
1102 
1103  }
1104 
1105  if ( m_verbosity && m_isDebugEnabled ) {
1106 
1107  std::ostringstream myCoutStream;
1108  gtDaqReadoutRecord->print(myCoutStream);
1109  LogTrace("L1GlobalTrigger")
1110  << "\n The following L1 GT DAQ readout record was produced:\n"
1111  << myCoutStream.str() << "\n"
1112  << std::endl;
1113 
1114  myCoutStream.str("");
1115  myCoutStream.clear();
1116 
1117  gtEvmReadoutRecord->print(myCoutStream);
1118  LogTrace("L1GlobalTrigger")
1119  << "\n The following L1 GT EVM readout record was produced:\n"
1120  << myCoutStream.str() << "\n"
1121  << std::endl;
1122 
1123  myCoutStream.str("");
1124  myCoutStream.clear();
1125 
1126  const std::vector<L1GlobalTriggerObjectMap> objMapVec =
1127  gtObjectMapRecord->gtObjectMap();
1128 
1129  for (std::vector<L1GlobalTriggerObjectMap>::const_iterator
1130  it = objMapVec.begin(); it != objMapVec.end(); ++it) {
1131 
1132  (*it).print(myCoutStream);
1133 
1134  }
1135 
1136 
1137  LogDebug("L1GlobalTrigger")
1138  << "Test gtObjectMapRecord in L1GlobalTrigger \n\n" << myCoutStream.str() << "\n\n"
1139  << std::endl;
1140 
1141  myCoutStream.str("");
1142  myCoutStream.clear();
1143 
1144  }
1145 
1146  // **
1147  // register products
1148  if (m_produceL1GtDaqRecord) {
1149  iEvent.put( gtDaqReadoutRecord );
1150  }
1151 
1152  if (m_produceL1GtEvmRecord) {
1153  iEvent.put( gtEvmReadoutRecord );
1154  }
1155 
1157  iEvent.put( gtObjectMapRecord );
1158  }
1159 
1160 }
1161 
1162 // static data members
1163 
#define LogDebug(id)
unsigned int gtNumberL1TauJet() const
get / set the number of L1 tau jets received by GT
EventNumber_t event() const
Definition: EventID.h:44
bool isDebugEnabled()
void setBstSource(const boost::uint16_t bstSourceVal)
void setTriggerType(const boost::uint16_t triggerTypeValue)
Definition: L1TcsWord.h:134
const L1GtTriggerMask * m_l1GtTmVetoTech
void setBxNr(const boost::uint16_t bxNrValue)
Definition: L1TcsWord.h:94
void init(const int nrL1Mu, const int numberPhysTriggers)
initialize the class (mainly reserve)
const L1GtTriggerMask * m_l1GtTmVetoAlgo
Definition: L1GtFwd.h:32
unsigned long long m_l1GtParCacheID
const L1GtStableParameters * m_l1GtStablePar
cached stuff
void run(edm::Event &iEvent, const edm::EventSetup &evSetup, const L1GlobalTriggerPSB *ptrGtPSB, const bool produceL1GtObjectMapRecord, const int iBxInEvent, std::auto_ptr< L1GlobalTriggerObjectMapRecord > &gtObjectMapRecord, const unsigned int numberPhysTriggers, const int nrL1Mu, const int nrL1NoIsoEG, const int nrL1IsoEG, const int nrL1CenJet, const int nrL1ForJet, const int nrL1TauJet, const int nrL1JetCounts, const int ifMuEtaNumberBits, const int ifCaloEtaNumberBits)
run the GTL
std::vector< unsigned int > m_triggerMaskVetoAlgoTrig
std::vector< int > m_recordLength
const boost::uint16_t gtDaqActiveBoards() const
get / set the active boards for L1 GT DAQ record
Definition: L1GtFwd.h:20
const int gtTotalBxInEvent() const
get / set the total Bx&#39;s in the event
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
std::vector< unsigned int > m_triggerMaskAlgoTrig
Definition: L1GtFwd.h:26
const unsigned int gtBstLengthBytes() const
get / set length of BST message (in bytes) for L1 GT EVM record
int bunchCrossing() const
Definition: EventBase.h:62
Definition: L1GtFwd.h:20
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
void run(edm::Event &iEvent, const std::vector< int > &prescaleFactorsAlgoTrig, const std::vector< int > &prescaleFactorsTechTrig, const std::vector< unsigned int > &triggerMaskAlgoTrig, const std::vector< unsigned int > &triggerMaskTechTrig, const std::vector< unsigned int > &triggerMaskVetoAlgoTrig, const std::vector< unsigned int > &triggerMaskVetoTechTrig, const std::vector< L1GtBoard > &boardMaps, const int totalBxInEvent, const int iBxInEvent, const unsigned int numberPhysTriggers, const unsigned int numberTechnicalTriggers, const unsigned int numberDaqPartitions, const L1GlobalTriggerGTL *ptrGTL, const L1GlobalTriggerPSB *ptrPSB, const int pfAlgoSetIndex, const int pfTechSetIndex)
run the FDL
void receiveGctObjectData(edm::Event &iEvent, const edm::InputTag &caloGctInputTag, const int iBxInEvent, const bool receiveNoIsoEG, const int nrL1NoIsoEG, const bool receiveIsoEG, const int nrL1IsoEG, const bool receiveCenJet, const int nrL1CenJet, const bool receiveForJet, const int nrL1ForJet, const bool receiveTauJet, const int nrL1TauJet, const bool receiveETM, const bool receiveETT, const bool receiveHTT, const bool receiveHTM, const bool receiveJetCounts, const bool receiveHfBitCounts, const bool receiveHfRingEtSums)
receive Global Calorimeter Trigger objects
void fillEvmFdlBlock(const int iBxInEvent, const boost::uint16_t &activeBoardsGtEvm, const int recordLength0, const int recordLength1, const unsigned int altNrBxBoardEvm, const std::vector< L1GtBoard > &boardMaps, std::auto_ptr< L1GlobalTriggerEvmReadoutRecord > &gtEvmReadoutRecord)
fill the FDL block in the L1 GT EVM record for iBxInEvent
unsigned long long m_l1GtStableParCacheID
const L1GtPrescaleFactors * m_l1GtPfAlgo
prescale factors
unsigned int m_numberPhysTriggers
number of physics triggers
L1GlobalTrigger(const edm::ParameterSet &)
unsigned int gtNumberL1CenJet() const
get / set the number of L1 central jets received by GT
L1GlobalTriggerGTL * m_gtGTL
unsigned int m_bstLengthBytes
length of BST record (in bytes) from event setup
const std::vector< std::vector< int > > * m_prescaleFactorsTechTrig
std::vector< unsigned int > m_triggerMaskVetoTechTrig
unsigned int gtNumberTechnicalTriggers() const
get / set the number of technical triggers
void setRecordLength1(boost::uint16_t recordLengthValue)
Definition: L1GtfeWord.h:92
unsigned int gtNumberPhysTriggers() const
get / set the number of physics trigger algorithms
void setActiveBoards(boost::uint16_t activeBoardsValue)
Definition: L1GtfeWord.h:170
unsigned int gtIfMuEtaNumberBits() const
get / set the number of bits for eta of muon objects
int iEvent
Definition: GenABIO.cc:243
const L1GtTriggerMask * m_l1GtTmTech
void setVerbosity(const int verbosity)
Definition: L1GtFwd.h:33
void setVerbosity(const int verbosity)
const T & max(const T &a, const T &b)
unsigned int gtNumberL1ForJet() const
get / set the number of L1 forward jets received by GT
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
edm::InputTag m_caloGctInputTag
input tag for calorimeter collections from GCT
boost::uint16_t m_activeBoardsGtEvm
unsigned long long m_l1GtPfTechCacheID
void receiveTechnicalTriggers(edm::Event &iEvent, const std::vector< edm::InputTag > &technicalTriggersInputTags, const int iBxInEvent, const bool receiveTechTr, const int nrL1TechTr)
receive technical trigger
void reset()
clear PSB
virtual void produce(edm::Event &, const edm::EventSetup &)
void setBoardId(const boost::uint16_t boardIdValue)
set BoardId from a BoardId value
Definition: L1TcsWord.h:74
unsigned int m_alternativeNrBxBoardDaq
int m_verbosity
verbosity level
L1GlobalTriggerFDL * m_gtFDL
const L1GtParameters * m_l1GtPar
parameters
std::vector< unsigned int > m_triggerMaskTechTrig
Definition: L1GtFwd.h:20
void setAltNrBxBoard(boost::uint16_t altNrBxBoardValue)
Definition: L1GtfeWord.h:194
void setGpsTime(const boost::uint64_t)
const L1GtPrescaleFactors * m_l1GtPfTech
unsigned long long m_l1GtTmAlgoCacheID
int orbitNumber() const
Definition: EventBase.h:63
std::vector< edm::InputTag > m_technicalTriggersInputTags
input tag for technical triggers
unsigned int m_alternativeNrBxBoardEvm
bool isValid() const
Definition: HandleBase.h:76
Definition: L1GtFwd.h:20
unsigned long long TimeValue_t
Definition: Timestamp.h:27
void setBxNr(boost::uint16_t bxNrValue)
Definition: L1GtfeWord.h:129
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
#define LogTrace(id)
bool m_produceL1GtDaqRecord
logical flag to produce the L1 GT DAQ readout record
unsigned int gtNumberL1NoIsoEG() const
get / set the number of L1 e/gamma objects received by GT
void setEventNr(const boost::uint32_t eventNrValue)
Definition: L1TcsWord.h:253
unsigned int gtNumberL1JetCounts() const
get / set the number of L1 jet counts received by GT
bool m_produceL1GtObjectMapRecord
logical flag to produce the L1 GT object map record
boost::uint16_t m_activeBoardsGtDaq
active boards in L1 GT DAQ record and in L1 GT EVM record
TimeValue_t value() const
Definition: Timestamp.cc:72
unsigned int gtIfCaloEtaNumberBits() const
get / set the number of bits for eta of calorimeter objects
edm::InputTag m_muGmtInputTag
input tag for muon collection from GMT
void setBoardId(boost::uint16_t boardIdValue)
set BoardId from a BoardId value
Definition: L1GtfeWord.h:73
bool m_produceL1GtEvmRecord
logical flag to produce the L1 GT EVM readout record
void reset()
clear FDL
const L1GtTriggerMask * m_l1GtTmAlgo
trigger masks &amp; veto masks
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
const boost::uint16_t gtEvmActiveBoards() const
get / set the active boards for L1 GT EVM record
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
unsigned long long m_l1GtTmVetoTechCacheID
void receiveGmtObjectData(edm::Event &, const edm::InputTag &, const int iBxInEvent, const bool receiveMu, const int nrL1Mu)
receive data from Global Muon Trigger
unsigned long long m_l1GtBMCacheID
L1GlobalTriggerPSB * m_gtPSB
bool m_readTechnicalTriggerRecords
logical flag to read the technical trigger records
edm::EventID id() const
Definition: EventBase.h:56
bool m_writePsbL1GtDaqRecord
logical flag to write the PSB content in the L1 GT DAQ record
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
Definition: L1GtBoardMaps.h:45
Definition: L1GtFwd.h:20
Definition: L1GtFwd.h:24
void setTotalTriggerNr(boost::uint32_t totalTriggerNrValue)
Definition: L1GtfeWord.h:218
int m_totalBxInEvent
total number of Bx&#39;s in the event coming from EventSetup
unsigned int m_numberTechnicalTriggers
number of technical triggers
void setVerbosity(const int verbosity)
void setRecordLength(boost::uint16_t recordLengthValue)
Definition: L1GtfeWord.h:111
const L1GtBoardMaps * m_l1GtBM
board maps - cache only the record
unsigned long long m_l1GtTmTechCacheID
unsigned int m_numberDaqPartitions
number of DAQ partitions
void fillPsbBlock(edm::Event &iEvent, const boost::uint16_t &activeBoardsGtDaq, const int recordLength0, const int recordLength1, const unsigned int altNrBxBoardDaq, const std::vector< L1GtBoard > &boardMaps, const int iBxInEvent, std::auto_ptr< L1GlobalTriggerReadoutRecord > &gtDaqReadoutRecord)
fill the content of active PSB boards
void init(const int nrL1NoIsoEG, const int nrL1IsoEG, const int nrL1CenJet, const int nrL1ForJet, const int nrL1TauJet, const int numberTechnicalTriggers)
initialize the class (mainly reserve)
edm::InputTag m_castorInputTag
input tag for CASTOR record
unsigned int gtNumberL1IsoEG() const
get / set the number of L1 isolated e/gamma objects received by GT
void setLuminositySegmentNr(const boost::uint16_t luminositySegmentNrValue)
Definition: L1TcsWord.h:173
int m_psBstLengthBytes
length of BST record (in bytes) from parameter set
Definition: L1GtFwd.h:23
void fillDaqFdlBlock(const int iBxInEvent, const boost::uint16_t &activeBoardsGtDaq, const int recordLength0, const int recordLength1, const unsigned int altNrBxBoardDaq, const std::vector< L1GtBoard > &boardMaps, std::auto_ptr< L1GlobalTriggerReadoutRecord > &gtDaqReadoutRecord)
fill the FDL block in the L1 GT DAQ record for iBxInEvent
edm::Timestamp time() const
Definition: EventBase.h:57
unsigned long long m_l1GtTmVetoAlgoCacheID
unsigned int gtNumberL1Mu() const
get / set the number of L1 muons received by GT
unsigned long long m_l1GtPfAlgoCacheID
void setOrbitNr(const boost::uint64_t orbitNrValue)
Definition: L1TcsWord.h:273
Definition: L1GtFwd.h:20
void reset()
clear GTL