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();
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 daqNrFdlBoards = 0;
444  int daqNrPsbBoards = 0;
445 
446  //
447  bool receiveMu = false;
448  bool receiveNoIsoEG = false;
449  bool receiveIsoEG = false;
450  bool receiveCenJet = false;
451  bool receiveForJet = false;
452  bool receiveTauJet = false;
453  bool receiveETM = false;
454  bool receiveETT = false;
455  bool receiveHTT = false;
456  bool receiveHTM = false;
457  bool receiveJetCounts = false;
458  bool receiveHfBitCounts = false;
459  bool receiveHfRingEtSums = false;
460 
461  bool receiveExternal = false;
462 
463  bool receiveTechTr = false;
464 
465  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
466  int iPosition = itBoard->gtPositionDaqRecord();
467  if (iPosition > 0) {
468  int iActiveBit = itBoard->gtBitDaqActiveBoards();
469  bool activeBoard = false;
470 
471  if (iActiveBit >= 0) {
472  activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
473  }
474 
475  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit <
476  // 0)
477  // in the record and ActiveBoardsMap, and active
478  if ((iActiveBit < 0) || activeBoard) {
479  switch (itBoard->gtBoardType()) {
480  case FDL: {
481  daqNrFdlBoards++;
482  }
483 
484  break;
485  case PSB: {
486  daqNrPsbBoards++;
487 
488  // get the objects coming to this PSB
489  std::vector<L1GtPsbQuad> quadInPsb = itBoard->gtQuadInPsb();
490  for (std::vector<L1GtPsbQuad>::const_iterator itQuad = quadInPsb.begin(); itQuad != quadInPsb.end();
491  ++itQuad) {
492  switch (*itQuad) {
493  case TechTr: {
494  receiveTechTr = true;
495  }
496 
497  break;
498  case NoIsoEGQ: {
499  receiveNoIsoEG = true;
500  }
501 
502  break;
503  case IsoEGQ: {
504  receiveIsoEG = true;
505  }
506 
507  break;
508  case CenJetQ: {
509  receiveCenJet = true;
510  }
511 
512  break;
513  case ForJetQ: {
514  receiveForJet = true;
515  }
516 
517  break;
518  case TauJetQ: {
519  receiveTauJet = true;
520  }
521 
522  break;
523  case ESumsQ: {
524  receiveETM = true;
525  receiveETT = true;
526  receiveHTT = true;
527  receiveHTM = true;
528  }
529 
530  break;
531  case JetCountsQ: {
532  receiveJetCounts = true;
533  }
534 
535  break;
536  case CastorQ: {
537  // obsolete
538  }
539 
540  break;
541  case BptxQ: {
542  // obsolete
543  }
544 
545  break;
546  case GtExternalQ: {
547  receiveExternal = true;
548  }
549 
550  break;
551  case HfQ: {
552  receiveHfBitCounts = true;
553  receiveHfRingEtSums = true;
554  }
555 
556  break;
557  // FIXME add MIP/Iso bits
558  default: {
559  // do nothing
560  }
561 
562  break;
563  }
564  }
565 
566  }
567 
568  break;
569  default: {
570  // do nothing, all blocks are given in GtBoardType enum
571  }
572 
573  break;
574  }
575  }
576  }
577  }
578 
579  // produce the L1GlobalTriggerReadoutRecord now, after we found how many
580  // BxInEvent the record has and how many boards are active
581  std::unique_ptr<L1GlobalTriggerReadoutRecord> gtDaqReadoutRecord(
582  new L1GlobalTriggerReadoutRecord(m_emulateBxInEvent, daqNrFdlBoards, daqNrPsbBoards));
583 
584  // * produce the L1GlobalTriggerEvmReadoutRecord
585  std::unique_ptr<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord(
587  // daqNrFdlBoards OK, just reserve memory at this point
588 
589  // * produce the L1GlobalTriggerObjectMapRecord
590  std::unique_ptr<L1GlobalTriggerObjectMapRecord> gtObjectMapRecord(new L1GlobalTriggerObjectMapRecord());
591 
592  // fill the boards not depending on the BxInEvent in the L1 GT DAQ record
593  // GMT, PSB and FDL depend on BxInEvent
594 
595  // fill in emulator the same bunch crossing (12 bits - hardwired number of
596  // bits...) and the same local bunch crossing for all boards
597  int bxCross = iEvent.bunchCrossing();
598  uint16_t bxCrossHw = 0;
599  if ((bxCross & 0xFFF) == bxCross) {
600  bxCrossHw = static_cast<uint16_t>(bxCross);
601  } else {
602  bxCrossHw = 0; // Bx number too large, set to 0!
603  if (m_verbosity) {
604  LogDebug("L1GlobalTrigger") << "\nBunch cross number [hex] = " << std::hex << bxCross
605  << "\n larger than 12 bits. Set to 0! \n"
606  << std::dec << std::endl;
607  }
608  }
609 
611  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
612  int iPosition = itBoard->gtPositionDaqRecord();
613  if (iPosition > 0) {
614  int iActiveBit = itBoard->gtBitDaqActiveBoards();
615  bool activeBoard = false;
616 
617  if (iActiveBit >= 0) {
618  activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
619  }
620 
621  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit <
622  // 0)
623  // in the record and ActiveBoardsMap, and active
624  if ((iActiveBit < 0) || activeBoard) {
625  switch (itBoard->gtBoardType()) {
626  case GTFE: {
627  L1GtfeWord gtfeWordValue;
628 
629  gtfeWordValue.setBoardId(itBoard->gtBoardId());
630 
631  // cast int to uint16_t
632  // there are normally 3 or 5 BxInEvent
633  gtfeWordValue.setRecordLength(static_cast<uint16_t>(recordLength0));
634 
635  gtfeWordValue.setRecordLength1(static_cast<uint16_t>(recordLength1));
636 
637  // bunch crossing
638  gtfeWordValue.setBxNr(bxCrossHw);
639 
640  // set the list of active boards
641  gtfeWordValue.setActiveBoards(m_activeBoardsGtDaq);
642 
643  // set alternative for number of BX per board
644  gtfeWordValue.setAltNrBxBoard(static_cast<uint16_t>(m_alternativeNrBxBoardDaq));
645 
646  // set the TOTAL_TRIGNR as read from iEvent
647  // TODO check again - PTC stuff
648 
649  gtfeWordValue.setTotalTriggerNr(static_cast<uint32_t>(iEvent.id().event()));
650 
651  // ** fill L1GtfeWord in GT DAQ record
652 
653  gtDaqReadoutRecord->setGtfeWord(gtfeWordValue);
654  }
655 
656  break;
657  case TCS: {
658  // nothing
659  }
660 
661  break;
662  case TIM: {
663  // nothing
664  }
665 
666  break;
667  default: {
668  // do nothing, all blocks are given in GtBoardType enum
669  }
670 
671  break;
672  }
673  }
674  }
675  }
676  }
677 
678  // fill the boards not depending on the BxInEvent in the L1 GT EVM record
679 
680  int evmNrFdlBoards = 0;
681 
683  // get the length of the BST message from parameter set or from event setup
684 
685  int bstLengthBytes = 0;
686 
687  if (m_psBstLengthBytes < 0) {
688  // length from event setup
689  bstLengthBytes = static_cast<int>(m_bstLengthBytes);
690 
691  } else {
692  // length from parameter set
693  bstLengthBytes = m_psBstLengthBytes;
694  }
695 
696  if (m_verbosity) {
697  LogTrace("L1GlobalTrigger") << "\n Length of BST message (in bytes): " << bstLengthBytes << "\n" << std::endl;
698  }
699 
700  for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
701  int iPosition = itBoard->gtPositionEvmRecord();
702  if (iPosition > 0) {
703  int iActiveBit = itBoard->gtBitEvmActiveBoards();
704  bool activeBoard = false;
705 
706  if (iActiveBit >= 0) {
707  activeBoard = m_activeBoardsGtEvm & (1 << iActiveBit);
708  }
709 
710  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit <
711  // 0)
712  // in the record and ActiveBoardsMap, and active
713  if ((iActiveBit < 0) || activeBoard) {
714  switch (itBoard->gtBoardType()) {
715  case GTFE: {
716  L1GtfeExtWord gtfeWordValue(bstLengthBytes);
717 
718  gtfeWordValue.setBoardId(itBoard->gtBoardId());
719 
720  // cast int to uint16_t
721  // there are normally 3 or 5 BxInEvent
722  gtfeWordValue.setRecordLength(static_cast<uint16_t>(recordLength0));
723 
724  gtfeWordValue.setRecordLength1(static_cast<uint16_t>(recordLength1));
725 
726  // bunch crossing
727  gtfeWordValue.setBxNr(bxCrossHw);
728 
729  // set the list of active boards
730  gtfeWordValue.setActiveBoards(m_activeBoardsGtEvm);
731 
732  // set alternative for number of BX per board
733  gtfeWordValue.setAltNrBxBoard(static_cast<uint16_t>(m_alternativeNrBxBoardEvm));
734 
735  // set the TOTAL_TRIGNR as read from iEvent
736  // TODO check again - PTC stuff
737 
738  gtfeWordValue.setTotalTriggerNr(static_cast<uint32_t>(iEvent.id().event()));
739 
740  // set the GPS time to the value read from Timestamp
741  edm::TimeValue_t evTime = iEvent.time().value();
742 
743  gtfeWordValue.setGpsTime(evTime);
744 
745  // LogDebug("L1GlobalTrigger")
746  //<< "\nEvent timestamp value [hex] = " << std::hex << evTime
747  //<< "\nBST retrieved value [hex] = " << gtfeWordValue.gpsTime()
748  //<< std::dec << std::endl;
749 
750  // source of BST message: DDDD simulated data
751  uint16_t bstSourceVal = 0xDDDD;
752  gtfeWordValue.setBstSource(bstSourceVal);
753 
754  // ** fill L1GtfeWord in GT EVM record
755 
756  gtEvmReadoutRecord->setGtfeWord(gtfeWordValue);
757  }
758 
759  break;
760  case FDL: {
761  evmNrFdlBoards++;
762  }
763 
764  break;
765  case TCS: {
766  L1TcsWord tcsWordValue;
767 
768  tcsWordValue.setBoardId(itBoard->gtBoardId());
769 
770  // bunch crossing
771  tcsWordValue.setBxNr(bxCrossHw);
772 
773  uint16_t trigType = 0x5; // 0101 simulated event
774  tcsWordValue.setTriggerType(trigType);
775 
776  // luminosity segment number
777  tcsWordValue.setLuminositySegmentNr(static_cast<uint16_t>(iEvent.luminosityBlock()));
778 
779  // set the Event_Nr as read from iEvent
780  tcsWordValue.setEventNr(static_cast<uint32_t>(iEvent.id().event()));
781 
782  // orbit number
783  tcsWordValue.setOrbitNr(static_cast<uint64_t>(iEvent.orbitNumber()));
784 
785  // ** fill L1TcsWord in the EVM record
786 
787  gtEvmReadoutRecord->setTcsWord(tcsWordValue);
788 
789  }
790 
791  break;
792  case TIM: {
793  // nothing
794  }
795 
796  break;
797  default: {
798  // do nothing, all blocks are given in GtBoardType enum
799  }
800 
801  break;
802  }
803  }
804  }
805  }
806  }
807 
808  // get the prescale factor set used in the actual luminosity segment
809  int pfAlgoSetIndex = 0; // FIXME
810  const std::vector<int> &prescaleFactorsAlgoTrig = (*m_prescaleFactorsAlgoTrig).at(pfAlgoSetIndex);
811 
812  int pfTechSetIndex = 0; // FIXME
813  const std::vector<int> &prescaleFactorsTechTrig = (*m_prescaleFactorsTechTrig).at(pfTechSetIndex);
814 
815  //
816 
817  // loop over BxInEvent
818  for (int iBxInEvent = minBxInEvent; iBxInEvent <= maxBxInEvent; ++iBxInEvent) {
819  // * receive GCT object data via PSBs
820  // LogDebug("L1GlobalTrigger")
821  //<< "\nL1GlobalTrigger : receiving PSB data for bx = " << iBxInEvent <<
822  //"\n"
823  //<< std::endl;
824 
827  iBxInEvent,
828  receiveNoIsoEG,
830  receiveIsoEG,
831  m_nrL1IsoEG,
832  receiveCenJet,
833  m_nrL1CenJet,
834  receiveForJet,
835  m_nrL1ForJet,
836  receiveTauJet,
837  m_nrL1TauJet,
838  receiveETM,
839  receiveETT,
840  receiveHTT,
841  receiveHTM,
842  receiveJetCounts,
843  receiveHfBitCounts,
844  receiveHfRingEtSums);
845 
849  iEvent, m_technicalTriggersInputTags, iBxInEvent, receiveTechTr, m_numberTechnicalTriggers);
850  }
851 
852  if (receiveExternal) {
853  // FIXME read the external conditions
854  }
855 
859  recordLength0,
860  recordLength1,
862  boardMaps,
863  iBxInEvent,
864  gtDaqReadoutRecord.get());
865  }
866 
867  // * receive GMT object data via GTL
868  // LogDebug("L1GlobalTrigger")
869  //<< "\nL1GlobalTrigger : receiving GMT data for bx = " << iBxInEvent <<
870  //"\n"
871  //<< std::endl;
872 
873  m_gtGTL->receiveGmtObjectData(iEvent, m_muGmtInputTag, iBxInEvent, receiveMu, m_nrL1Mu);
874 
875  // * run GTL
876  // LogDebug("L1GlobalTrigger")
877  //<< "\nL1GlobalTrigger : running GTL for bx = " << iBxInEvent << "\n"
878  //<< std::endl;
879 
880  m_gtGTL->run(iEvent,
881  evSetup,
882  m_gtPSB,
884  iBxInEvent,
885  gtObjectMapRecord.get(),
887  m_nrL1Mu,
889  m_nrL1IsoEG,
890  m_nrL1CenJet,
891  m_nrL1ForJet,
892  m_nrL1TauJet,
896 
897  // LogDebug("L1GlobalTrigger")
898  //<< "\n AlgorithmOR\n" << m_gtGTL->getAlgorithmOR() << "\n"
899  //<< std::endl;
900 
901  // * run FDL
902  // LogDebug("L1GlobalTrigger")
903  //<< "\nL1GlobalTrigger : running FDL for bx = " << iBxInEvent << "\n"
904  //<< std::endl;
905 
906  m_gtFDL->run(iEvent,
907  prescaleFactorsAlgoTrig,
908  prescaleFactorsTechTrig,
913  boardMaps,
915  iBxInEvent,
919  m_gtGTL,
920  m_gtPSB,
921  pfAlgoSetIndex,
922  pfTechSetIndex,
928 
929  if (m_produceL1GtDaqRecord && (daqNrFdlBoards > 0)) {
930  m_gtFDL->fillDaqFdlBlock(iBxInEvent,
932  recordLength0,
933  recordLength1,
935  boardMaps,
936  gtDaqReadoutRecord.get());
937  }
938 
939  if (m_produceL1GtEvmRecord && (evmNrFdlBoards > 0)) {
940  m_gtFDL->fillEvmFdlBlock(iBxInEvent,
942  recordLength0,
943  recordLength1,
945  boardMaps,
946  gtEvmReadoutRecord.get());
947  }
948 
949  // reset
950  m_gtPSB->reset();
951  m_gtGTL->reset();
952  m_gtFDL->reset();
953 
954  // LogDebug("L1GlobalTrigger") << "\n Reset PSB, GTL, FDL\n" << std::endl;
955  }
956 
957  if (receiveMu) {
958  // LogDebug("L1GlobalTrigger")
959  //<< "\n**** "
960  //<< "\n Persistent reference for L1MuGMTReadoutCollection with input tag:
961  //"
962  //<< m_muGmtInputTag
963  //<< "\n**** \n"
964  //<< std::endl;
965 
966  // get L1MuGMTReadoutCollection reference and set it in GT record
967 
969  iEvent.getByLabel(m_muGmtInputTag, gmtRcHandle);
970 
971  if (!gmtRcHandle.isValid()) {
972  if (m_verbosity) {
973  edm::LogWarning("L1GlobalTrigger") << "\nWarning: L1MuGMTReadoutCollection with input tag " << m_muGmtInputTag
974  << "\nrequested in configuration, but not found in the event.\n"
975  << std::endl;
976  }
977  } else {
978  gtDaqReadoutRecord->setMuCollectionRefProd(gmtRcHandle);
979  }
980  }
981 
982  if (m_verbosity && m_isDebugEnabled) {
983  std::ostringstream myCoutStream;
984  gtDaqReadoutRecord->print(myCoutStream);
985  LogTrace("L1GlobalTrigger") << "\n The following L1 GT DAQ readout record was produced:\n"
986  << myCoutStream.str() << "\n"
987  << std::endl;
988 
989  myCoutStream.str("");
990  myCoutStream.clear();
991 
992  gtEvmReadoutRecord->print(myCoutStream);
993  LogTrace("L1GlobalTrigger") << "\n The following L1 GT EVM readout record was produced:\n"
994  << myCoutStream.str() << "\n"
995  << std::endl;
996 
997  myCoutStream.str("");
998  myCoutStream.clear();
999 
1000  const std::vector<L1GlobalTriggerObjectMap> objMapVec = gtObjectMapRecord->gtObjectMap();
1001 
1002  for (std::vector<L1GlobalTriggerObjectMap>::const_iterator it = objMapVec.begin(); it != objMapVec.end(); ++it) {
1003  (*it).print(myCoutStream);
1004  }
1005 
1006  LogDebug("L1GlobalTrigger") << "Test gtObjectMapRecord in L1GlobalTrigger \n\n"
1007  << myCoutStream.str() << "\n\n"
1008  << std::endl;
1009 
1010  myCoutStream.str("");
1011  myCoutStream.clear();
1012  }
1013 
1014  // **
1015  // register products
1016  if (m_produceL1GtDaqRecord) {
1017  iEvent.put(std::move(gtDaqReadoutRecord));
1018  }
1019 
1020  if (m_produceL1GtEvmRecord) {
1021  iEvent.put(std::move(gtEvmReadoutRecord));
1022  }
1023 
1025  iEvent.put(std::move(gtObjectMapRecord));
1026  }
1027 }
1028 
1029 // static data members
1030 
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:79
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:130
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