CMS 3D CMS Logo

L1GlobalTrigger.cc
Go to the documentation of this file.
1 
15 // this class header
16 #include "L1GlobalTrigger.h"
17 
18 // system include files
19 #include <algorithm>
20 #include <iomanip>
21 #include <iostream>
22 #include <memory>
23 
24 // user include files
25 //#include
26 //"DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
30 
32 
36 
43 
48 
52 
56 
59 
62 #include <cstdint>
63 
64 // constructors
65 
67  : m_muGmtInputTag(parSet.getParameter<edm::InputTag>("GmtInputTag")),
68  m_caloGctInputTag(parSet.getParameter<edm::InputTag>("GctInputTag")),
69  m_castorInputTag(parSet.getParameter<edm::InputTag>("CastorInputTag")),
70  m_technicalTriggersInputTags(parSet.getParameter<std::vector<edm::InputTag>>("TechnicalTriggersInputTags")),
71  m_produceL1GtDaqRecord(parSet.getParameter<bool>("ProduceL1GtDaqRecord")),
72  m_produceL1GtEvmRecord(parSet.getParameter<bool>("ProduceL1GtEvmRecord")),
73  m_produceL1GtObjectMapRecord(parSet.getParameter<bool>("ProduceL1GtObjectMapRecord")),
74  m_writePsbL1GtDaqRecord(parSet.getParameter<bool>("WritePsbL1GtDaqRecord")),
75  m_readTechnicalTriggerRecords(parSet.getParameter<bool>("ReadTechnicalTriggerRecords")),
76  m_emulateBxInEvent(parSet.getParameter<int>("EmulateBxInEvent")),
77  m_recordLength(parSet.getParameter<std::vector<int>>("RecordLength")),
78  m_alternativeNrBxBoardDaq(parSet.getParameter<unsigned int>("AlternativeNrBxBoardDaq")),
79  m_alternativeNrBxBoardEvm(parSet.getParameter<unsigned int>("AlternativeNrBxBoardEvm")),
80  m_psBstLengthBytes(parSet.getParameter<int>("BstLengthBytes")),
81  m_algorithmTriggersUnprescaled(parSet.getParameter<bool>("AlgorithmTriggersUnprescaled")),
82  m_algorithmTriggersUnmasked(parSet.getParameter<bool>("AlgorithmTriggersUnmasked")),
83  m_technicalTriggersUnprescaled(parSet.getParameter<bool>("TechnicalTriggersUnprescaled")),
84  m_technicalTriggersUnmasked(parSet.getParameter<bool>("TechnicalTriggersUnmasked")),
85  m_technicalTriggersVetoUnmasked(parSet.getParameter<bool>("TechnicalTriggersVetoUnmasked")),
86  m_verbosity(parSet.getUntrackedParameter<int>("Verbosity", 0)),
87  m_isDebugEnabled(edm::isDebugEnabled()),
89  m_l1GtParToken(esConsumes<L1GtParameters, L1GtParametersRcd>()),
90  m_l1GtBMToken(esConsumes<L1GtBoardMaps, L1GtBoardMapsRcd>()),
96  m_l1GtTmVetoTechToken(esConsumes<L1GtTriggerMask, L1GtTriggerMaskVetoTechTrigRcd>()) {
97  if (m_verbosity) {
98  LogDebug("L1GlobalTrigger") << std::endl;
99 
100  LogTrace("L1GlobalTrigger") << "\nInput tag for muon collection from GMT: " << m_muGmtInputTag
101  << "\nInput tag for calorimeter collections from GCT: " << m_caloGctInputTag
102  << "\nInput tag for CASTOR record: " << m_castorInputTag
103  << "\nInput tag for technical triggers: " << std::endl;
104 
105  // loop over all producers of technical trigger records
106  for (std::vector<edm::InputTag>::const_iterator it = m_technicalTriggersInputTags.begin();
107  it != m_technicalTriggersInputTags.end();
108  it++) {
109  LogTrace("L1GlobalTrigger") << "\n " << (*it) << std::endl;
110  }
111 
112  LogTrace("L1GlobalTrigger")
113  << "\nProduce the L1 GT DAQ readout record: " << m_produceL1GtDaqRecord
114  << "\nProduce the L1 GT EVM readout record: " << m_produceL1GtEvmRecord
115  << "\nProduce the L1 GT Object Map record: " << m_produceL1GtObjectMapRecord << " \n"
116  << "\nWrite Psb content to L1 GT DAQ Record: " << m_writePsbL1GtDaqRecord << " \n"
117  << "\nRead technical trigger records: " << m_readTechnicalTriggerRecords << " \n"
118  << "\nNumber of BxInEvent to be emulated: " << m_emulateBxInEvent
119  << "\nNumber of BXs corresponding to alternative 0: " << m_recordLength.at(0)
120  << "\nNumber of BXs corresponding to alternative 1: " << m_recordLength.at(1) << " \n"
121  << "\nAlternative for number of BX in GT DAQ record: 0x" << std::hex << m_alternativeNrBxBoardDaq
122  << "\nAlternative for number of BX in GT EVM record: 0x" << std::hex << m_alternativeNrBxBoardEvm << std::dec
123  << " \n"
124  << "\nLength of BST message [bytes]: " << m_psBstLengthBytes << "\n"
125  << "\nRun algorithm triggers unprescaled: " << m_algorithmTriggersUnprescaled
126  << "\nRun algorithm triggers unmasked (all enabled): " << m_algorithmTriggersUnmasked << "\n"
127  << "\nRun technical triggers unprescaled: " << m_technicalTriggersUnprescaled
128  << "\nRun technical triggers unmasked (all enabled): " << m_technicalTriggersUnmasked
129  << "\nRun technical triggers veto unmasked (no veto): " << m_technicalTriggersUnmasked << "\n"
130  << std::endl;
131  }
132 
133  if ((m_emulateBxInEvent > 0) && ((m_emulateBxInEvent % 2) == 0)) {
135 
136  if (m_verbosity) {
137  edm::LogWarning("L1GlobalTrigger") << "\nWARNING: Number of bunch crossing to be emulated rounded to: "
138  << m_emulateBxInEvent << "\n The number must be an odd number!\n"
139  << std::endl;
140  }
141  }
142 
143  int requiredRecordLength = std::max(m_recordLength.at(0), m_recordLength.at(1));
144  if ((m_emulateBxInEvent >= 0) && (m_emulateBxInEvent < requiredRecordLength)) {
145  m_emulateBxInEvent = requiredRecordLength;
146 
147  if (m_verbosity) {
148  edm::LogWarning("L1GlobalTrigger") << "\nWARNING: Number of bunch crossing required to be emulated ( "
149  << m_emulateBxInEvent << " BX) smaller as required in RecordLength:"
150  << "\n Number of BXs corresponding to alternative 0: "
151  << m_recordLength.at(0)
152  << "\n Number of BXs corresponding to alternative 1: "
153  << m_recordLength.at(1) << "\nEmulating " << requiredRecordLength << " BX!"
154  << "\n"
155  << std::endl;
156  }
157  }
158 
159  // register products
161  produces<L1GlobalTriggerReadoutRecord>();
162  }
163 
165  produces<L1GlobalTriggerEvmReadoutRecord>();
166  }
167 
169  produces<L1GlobalTriggerObjectMapRecord>();
170  }
171 
172  // create new PSBs
175 
176  // create new GTL
177  m_gtGTL = new L1GlobalTriggerGTL(m_muGmtInputTag, consumesCollector());
179 
180  // create new FDL
181  m_gtFDL = new L1GlobalTriggerFDL();
183 
184  // initialize cached IDs
185 
186  //
187  m_l1GtStableParCacheID = 0ULL;
188 
192 
193  m_nrL1Mu = 0;
194 
195  m_nrL1NoIsoEG = 0;
196  m_nrL1IsoEG = 0;
197 
198  m_nrL1CenJet = 0;
199  m_nrL1ForJet = 0;
200  m_nrL1TauJet = 0;
201 
202  m_nrL1JetCounts = 0;
203 
206 
207  //
208  m_l1GtParCacheID = 0ULL;
209 
210  m_totalBxInEvent = 0;
211 
214  m_bstLengthBytes = 0;
215 
216  //
217  m_l1GtBMCacheID = 0ULL;
218 
219  //
220  m_l1GtPfAlgoCacheID = 0ULL;
221  m_l1GtPfTechCacheID = 0ULL;
222 
223  m_l1GtTmAlgoCacheID = 0ULL;
224  m_l1GtTmTechCacheID = 0ULL;
225 
228 
229  consumes<L1MuGMTReadoutCollection>(m_muGmtInputTag);
230 }
231 
232 // destructor
234  delete m_gtPSB;
235  delete m_gtGTL;
236  delete m_gtFDL;
237 }
238 
239 // member functions
240 
241 // method called to produce the data
243  // process event iEvent
244 
245  // get / update the stable parameters from the EventSetup
246  // local cache & check on cacheIdentifier
247 
248  unsigned long long l1GtStableParCacheID = evSetup.get<L1GtStableParametersRcd>().cacheIdentifier();
249 
250  if (m_l1GtStableParCacheID != l1GtStableParCacheID) {
252  m_l1GtStablePar = l1GtStablePar.product();
253 
254  // number of physics triggers
256 
257  // number of technical triggers
259 
260  // number of DAQ partitions
261  m_numberDaqPartitions = 8; // FIXME add it to stable parameters
262 
263  // number of objects of each type
264  m_nrL1Mu = static_cast<int>(m_l1GtStablePar->gtNumberL1Mu());
265 
266  m_nrL1NoIsoEG = static_cast<int>(m_l1GtStablePar->gtNumberL1NoIsoEG());
267  m_nrL1IsoEG = static_cast<int>(m_l1GtStablePar->gtNumberL1IsoEG());
268 
269  m_nrL1CenJet = static_cast<int>(m_l1GtStablePar->gtNumberL1CenJet());
270  m_nrL1ForJet = static_cast<int>(m_l1GtStablePar->gtNumberL1ForJet());
271  m_nrL1TauJet = static_cast<int>(m_l1GtStablePar->gtNumberL1TauJet());
272 
273  m_nrL1JetCounts = static_cast<int>(m_l1GtStablePar->gtNumberL1JetCounts());
274 
275  // ... the rest of the objects are global
276 
279 
280  // (re)initialize L1GlobalTriggerGTL
282 
283  // (re)initialize L1GlobalTriggerPSB
285 
286  //
287  m_l1GtStableParCacheID = l1GtStableParCacheID;
288  }
289 
290  // get / update the parameters from the EventSetup
291  // local cache & check on cacheIdentifier
292 
293  unsigned long long l1GtParCacheID = evSetup.get<L1GtParametersRcd>().cacheIdentifier();
294 
295  if (m_l1GtParCacheID != l1GtParCacheID) {
297  m_l1GtPar = l1GtPar.product();
298 
299  // total number of Bx's in the event coming from EventSetup
301 
302  // active boards in L1 GT DAQ record and in L1 GT EVM record
305 
308 
309  m_l1GtParCacheID = l1GtParCacheID;
310  }
311 
312  // negative value: emulate TotalBxInEvent as given in EventSetup
313  if (m_emulateBxInEvent < 0) {
315  }
316 
317  int minBxInEvent = (m_emulateBxInEvent + 1) / 2 - m_emulateBxInEvent;
318  int maxBxInEvent = (m_emulateBxInEvent + 1) / 2 - 1;
319 
320  int recordLength0 = m_recordLength.at(0);
321  int recordLength1 = m_recordLength.at(1);
322 
323  if ((recordLength0 < 0) || (recordLength1 < 0)) {
324  // take them from event setup
325  // FIXME implement later - temporary solution
326 
327  recordLength0 = m_emulateBxInEvent;
328  recordLength1 = m_emulateBxInEvent;
329  }
330 
331  if (m_verbosity) {
332  LogDebug("L1GlobalTrigger") << "\nTotal number of BX to emulate in the GT readout record: " << m_emulateBxInEvent
333  << " = "
334  << "[" << minBxInEvent << ", " << maxBxInEvent << "] BX\n"
335  << "\nNumber of BX for alternative 0: " << recordLength0
336  << "\nNumber of BX for alternative 1: " << recordLength1
337  << "\nActive boards in L1 GT DAQ record (hex format) = " << std::hex
338  << std::setw(sizeof(m_activeBoardsGtDaq) * 2) << std::setfill('0')
339  << m_activeBoardsGtDaq << std::dec << std::setfill(' ')
340  << "\nActive boards in L1 GT EVM record (hex format) = " << std::hex
341  << std::setw(sizeof(m_activeBoardsGtEvm) * 2) << std::setfill('0')
342  << m_activeBoardsGtEvm << std::dec << std::setfill(' ') << "\n"
343  << std::endl;
344  }
345 
346  // get / update the board maps from the EventSetup
347  // local cache & check on cacheIdentifier
348 
349  typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
350 
351  unsigned long long l1GtBMCacheID = evSetup.get<L1GtBoardMapsRcd>().cacheIdentifier();
352 
353  if (m_l1GtBMCacheID != l1GtBMCacheID) {
355  m_l1GtBM = l1GtBM.product();
356 
357  m_l1GtBMCacheID = l1GtBMCacheID;
358  }
359 
360  // TODO need changes in CondFormats to cache the maps
361  const std::vector<L1GtBoard> &boardMaps = m_l1GtBM->gtBoardMaps();
362 
363  // get / update the prescale factors from the EventSetup
364  // local cache & check on cacheIdentifier
365 
366  unsigned long long l1GtPfAlgoCacheID = evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
367 
368  if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
370  m_l1GtPfAlgo = l1GtPfAlgo.product();
371 
373 
374  m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
375  }
376 
377  unsigned long long l1GtPfTechCacheID = evSetup.get<L1GtPrescaleFactorsTechTrigRcd>().cacheIdentifier();
378 
379  if (m_l1GtPfTechCacheID != l1GtPfTechCacheID) {
381  m_l1GtPfTech = l1GtPfTech.product();
382 
384 
385  m_l1GtPfTechCacheID = l1GtPfTechCacheID;
386  }
387 
388  // get / update the trigger mask from the EventSetup
389  // local cache & check on cacheIdentifier
390 
391  unsigned long long l1GtTmAlgoCacheID = evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
392 
393  if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
395  m_l1GtTmAlgo = l1GtTmAlgo.product();
396 
398 
399  m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
400  }
401 
402  unsigned long long l1GtTmTechCacheID = evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
403 
404  if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
406  m_l1GtTmTech = l1GtTmTech.product();
407 
409 
410  m_l1GtTmTechCacheID = l1GtTmTechCacheID;
411  }
412 
413  unsigned long long l1GtTmVetoAlgoCacheID = evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().cacheIdentifier();
414 
415  if (m_l1GtTmVetoAlgoCacheID != l1GtTmVetoAlgoCacheID) {
417  m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
418 
420 
421  m_l1GtTmVetoAlgoCacheID = l1GtTmVetoAlgoCacheID;
422  }
423 
424  unsigned long long l1GtTmVetoTechCacheID = evSetup.get<L1GtTriggerMaskVetoTechTrigRcd>().cacheIdentifier();
425 
426  if (m_l1GtTmVetoTechCacheID != l1GtTmVetoTechCacheID) {
428  m_l1GtTmVetoTech = l1GtTmVetoTech.product();
429 
431 
432  m_l1GtTmVetoTechCacheID = l1GtTmVetoTechCacheID;
433  }
434 
435  // loop over blocks in the GT DAQ record receiving data, count them if they
436  // are active all board type are defined in CondFormats/L1TObjects/L1GtFwd
437  // enum L1GtBoardType { GTFE, FDL, PSB, GMT, TCS, TIM };
438  // &
439  // set the active flag for each object type received from GMT and GCT
440  // all objects in the GT system are defined in enum L1GtObject from
441  // DataFormats/L1Trigger/L1GlobalTriggerReadoutSetupFwd
442 
443  int daqNrGtfeBoards = 0;
444 
445  int daqNrFdlBoards = 0;
446  int daqNrPsbBoards = 0;
447  int daqNrGmtBoards = 0;
448  int daqNrTcsBoards = 0;
449  int daqNrTimBoards = 0;
450 
451  //
452  bool receiveMu = false;
453  bool receiveNoIsoEG = false;
454  bool receiveIsoEG = false;
455  bool receiveCenJet = false;
456  bool receiveForJet = false;
457  bool receiveTauJet = false;
458  bool receiveETM = false;
459  bool receiveETT = false;
460  bool receiveHTT = false;
461  bool receiveHTM = false;
462  bool receiveJetCounts = false;
463  bool receiveHfBitCounts = false;
464  bool receiveHfRingEtSums = false;
465 
466  bool receiveExternal = false;
467 
468  bool receiveTechTr = false;
469 
470  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
471  int iPosition = itBoard->gtPositionDaqRecord();
472  if (iPosition > 0) {
473  int iActiveBit = itBoard->gtBitDaqActiveBoards();
474  bool activeBoard = false;
475 
476  if (iActiveBit >= 0) {
477  activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
478  }
479 
480  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit <
481  // 0)
482  // in the record and ActiveBoardsMap, and active
483  if ((iActiveBit < 0) || activeBoard) {
484  switch (itBoard->gtBoardType()) {
485  case GTFE: {
486  daqNrGtfeBoards++;
487  }
488 
489  break;
490  case FDL: {
491  daqNrFdlBoards++;
492  }
493 
494  break;
495  case PSB: {
496  daqNrPsbBoards++;
497 
498  // get the objects coming to this PSB
499  std::vector<L1GtPsbQuad> quadInPsb = itBoard->gtQuadInPsb();
500  for (std::vector<L1GtPsbQuad>::const_iterator itQuad = quadInPsb.begin(); itQuad != quadInPsb.end();
501  ++itQuad) {
502  switch (*itQuad) {
503  case TechTr: {
504  receiveTechTr = true;
505  }
506 
507  break;
508  case NoIsoEGQ: {
509  receiveNoIsoEG = true;
510  }
511 
512  break;
513  case IsoEGQ: {
514  receiveIsoEG = true;
515  }
516 
517  break;
518  case CenJetQ: {
519  receiveCenJet = true;
520  }
521 
522  break;
523  case ForJetQ: {
524  receiveForJet = true;
525  }
526 
527  break;
528  case TauJetQ: {
529  receiveTauJet = true;
530  }
531 
532  break;
533  case ESumsQ: {
534  receiveETM = true;
535  receiveETT = true;
536  receiveHTT = true;
537  receiveHTM = true;
538  }
539 
540  break;
541  case JetCountsQ: {
542  receiveJetCounts = true;
543  }
544 
545  break;
546  case CastorQ: {
547  // obsolete
548  }
549 
550  break;
551  case BptxQ: {
552  // obsolete
553  }
554 
555  break;
556  case GtExternalQ: {
557  receiveExternal = true;
558  }
559 
560  break;
561  case HfQ: {
562  receiveHfBitCounts = true;
563  receiveHfRingEtSums = true;
564  }
565 
566  break;
567  // FIXME add MIP/Iso bits
568  default: {
569  // do nothing
570  }
571 
572  break;
573  }
574  }
575 
576  }
577 
578  break;
579  case GMT: {
580  daqNrGmtBoards++;
581  receiveMu = true;
582  }
583 
584  break;
585  case TCS: {
586  daqNrTcsBoards++;
587  }
588 
589  break;
590  case TIM: {
591  daqNrTimBoards++;
592  }
593 
594  break;
595  default: {
596  // do nothing, all blocks are given in GtBoardType enum
597  }
598 
599  break;
600  }
601  }
602  }
603  }
604 
605  // produce the L1GlobalTriggerReadoutRecord now, after we found how many
606  // BxInEvent the record has and how many boards are active
607  std::unique_ptr<L1GlobalTriggerReadoutRecord> gtDaqReadoutRecord(
608  new L1GlobalTriggerReadoutRecord(m_emulateBxInEvent, daqNrFdlBoards, daqNrPsbBoards));
609 
610  // * produce the L1GlobalTriggerEvmReadoutRecord
611  std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord(
613  // daqNrFdlBoards OK, just reserve memory at this point
614 
615  // * produce the L1GlobalTriggerObjectMapRecord
616  std::unique_ptr<L1GlobalTriggerObjectMapRecord> gtObjectMapRecord(new L1GlobalTriggerObjectMapRecord());
617 
618  // fill the boards not depending on the BxInEvent in the L1 GT DAQ record
619  // GMT, PSB and FDL depend on BxInEvent
620 
621  // fill in emulator the same bunch crossing (12 bits - hardwired number of
622  // bits...) and the same local bunch crossing for all boards
623  int bxCross = iEvent.bunchCrossing();
624  uint16_t bxCrossHw = 0;
625  if ((bxCross & 0xFFF) == bxCross) {
626  bxCrossHw = static_cast<uint16_t>(bxCross);
627  } else {
628  bxCrossHw = 0; // Bx number too large, set to 0!
629  if (m_verbosity) {
630  LogDebug("L1GlobalTrigger") << "\nBunch cross number [hex] = " << std::hex << bxCross
631  << "\n larger than 12 bits. Set to 0! \n"
632  << std::dec << std::endl;
633  }
634  }
635 
637  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
638  int iPosition = itBoard->gtPositionDaqRecord();
639  if (iPosition > 0) {
640  int iActiveBit = itBoard->gtBitDaqActiveBoards();
641  bool activeBoard = false;
642 
643  if (iActiveBit >= 0) {
644  activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
645  }
646 
647  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit <
648  // 0)
649  // in the record and ActiveBoardsMap, and active
650  if ((iActiveBit < 0) || activeBoard) {
651  switch (itBoard->gtBoardType()) {
652  case GTFE: {
653  L1GtfeWord gtfeWordValue;
654 
655  gtfeWordValue.setBoardId(itBoard->gtBoardId());
656 
657  // cast int to uint16_t
658  // there are normally 3 or 5 BxInEvent
659  gtfeWordValue.setRecordLength(static_cast<uint16_t>(recordLength0));
660 
661  gtfeWordValue.setRecordLength1(static_cast<uint16_t>(recordLength1));
662 
663  // bunch crossing
664  gtfeWordValue.setBxNr(bxCrossHw);
665 
666  // set the list of active boards
667  gtfeWordValue.setActiveBoards(m_activeBoardsGtDaq);
668 
669  // set alternative for number of BX per board
670  gtfeWordValue.setAltNrBxBoard(static_cast<uint16_t>(m_alternativeNrBxBoardDaq));
671 
672  // set the TOTAL_TRIGNR as read from iEvent
673  // TODO check again - PTC stuff
674 
675  gtfeWordValue.setTotalTriggerNr(static_cast<uint32_t>(iEvent.id().event()));
676 
677  // ** fill L1GtfeWord in GT DAQ record
678 
679  gtDaqReadoutRecord->setGtfeWord(gtfeWordValue);
680  }
681 
682  break;
683  case TCS: {
684  // nothing
685  }
686 
687  break;
688  case TIM: {
689  // nothing
690  }
691 
692  break;
693  default: {
694  // do nothing, all blocks are given in GtBoardType enum
695  }
696 
697  break;
698  }
699  }
700  }
701  }
702  }
703 
704  // fill the boards not depending on the BxInEvent in the L1 GT EVM record
705 
706  int evmNrFdlBoards = 0;
707 
709  // get the length of the BST message from parameter set or from event setup
710 
711  int bstLengthBytes = 0;
712 
713  if (m_psBstLengthBytes < 0) {
714  // length from event setup
715  bstLengthBytes = static_cast<int>(m_bstLengthBytes);
716 
717  } else {
718  // length from parameter set
719  bstLengthBytes = m_psBstLengthBytes;
720  }
721 
722  if (m_verbosity) {
723  LogTrace("L1GlobalTrigger") << "\n Length of BST message (in bytes): " << bstLengthBytes << "\n" << std::endl;
724  }
725 
726  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
727  int iPosition = itBoard->gtPositionEvmRecord();
728  if (iPosition > 0) {
729  int iActiveBit = itBoard->gtBitEvmActiveBoards();
730  bool activeBoard = false;
731 
732  if (iActiveBit >= 0) {
733  activeBoard = m_activeBoardsGtEvm & (1 << iActiveBit);
734  }
735 
736  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit <
737  // 0)
738  // in the record and ActiveBoardsMap, and active
739  if ((iActiveBit < 0) || activeBoard) {
740  switch (itBoard->gtBoardType()) {
741  case GTFE: {
742  L1GtfeExtWord gtfeWordValue(bstLengthBytes);
743 
744  gtfeWordValue.setBoardId(itBoard->gtBoardId());
745 
746  // cast int to uint16_t
747  // there are normally 3 or 5 BxInEvent
748  gtfeWordValue.setRecordLength(static_cast<uint16_t>(recordLength0));
749 
750  gtfeWordValue.setRecordLength1(static_cast<uint16_t>(recordLength1));
751 
752  // bunch crossing
753  gtfeWordValue.setBxNr(bxCrossHw);
754 
755  // set the list of active boards
756  gtfeWordValue.setActiveBoards(m_activeBoardsGtEvm);
757 
758  // set alternative for number of BX per board
759  gtfeWordValue.setAltNrBxBoard(static_cast<uint16_t>(m_alternativeNrBxBoardEvm));
760 
761  // set the TOTAL_TRIGNR as read from iEvent
762  // TODO check again - PTC stuff
763 
764  gtfeWordValue.setTotalTriggerNr(static_cast<uint32_t>(iEvent.id().event()));
765 
766  // set the GPS time to the value read from Timestamp
767  edm::TimeValue_t evTime = iEvent.time().value();
768 
769  gtfeWordValue.setGpsTime(evTime);
770 
771  // LogDebug("L1GlobalTrigger")
772  //<< "\nEvent timestamp value [hex] = " << std::hex << evTime
773  //<< "\nBST retrieved value [hex] = " << gtfeWordValue.gpsTime()
774  //<< std::dec << std::endl;
775 
776  // source of BST message: DDDD simulated data
777  uint16_t bstSourceVal = 0xDDDD;
778  gtfeWordValue.setBstSource(bstSourceVal);
779 
780  // ** fill L1GtfeWord in GT EVM record
781 
782  gtEvmReadoutRecord->setGtfeWord(gtfeWordValue);
783  }
784 
785  break;
786  case FDL: {
787  evmNrFdlBoards++;
788  }
789 
790  break;
791  case TCS: {
792  L1TcsWord tcsWordValue;
793 
794  tcsWordValue.setBoardId(itBoard->gtBoardId());
795 
796  // bunch crossing
797  tcsWordValue.setBxNr(bxCrossHw);
798 
799  uint16_t trigType = 0x5; // 0101 simulated event
800  tcsWordValue.setTriggerType(trigType);
801 
802  // luminosity segment number
803  tcsWordValue.setLuminositySegmentNr(static_cast<uint16_t>(iEvent.luminosityBlock()));
804 
805  // set the Event_Nr as read from iEvent
806  tcsWordValue.setEventNr(static_cast<uint32_t>(iEvent.id().event()));
807 
808  // orbit number
809  tcsWordValue.setOrbitNr(static_cast<uint64_t>(iEvent.orbitNumber()));
810 
811  // ** fill L1TcsWord in the EVM record
812 
813  gtEvmReadoutRecord->setTcsWord(tcsWordValue);
814 
815  }
816 
817  break;
818  case TIM: {
819  // nothing
820  }
821 
822  break;
823  default: {
824  // do nothing, all blocks are given in GtBoardType enum
825  }
826 
827  break;
828  }
829  }
830  }
831  }
832  }
833 
834  // get the prescale factor set used in the actual luminosity segment
835  int pfAlgoSetIndex = 0; // FIXME
836  const std::vector<int> &prescaleFactorsAlgoTrig = (*m_prescaleFactorsAlgoTrig).at(pfAlgoSetIndex);
837 
838  int pfTechSetIndex = 0; // FIXME
839  const std::vector<int> &prescaleFactorsTechTrig = (*m_prescaleFactorsTechTrig).at(pfTechSetIndex);
840 
841  //
842 
843  // loop over BxInEvent
844  for (int iBxInEvent = minBxInEvent; iBxInEvent <= maxBxInEvent; ++iBxInEvent) {
845  // * receive GCT object data via PSBs
846  // LogDebug("L1GlobalTrigger")
847  //<< "\nL1GlobalTrigger : receiving PSB data for bx = " << iBxInEvent <<
848  //"\n"
849  //<< std::endl;
850 
853  iBxInEvent,
854  receiveNoIsoEG,
856  receiveIsoEG,
857  m_nrL1IsoEG,
858  receiveCenJet,
859  m_nrL1CenJet,
860  receiveForJet,
861  m_nrL1ForJet,
862  receiveTauJet,
863  m_nrL1TauJet,
864  receiveETM,
865  receiveETT,
866  receiveHTT,
867  receiveHTM,
868  receiveJetCounts,
869  receiveHfBitCounts,
870  receiveHfRingEtSums);
871 
875  iEvent, m_technicalTriggersInputTags, iBxInEvent, receiveTechTr, m_numberTechnicalTriggers);
876  }
877 
878  if (receiveExternal) {
879  // FIXME read the external conditions
880  }
881 
885  recordLength0,
886  recordLength1,
888  boardMaps,
889  iBxInEvent,
890  gtDaqReadoutRecord.get());
891  }
892 
893  // * receive GMT object data via GTL
894  // LogDebug("L1GlobalTrigger")
895  //<< "\nL1GlobalTrigger : receiving GMT data for bx = " << iBxInEvent <<
896  //"\n"
897  //<< std::endl;
898 
899  m_gtGTL->receiveGmtObjectData(iEvent, m_muGmtInputTag, iBxInEvent, receiveMu, m_nrL1Mu);
900 
901  // * run GTL
902  // LogDebug("L1GlobalTrigger")
903  //<< "\nL1GlobalTrigger : running GTL for bx = " << iBxInEvent << "\n"
904  //<< std::endl;
905 
906  m_gtGTL->run(iEvent,
907  evSetup,
908  m_gtPSB,
910  iBxInEvent,
911  gtObjectMapRecord.get(),
913  m_nrL1Mu,
915  m_nrL1IsoEG,
916  m_nrL1CenJet,
917  m_nrL1ForJet,
918  m_nrL1TauJet,
922 
923  // LogDebug("L1GlobalTrigger")
924  //<< "\n AlgorithmOR\n" << m_gtGTL->getAlgorithmOR() << "\n"
925  //<< std::endl;
926 
927  // * run FDL
928  // LogDebug("L1GlobalTrigger")
929  //<< "\nL1GlobalTrigger : running FDL for bx = " << iBxInEvent << "\n"
930  //<< std::endl;
931 
932  m_gtFDL->run(iEvent,
933  prescaleFactorsAlgoTrig,
934  prescaleFactorsTechTrig,
939  boardMaps,
941  iBxInEvent,
945  m_gtGTL,
946  m_gtPSB,
947  pfAlgoSetIndex,
948  pfTechSetIndex,
954 
955  if (m_produceL1GtDaqRecord && (daqNrFdlBoards > 0)) {
956  m_gtFDL->fillDaqFdlBlock(iBxInEvent,
958  recordLength0,
959  recordLength1,
961  boardMaps,
962  gtDaqReadoutRecord.get());
963  }
964 
965  if (m_produceL1GtEvmRecord && (evmNrFdlBoards > 0)) {
966  m_gtFDL->fillEvmFdlBlock(iBxInEvent,
968  recordLength0,
969  recordLength1,
971  boardMaps,
972  gtEvmReadoutRecord.get());
973  }
974 
975  // reset
976  m_gtPSB->reset();
977  m_gtGTL->reset();
978  m_gtFDL->reset();
979 
980  // LogDebug("L1GlobalTrigger") << "\n Reset PSB, GTL, FDL\n" << std::endl;
981  }
982 
983  if (receiveMu) {
984  // LogDebug("L1GlobalTrigger")
985  //<< "\n**** "
986  //<< "\n Persistent reference for L1MuGMTReadoutCollection with input tag:
987  //"
988  //<< m_muGmtInputTag
989  //<< "\n**** \n"
990  //<< std::endl;
991 
992  // get L1MuGMTReadoutCollection reference and set it in GT record
993 
995  iEvent.getByLabel(m_muGmtInputTag, gmtRcHandle);
996 
997  if (!gmtRcHandle.isValid()) {
998  if (m_verbosity) {
999  edm::LogWarning("L1GlobalTrigger") << "\nWarning: L1MuGMTReadoutCollection with input tag " << m_muGmtInputTag
1000  << "\nrequested in configuration, but not found in the event.\n"
1001  << std::endl;
1002  }
1003  } else {
1004  gtDaqReadoutRecord->setMuCollectionRefProd(gmtRcHandle);
1005  }
1006  }
1007 
1008  if (m_verbosity && m_isDebugEnabled) {
1009  std::ostringstream myCoutStream;
1010  gtDaqReadoutRecord->print(myCoutStream);
1011  LogTrace("L1GlobalTrigger") << "\n The following L1 GT DAQ readout record was produced:\n"
1012  << myCoutStream.str() << "\n"
1013  << std::endl;
1014 
1015  myCoutStream.str("");
1016  myCoutStream.clear();
1017 
1018  gtEvmReadoutRecord->print(myCoutStream);
1019  LogTrace("L1GlobalTrigger") << "\n The following L1 GT EVM readout record was produced:\n"
1020  << myCoutStream.str() << "\n"
1021  << std::endl;
1022 
1023  myCoutStream.str("");
1024  myCoutStream.clear();
1025 
1026  const std::vector<L1GlobalTriggerObjectMap> objMapVec = gtObjectMapRecord->gtObjectMap();
1027 
1028  for (std::vector<L1GlobalTriggerObjectMap>::const_iterator it = objMapVec.begin(); it != objMapVec.end(); ++it) {
1029  (*it).print(myCoutStream);
1030  }
1031 
1032  LogDebug("L1GlobalTrigger") << "Test gtObjectMapRecord in L1GlobalTrigger \n\n"
1033  << myCoutStream.str() << "\n\n"
1034  << std::endl;
1035 
1036  myCoutStream.str("");
1037  myCoutStream.clear();
1038  }
1039 
1040  // **
1041  // register products
1042  if (m_produceL1GtDaqRecord) {
1043  iEvent.put(std::move(gtDaqReadoutRecord));
1044  }
1045 
1046  if (m_produceL1GtEvmRecord) {
1047  iEvent.put(std::move(gtEvmReadoutRecord));
1048  }
1049 
1051  iEvent.put(std::move(gtObjectMapRecord));
1052  }
1053 }
1054 
1055 // static data members
1056 
const std::vector< edm::InputTag > m_technicalTriggersInputTags
input tag for technical triggers
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
bool isDebugEnabled()
const L1GtTriggerMask * m_l1GtTmVetoTech
void init(const int nrL1Mu, const int numberPhysTriggers)
initialize the class (mainly reserve)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const L1GtTriggerMask * m_l1GtTmVetoAlgo
unsigned int gtIfCaloEtaNumberBits() const
get / set the number of bits for eta of calorimeter objects
const std::vector< int > m_recordLength
unsigned long long m_l1GtParCacheID
const L1GtStableParameters * m_l1GtStablePar
cached stuff
const int gtTotalBxInEvent() const
get / set the total Bx&#39;s in the event
std::vector< unsigned int > m_triggerMaskVetoAlgoTrig
void setBxNr(cms_uint16_t bxNrValue)
Definition: L1GtfeWord.h:95
const edm::InputTag m_caloGctInputTag
input tag for calorimeter collections from GCT
void setBstSource(const cms_uint16_t bstSourceVal)
Definition: L1GtfeExtWord.h:98
unsigned int gtNumberL1JetCounts() const
get / set the number of L1 jet counts received by GT
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
const bool m_readTechnicalTriggerRecords
logical flag to read the technical trigger records
std::vector< unsigned int > m_triggerMaskAlgoTrig
void setBxNr(const cms_uint16_t bxNrValue)
Definition: L1TcsWord.h:75
edm::ESGetToken< L1GtTriggerMask, L1GtTriggerMaskAlgoTrigRcd > m_l1GtTmAlgoToken
unsigned int gtNumberL1NoIsoEG() const
get / set the number of L1 e/gamma objects received by GT
const bool m_technicalTriggersVetoUnmasked
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
const bool m_produceL1GtObjectMapRecord
logical flag to produce the L1 GT object map record
edm::ESGetToken< L1GtTriggerMask, L1GtTriggerMaskVetoAlgoTrigRcd > m_l1GtTmVetoAlgoToken
const uint16_t gtEvmActiveBoards() const
get / set the active boards for L1 GT EVM record
const bool m_writePsbL1GtDaqRecord
logical flag to write the PSB content in the L1 GT DAQ record
unsigned long long m_l1GtStableParCacheID
void setRecordLength(cms_uint16_t recordLengthValue)
Definition: L1GtfeWord.h:84
const bool m_produceL1GtDaqRecord
logical flag to produce the L1 GT DAQ readout record
void setLuminositySegmentNr(const cms_uint16_t luminositySegmentNrValue)
Definition: L1TcsWord.h:123
const L1GtPrescaleFactors * m_l1GtPfAlgo
prescale factors
void fillPsbBlock(edm::Event &iEvent, const uint16_t &activeBoardsGtDaq, const int recordLength0, const int recordLength1, const unsigned int altNrBxBoardDaq, const std::vector< L1GtBoard > &boardMaps, const int iBxInEvent, L1GlobalTriggerReadoutRecord *gtDaqReadoutRecord)
fill the content of active PSB boards
unsigned int m_numberPhysTriggers
number of physics triggers
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
L1GlobalTrigger(const edm::ParameterSet &)
L1GlobalTriggerGTL * m_gtGTL
unsigned int m_bstLengthBytes
length of BST record (in bytes) from event setup
const std::vector< std::vector< int > > * m_prescaleFactorsTechTrig
#define LogTrace(id)
std::vector< unsigned int > m_triggerMaskVetoTechTrig
const bool m_produceL1GtEvmRecord
logical flag to produce the L1 GT EVM readout record
edm::ESGetToken< L1GtTriggerMask, L1GtTriggerMaskTechTrigRcd > m_l1GtTmTechToken
edm::ESGetToken< L1GtParameters, L1GtParametersRcd > m_l1GtParToken
const uint16_t gtDaqActiveBoards() const
get / set the active boards for L1 GT DAQ record
const bool m_algorithmTriggersUnmasked
void setAltNrBxBoard(cms_uint16_t altNrBxBoardValue)
Definition: L1GtfeWord.h:136
void setTotalTriggerNr(cms_uint32_t totalTriggerNrValue)
Definition: L1GtfeWord.h:151
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
const L1GtTriggerMask * m_l1GtTmTech
const bool m_technicalTriggersUnmasked
void setVerbosity(const int verbosity)
void setVerbosity(const int verbosity)
unsigned int gtNumberL1IsoEG() const
get / set the number of L1 isolated e/gamma objects received by GT
unsigned int gtNumberL1TauJet() const
get / set the number of L1 tau jets received by GT
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
unsigned int gtNumberL1ForJet() const
get / set the number of L1 forward jets received by GT
void fillDaqFdlBlock(const int iBxInEvent, const uint16_t &activeBoardsGtDaq, const int recordLength0, const int recordLength1, const unsigned int altNrBxBoardDaq, const std::vector< L1GtBoard > &boardMaps, L1GlobalTriggerReadoutRecord *gtDaqReadoutRecord)
fill the FDL block in the L1 GT DAQ record for iBxInEvent
const unsigned int m_alternativeNrBxBoardEvm
edm::ESGetToken< L1GtBoardMaps, L1GtBoardMapsRcd > m_l1GtBMToken
unsigned int gtNumberL1CenJet() const
get / set the number of L1 central jets received by GT
L1GlobalTriggerFDL * m_gtFDL
T get() const
Definition: EventSetup.h:82
const bool m_algorithmTriggersUnprescaled
const bool m_isDebugEnabled
void fillEvmFdlBlock(const int iBxInEvent, const uint16_t &activeBoardsGtEvm, const int recordLength0, const int recordLength1, const unsigned int altNrBxBoardEvm, const std::vector< L1GtBoard > &boardMaps, L1GlobalTriggerEvmReadoutRecord *gtEvmReadoutRecord)
fill the FDL block in the L1 GT EVM record for iBxInEvent
const L1GtParameters * m_l1GtPar
parameters
std::vector< unsigned int > m_triggerMaskTechTrig
void run(edm::Event &iEvent, const edm::EventSetup &evSetup, const L1GlobalTriggerPSB *ptrGtPSB, const bool produceL1GtObjectMapRecord, const int iBxInEvent, 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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const L1GtPrescaleFactors * m_l1GtPfTech
unsigned long long m_l1GtTmAlgoCacheID
void setRecordLength1(cms_uint16_t recordLengthValue)
Definition: L1GtfeWord.h:73
const std::vector< L1GtBoard > & gtBoardMaps() const
get / set / print the L1 GT board map
Definition: L1GtBoardMaps.h:43
unsigned long long TimeValue_t
Definition: Timestamp.h:21
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
const int m_verbosity
verbosity level
void setBoardId(cms_uint16_t boardIdValue)
set BoardId from a BoardId value
Definition: L1GtfeWord.h:61
void setBoardId(const cms_uint16_t boardIdValue)
set BoardId from a BoardId value
Definition: L1TcsWord.h:63
void reset()
clear FDL
~L1GlobalTrigger() override
const L1GtTriggerMask * m_l1GtTmAlgo
trigger masks & veto masks
void produce(edm::Event &, const edm::EventSetup &) override
unsigned int gtNumberL1Mu() const
get / set the number of L1 muons received by GT
void setActiveBoards(cms_uint16_t activeBoardsValue)
Definition: L1GtfeWord.h:121
edm::ESGetToken< L1GtStableParameters, L1GtStableParametersRcd > m_l1GtStableParToken
EventSetup Tokens.
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
uint16_t m_activeBoardsGtDaq
active boards in L1 GT DAQ record and in L1 GT EVM record
unsigned long long m_l1GtBMCacheID
L1GlobalTriggerPSB * m_gtPSB
bool isValid() const
Definition: HandleBase.h:70
const edm::InputTag m_muGmtInputTag
input tag for muon collection from GMT
edm::ESGetToken< L1GtPrescaleFactors, L1GtPrescaleFactorsTechTrigRcd > m_l1GtPfTechToken
const bool m_technicalTriggersUnprescaled
HLT enums.
const int m_psBstLengthBytes
length of BST record (in bytes) from parameter set
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, const bool algorithmTriggersUnprescaled, const bool algorithmTriggersUnmasked, const bool technicalTriggersUnprescaled, const bool technicalTriggersUnmasked, const bool technicalTriggersVetoUnmasked)
run the FDL
uint16_t m_activeBoardsGtEvm
const unsigned int m_alternativeNrBxBoardDaq
void setGpsTime(const cms_uint64_t)
void setTriggerType(const cms_uint16_t triggerTypeValue)
Definition: L1TcsWord.h:99
edm::ESGetToken< L1GtPrescaleFactors, L1GtPrescaleFactorsAlgoTrigRcd > m_l1GtPfAlgoToken
int m_totalBxInEvent
total number of Bx&#39;s in the event coming from EventSetup
unsigned int gtNumberTechnicalTriggers() const
get / set the number of technical triggers
unsigned int m_numberTechnicalTriggers
number of technical triggers
Log< level::Warning, false > LogWarning
void setEventNr(const cms_uint32_t eventNrValue)
Definition: L1TcsWord.h:175
void setVerbosity(const int verbosity)
const L1GtBoardMaps * m_l1GtBM
board maps - cache only the record
unsigned long long m_l1GtTmTechCacheID
unsigned int m_numberDaqPartitions
number of DAQ partitions
unsigned int gtIfMuEtaNumberBits() const
get / set the number of bits for eta of muon objects
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)
const unsigned int gtBstLengthBytes() const
get / set length of BST message (in bytes) for L1 GT EVM record
const edm::InputTag m_castorInputTag
input tag for CASTOR record
void setOrbitNr(const cms_uint64_t orbitNrValue)
Definition: L1TcsWord.h:187
def move(src, dest)
Definition: eostools.py:511
unsigned long long m_l1GtTmVetoAlgoCacheID
edm::ESGetToken< L1GtTriggerMask, L1GtTriggerMaskVetoTechTrigRcd > m_l1GtTmVetoTechToken
unsigned long long m_l1GtPfAlgoCacheID
unsigned int gtNumberPhysTriggers() const
get / set the number of physics trigger algorithms
#define LogDebug(id)
void reset()
clear GTL