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