CMS 3D CMS Logo

L1TGlobalProducer.cc
Go to the documentation of this file.
1 // L1TGlobalProducer.cc
2 //author: Brian Winer - Ohio State
3 // Vladimir Rekovic - extend for overlap removal
4 // Elisa Fontanesi - extended for three-body correlation conditions
5 
7 
8 // system include files
9 #include <memory>
10 #include <iostream>
11 #include <iomanip>
12 #include <algorithm>
13 
24 
26 
30 
32 
33 #include "TriggerMenuParser.h"
34 
35 using namespace l1t;
36 
39  // These parameters are part of the L1T/HLT interface, avoid changing if possible::
40  desc.add<edm::InputTag>("MuonInputTag", edm::InputTag(""))
41  ->setComment("InputTag for Global Muon Trigger (required parameter: default value is invalid)");
42  desc.add<edm::InputTag>("MuonShowerInputTag", edm::InputTag(""))
43  ->setComment("InputTag for Global Muon Shower Trigger (required parameter: default value is invalid)");
44  desc.add<edm::InputTag>("EGammaInputTag", edm::InputTag(""))
45  ->setComment("InputTag for Calo Trigger EGamma (required parameter: default value is invalid)");
46  desc.add<edm::InputTag>("TauInputTag", edm::InputTag(""))
47  ->setComment("InputTag for Calo Trigger Tau (required parameter: default value is invalid)");
48  desc.add<edm::InputTag>("JetInputTag", edm::InputTag(""))
49  ->setComment("InputTag for Calo Trigger Jet (required parameter: default value is invalid)");
50  desc.add<edm::InputTag>("EtSumInputTag", edm::InputTag(""))
51  ->setComment("InputTag for Calo Trigger EtSum (required parameter: default value is invalid)");
52  desc.add<edm::InputTag>("EtSumZdcInputTag", edm::InputTag(""))
53  ->setComment("InputTag for ZDC EtSums Plus and Minus (required parameter: default value is invalid)");
54  desc.add<edm::InputTag>("CICADAInputTag", edm::InputTag(""))
55  ->setComment("InputTag for CICADA Anomaly Detection (required parameter: default value is invalid)");
56  desc.add<edm::InputTag>("ExtInputTag", edm::InputTag(""))
57  ->setComment("InputTag for external conditions (not required, but recommend to specify explicitly in config)");
58  desc.add<edm::InputTag>("AlgoBlkInputTag", edm::InputTag("hltGtStage2Digis"))
59  ->setComment(
60  "InputTag for unpacked Algblk (required only if GetPrescaleColumnFromData orRequireMenuToMatchAlgoBlkInput "
61  "set to true)");
62  desc.add<bool>("GetPrescaleColumnFromData", false)
63  ->setComment("Get prescale column from unpacked GlobalAlgBck. Otherwise use value specified in PrescaleSet");
64  desc.add<bool>("AlgorithmTriggersUnprescaled", false)
65  ->setComment("not required, but recommend to specify explicitly in config");
66  desc.add<bool>("RequireMenuToMatchAlgoBlkInput", true)
67  ->setComment(
68  "This requires that the L1 menu record to match the menu used to produce the inputed L1 results, should be "
69  "true when used by the HLT to produce the object map");
70  desc.add<bool>("AlgorithmTriggersUnmasked", false)
71  ->setComment("not required, but recommend to specify explicitly in config");
72 
73  // switch for muon showers in Run-3
74  desc.add<bool>("useMuonShowers", false);
75 
76  // disables resetting the prescale counters each lumisection (needed for offline)
77  // originally, the L1T firmware applied the reset of prescale counters at the end of every LS;
78  // this reset was disabled in the L1T firmware starting from run-362658 (November 25th, 2022), see
79  // https://github.com/cms-sw/cmssw/pull/37395#issuecomment-1323437044
80  desc.add<bool>("resetPSCountersEachLumiSec", false);
81 
82  // initialise prescale counters with a semi-random value in the range [0, prescale*10^precision - 1];
83  // if false, the prescale counters are initialised to zero
84  desc.add<bool>("semiRandomInitialPSCounters", false);
85 
86  // These parameters have well defined default values and are not currently
87  // part of the L1T/HLT interface. They can be cleaned up or updated at will:
88  desc.add<bool>("ProduceL1GtDaqRecord", true);
89  desc.add<bool>("ProduceL1GtObjectMapRecord", true);
90  desc.add<int>("EmulateBxInEvent", 1);
91  desc.add<int>("L1DataBxInEvent", 5);
92  desc.add<unsigned int>("AlternativeNrBxBoardDaq", 0);
93  desc.add<int>("BstLengthBytes", -1);
94  desc.add<unsigned int>("PrescaleSet", 1);
95  desc.addUntracked<int>("Verbosity", 0);
96  desc.addUntracked<bool>("PrintL1Menu", false);
97  desc.add<std::string>("TriggerMenuLuminosity", "startup");
98  descriptions.add("L1TGlobalProducer", desc);
99 }
100 
101 // constructors
102 
104  : m_muInputTag(parSet.getParameter<edm::InputTag>("MuonInputTag")),
105  m_muShowerInputTag(parSet.getParameter<edm::InputTag>("MuonShowerInputTag")),
106  m_egInputTag(parSet.getParameter<edm::InputTag>("EGammaInputTag")),
107  m_tauInputTag(parSet.getParameter<edm::InputTag>("TauInputTag")),
108  m_jetInputTag(parSet.getParameter<edm::InputTag>("JetInputTag")),
109  m_sumInputTag(parSet.getParameter<edm::InputTag>("EtSumInputTag")),
110  m_sumZdcInputTag(parSet.getParameter<edm::InputTag>("EtSumZdcInputTag")),
111  m_CICADAInputTag(parSet.getParameter<edm::InputTag>("CICADAInputTag")),
112  m_extInputTag(parSet.getParameter<edm::InputTag>("ExtInputTag")),
113 
114  m_produceL1GtDaqRecord(parSet.getParameter<bool>("ProduceL1GtDaqRecord")),
115  m_produceL1GtObjectMapRecord(parSet.getParameter<bool>("ProduceL1GtObjectMapRecord")),
116 
117  m_emulateBxInEvent(parSet.getParameter<int>("EmulateBxInEvent")),
118  m_L1DataBxInEvent(parSet.getParameter<int>("L1DataBxInEvent")),
119 
120  m_alternativeNrBxBoardDaq(parSet.getParameter<unsigned int>("AlternativeNrBxBoardDaq")),
121  m_psBstLengthBytes(parSet.getParameter<int>("BstLengthBytes")),
122 
123  m_prescaleSet(parSet.getParameter<unsigned int>("PrescaleSet")),
124 
125  m_algorithmTriggersUnprescaled(parSet.getParameter<bool>("AlgorithmTriggersUnprescaled")),
126  m_algorithmTriggersUnmasked(parSet.getParameter<bool>("AlgorithmTriggersUnmasked")),
127 
128  m_verbosity(parSet.getUntrackedParameter<int>("Verbosity")),
129  m_printL1Menu(parSet.getUntrackedParameter<bool>("PrintL1Menu")),
130  m_isDebugEnabled(edm::isDebugEnabled()),
131  m_getPrescaleColumnFromData(parSet.getParameter<bool>("GetPrescaleColumnFromData")),
132  m_requireMenuToMatchAlgoBlkInput(parSet.getParameter<bool>("RequireMenuToMatchAlgoBlkInput")),
133  m_algoblkInputTag(parSet.getParameter<edm::InputTag>("AlgoBlkInputTag")),
134  m_resetPSCountersEachLumiSec(parSet.getParameter<bool>("resetPSCountersEachLumiSec")),
135  m_semiRandomInitialPSCounters(parSet.getParameter<bool>("semiRandomInitialPSCounters")),
136  m_useMuonShowers(parSet.getParameter<bool>("useMuonShowers")) {
137  m_egInputToken = consumes<BXVector<EGamma>>(m_egInputTag);
138  m_tauInputToken = consumes<BXVector<Tau>>(m_tauInputTag);
139  m_jetInputToken = consumes<BXVector<Jet>>(m_jetInputTag);
140  m_sumInputToken = consumes<BXVector<EtSum>>(m_sumInputTag);
141  m_sumZdcInputToken = consumes<BXVector<EtSum>>(m_sumZdcInputTag);
142  m_CICADAInputToken = consumes<BXVector<float>>(m_CICADAInputTag);
143  m_muInputToken = consumes<BXVector<Muon>>(m_muInputTag);
144  if (m_useMuonShowers)
145  m_muShowerInputToken = consumes<BXVector<MuonShower>>(m_muShowerInputTag);
146  m_extInputToken = consumes<BXVector<GlobalExtBlk>>(m_extInputTag);
147  m_l1GtStableParToken = esConsumes<L1TGlobalParameters, L1TGlobalParametersRcd>();
148  m_l1GtMenuToken = esConsumes<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd>();
150  m_l1GtPrescaleVetosToken = esConsumes<L1TGlobalPrescalesVetosFract, L1TGlobalPrescalesVetosFractRcd>();
151  }
153  m_algoblkInputToken = consumes<BXVector<GlobalAlgBlk>>(m_algoblkInputTag);
154  }
155 
156  if (m_verbosity) {
157  LogTrace("L1TGlobalProducer") << "\nInput tag for muon collection from uGMT: " << m_muInputTag
158  << "\nInput tag for calorimeter jet collections from Cal: " << m_jetInputTag
159  << "\nInput tag for external conditions : " << m_extInputTag << std::endl;
160 
161  LogTrace("L1TGlobalProducer") << "\nProduce the L1 uGT DAQ readout record: " << m_produceL1GtDaqRecord
162  << "\nProduce the L1 uGT Object Map record: "
163  << m_produceL1GtObjectMapRecord << " \n"
164  << "\nNumber of BxInEvent to be emulated: " << m_emulateBxInEvent << " \n"
165  << "\nAlternative for number of BX in GT DAQ record: 0x" << std::hex
166  << m_alternativeNrBxBoardDaq << " \n"
167  << "\nRun algorithm triggers unprescaled: "
169  << "\nRun algorithm triggers unmasked (all enabled): " << m_algorithmTriggersUnmasked
170  << "\n"
171  << std::endl;
172  }
173 
174  if ((m_emulateBxInEvent > 0) && ((m_emulateBxInEvent % 2) == 0)) {
176 
177  if (m_verbosity) {
178  edm::LogWarning("L1TGlobalProducer")
179  << "\nWARNING: Number of bunch crossing to be emulated rounded to: " << m_emulateBxInEvent
180  << "\n The number must be an odd number!\n"
181  << std::endl;
182  }
183  }
184 
185  if ((m_L1DataBxInEvent > 0) && ((m_L1DataBxInEvent % 2) == 0)) {
187 
188  if (m_verbosity) {
189  edm::LogWarning("L1TGlobalProducer")
190  << "\nWARNING: Number of bunch crossing for incoming L1 Data rounded to: " << m_L1DataBxInEvent
191  << "\n The number must be an odd number!\n"
192  << std::endl;
193  }
194  } else if (m_L1DataBxInEvent < 0) {
195  m_L1DataBxInEvent = 1;
196 
197  if (m_verbosity) {
198  edm::LogWarning("L1TGlobalProducer")
199  << "\nWARNING: Number of bunch crossing for incoming L1 Data was changed to: " << m_L1DataBxInEvent
200  << "\n The number must be an odd positive number!\n"
201  << std::endl;
202  }
203  }
204 
205  // register products
207  produces<GlobalAlgBlkBxCollection>();
208  //blwEXT produces<GlobalExtBlkBxCollection>();
209  }
210 
212  produces<GlobalObjectMapRecord>();
213  }
214 
215  // create new uGt Board
216  m_uGtBrd = std::make_unique<GlobalBoard>();
217  m_uGtBrd->setVerbosity(m_verbosity);
218  m_uGtBrd->setResetPSCountersEachLumiSec(m_resetPSCountersEachLumiSec);
219  m_uGtBrd->setSemiRandomInitialPSCounters(m_semiRandomInitialPSCounters);
220 
221  // initialize cached IDs
222 
223  //
224  m_l1GtParCacheID = 0ULL;
225  m_l1GtMenuCacheID = 0ULL;
226 
229 
230  m_nrL1Mu = 0;
231  m_nrL1MuShower = 0;
232  m_nrL1EG = 0;
233  m_nrL1Tau = 0;
234 
235  m_nrL1Jet = 0;
236 
239 
240  //
241  m_l1GtParCacheID = 0ULL;
242 
243  m_totalBxInEvent = 0;
244 
246  m_bstLengthBytes = 0;
247 
248  //
249  m_l1GtBMCacheID = 0ULL;
250 
251  //
252  m_l1GtPfAlgoCacheID = 0ULL;
253 
254  m_l1GtTmAlgoCacheID = 0ULL;
255 
257 
258  m_currentLumi = 0;
259 
260  // Set default, initial, dummy prescale factor table
261  std::vector<std::vector<double>> temp_prescaleTable;
262 
263  temp_prescaleTable.push_back(std::vector<double>());
264  m_initialPrescaleFactorsAlgoTrig = temp_prescaleTable;
265 }
266 
267 // destructor
269 
270 // member functions
271 
272 // method called to produce the data
274  // process event iEvent
275  // get / update the stable parameters from the EventSetup
276  // local cache & check on cacheIdentifier
277 
278  unsigned long long l1GtParCacheID = evSetup.get<L1TGlobalParametersRcd>().cacheIdentifier();
279 
280  if (m_l1GtParCacheID != l1GtParCacheID) {
282  m_l1GtStablePar = l1GtStablePar.product();
283  const GlobalParamsHelper* data = GlobalParamsHelper::readFromEventSetup(m_l1GtStablePar);
284 
285  // number of bx
286  m_totalBxInEvent = data->totalBxInEvent();
287 
288  // number of physics triggers
289  m_numberPhysTriggers = data->numberPhysTriggers();
290 
291  // number of objects of each type
292  m_nrL1Mu = data->numberL1Mu();
293 
294  // There should be at most 1 muon shower object per BX
295  // This object contains information for the in-time
296  // showers and out-of-time showers
297  if (m_useMuonShowers)
298  m_nrL1MuShower = 1;
299 
300  // EG
301  m_nrL1EG = data->numberL1EG();
302 
303  // jets
304  m_nrL1Jet = data->numberL1Jet();
305 
306  // taus
307  m_nrL1Tau = data->numberL1Tau();
308 
309  if (m_L1DataBxInEvent < 1)
310  m_L1DataBxInEvent = 1;
311  int minL1DataBxInEvent = (m_L1DataBxInEvent + 1) / 2 - m_L1DataBxInEvent;
312  int maxL1DataBxInEvent = (m_L1DataBxInEvent + 1) / 2 - 1;
313 
314  // Initialize Board
316  m_nrL1Mu,
318  m_nrL1EG,
319  m_nrL1Tau,
320  m_nrL1Jet,
321  minL1DataBxInEvent,
322  maxL1DataBxInEvent);
323 
324  //
325  m_l1GtParCacheID = l1GtParCacheID;
326  }
327 
328  if (m_emulateBxInEvent < 0) {
330  }
331 
332  if (m_emulateBxInEvent < 1)
333  m_emulateBxInEvent = 1;
334  int minEmulBxInEvent = (m_emulateBxInEvent + 1) / 2 - m_emulateBxInEvent;
335  int maxEmulBxInEvent = (m_emulateBxInEvent + 1) / 2 - 1;
336 
337  // get / update the trigger menu from the EventSetup
338  // local cache & check on cacheIdentifier
339  unsigned long long l1GtMenuCacheID = evSetup.get<L1TUtmTriggerMenuRcd>().cacheIdentifier();
340 
341  if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
342  const GlobalParamsHelper* data = GlobalParamsHelper::readFromEventSetup(m_l1GtStablePar);
343 
345  const L1TUtmTriggerMenu* utml1GtMenu = l1GtMenu.product();
346 
349  iEvent.getByToken(m_algoblkInputToken, m_uGtAlgBlk);
350  if (m_uGtAlgBlk->size() >= 1) {
351  if ((*m_uGtAlgBlk)[0].getL1FirmwareUUID() != static_cast<int>(utml1GtMenu->getFirmwareUuidHashed())) {
352  throw cms::Exception("ConditionsError")
353  << " Error L1 menu loaded in via conditions does not match the L1 actually run "
354  << (*m_uGtAlgBlk)[0].getL1FirmwareUUID() << " vs " << utml1GtMenu->getFirmwareUuidHashed()
355  << ". This means that the mapping of the names to the bits may be incorrect. Please check the "
356  "L1TUtmTriggerMenuRcd record supplied. Unless you know what you are doing, do not simply disable this "
357  "check via the config as this a major error and the indication of something very wrong";
358  }
359  }
360  }
361 
362  // Instantiate Parser
364 
365  gtParser.setGtNumberConditionChips(data->numberChips());
366  gtParser.setGtPinsOnConditionChip(data->pinsOnChip());
367  gtParser.setGtOrderConditionChip(data->orderOfChip());
368  gtParser.setGtNumberPhysTriggers(data->numberPhysTriggers());
369 
370  //Parse menu into emulator classes
371  gtParser.parseCondFormats(utml1GtMenu);
372 
373  // transfer the condition map and algorithm map from parser to L1uGtTriggerMenu
374  m_l1GtMenu = std::make_unique<TriggerMenu>(gtParser.gtTriggerMenuName(),
375  data->numberChips(),
376  gtParser.vecMuonTemplate(),
377  gtParser.vecMuonShowerTemplate(),
378  gtParser.vecCaloTemplate(),
379  gtParser.vecEnergySumTemplate(),
380  gtParser.vecEnergySumZdcTemplate(),
381  gtParser.vecAXOL1TLTemplate(),
382  gtParser.vecCICADATemplate(),
383  gtParser.vecExternalTemplate(),
384  gtParser.vecCorrelationTemplate(),
387  gtParser.corMuonTemplate(),
388  gtParser.corCaloTemplate(),
389  gtParser.corEnergySumTemplate());
390 
391  m_l1GtMenu->setGtTriggerMenuInterface(gtParser.gtTriggerMenuInterface());
392  m_l1GtMenu->setGtTriggerMenuImplementation(gtParser.gtTriggerMenuImplementation());
393  m_l1GtMenu->setGtScaleDbKey(gtParser.gtScaleDbKey());
394  m_l1GtMenu->setGtScales(gtParser.gtScales());
395  m_l1GtMenu->setGtTriggerMenuUUID(gtParser.gtTriggerMenuUUID());
396 
397  m_l1GtMenu->setGtAlgorithmMap(gtParser.gtAlgorithmMap());
398  m_l1GtMenu->setGtAlgorithmAliasMap(gtParser.gtAlgorithmAliasMap());
399 
400  m_l1GtMenu->buildGtConditionMap();
401 
402  int printV = 2;
403  if (m_printL1Menu)
404  m_l1GtMenu->print(std::cout, printV);
405 
406  m_l1GtMenuCacheID = l1GtMenuCacheID;
407  }
408 
409  // get / update the board maps from the EventSetup
410  // local cache & check on cacheIdentifier
411 
412  /* *** Drop L1GtBoard Maps for now
413  typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
414 
415  unsigned long long l1GtBMCacheID = evSetup.get<L1GtBoardMapsRcd>().cacheIdentifier();
416 */
417 
418  /* ** Drop board mapping for now
419  if (m_l1GtBMCacheID != l1GtBMCacheID) {
420 
421  edm::ESHandle< L1GtBoardMaps > l1GtBM;
422  evSetup.get< L1GtBoardMapsRcd >().get( l1GtBM );
423  m_l1GtBM = l1GtBM.product();
424 
425  m_l1GtBMCacheID = l1GtBMCacheID;
426 
427  }
428 
429 
430  // TODO need changes in CondFormats to cache the maps
431  const std::vector<L1GtBoard>& boardMaps = m_l1GtBM->gtBoardMaps();
432 */
433  // get / update the prescale factors from the EventSetup
434  // local cache & check on cacheIdentifier
435 
436  // Only get event record if not unprescaled and not unmasked
438  unsigned long long l1GtPfAlgoCacheID = evSetup.get<L1TGlobalPrescalesVetosFractRcd>().cacheIdentifier();
439 
440  if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
441  edm::ESHandle<L1TGlobalPrescalesVetosFract> l1GtPrescalesFractVetoes =
443  const L1TGlobalPrescalesVetosFract* es = l1GtPrescalesFractVetoes.product();
444  m_l1GtPrescalesVetosFract = PrescalesVetosFractHelper::readFromEventSetup(es);
445 
448 
449  m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
450  }
452  (m_currentLumi != iEvent.luminosityBlock())) { // get prescale column from unpacked data
453 
454  m_currentLumi = iEvent.luminosityBlock();
455 
457  iEvent.getByToken(m_algoblkInputToken, m_uGtAlgBlk);
458 
459  if (m_uGtAlgBlk.isValid() && !m_uGtAlgBlk->isEmpty(0)) {
460  std::vector<GlobalAlgBlk>::const_iterator algBlk = m_uGtAlgBlk->begin(0);
461  m_prescaleSet = static_cast<unsigned int>(algBlk->getPreScColumn());
462  } else {
463  m_prescaleSet = 1;
464  edm::LogError("L1TGlobalProduce")
465  << "Could not find valid algo block. Setting prescale column to 1" << std::endl;
466  }
467  }
468  } else {
469  // Set Prescale factors to initial dummy values
470  m_prescaleSet = 0;
474  }
475 
476  // get / update the trigger mask from the EventSetup
477  // local cache & check on cacheIdentifier
478 
479  /* **** For now Leave out Masks *****
480  unsigned long long l1GtTmAlgoCacheID =
481  evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
482 
483  if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
484 
485  edm::ESHandle< L1GtTriggerMask > l1GtTmAlgo;
486  evSetup.get< L1GtTriggerMaskAlgoTrigRcd >().get( l1GtTmAlgo );
487  m_l1GtTmAlgo = l1GtTmAlgo.product();
488 
489  m_triggerMaskAlgoTrig = m_l1GtTmAlgo->gtTriggerMask();
490 
491  m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
492 
493  }
494 */
495 
496  /* **** For now Leave out Veto Masks *****
497  unsigned long long l1GtTmVetoAlgoCacheID =
498  evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().cacheIdentifier();
499 
500  if (m_l1GtTmVetoAlgoCacheID != l1GtTmVetoAlgoCacheID) {
501 
502  edm::ESHandle< L1GtTriggerMask > l1GtTmVetoAlgo;
503  evSetup.get< L1GtTriggerMaskVetoAlgoTrigRcd >().get( l1GtTmVetoAlgo );
504  m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
505 
506  m_triggerMaskVetoAlgoTrig = m_l1GtTmVetoAlgo->gtTriggerMask();
507 
508  m_l1GtTmVetoAlgoCacheID = l1GtTmVetoAlgoCacheID;
509 
510  }
511 */
512 
513  // ****** Board Maps Need to be redone....hard code for now ******
514  // loop over blocks in the GT DAQ record receiving data, count them if they are active
515  // all board type are defined in CondFormats/L1TObjects/L1GtFwd
516  // &
517  // set the active flag for each object type received from GMT and GCT
518  // all objects in the GT system
519 
520  //
521  bool receiveMu = true;
522  bool receiveMuShower = true;
523  bool receiveEG = true;
524  bool receiveTau = true;
525  bool receiveJet = true;
526  bool receiveEtSums = true;
527  bool receiveEtSumsZdc = true;
528  bool receiveCICADA = true;
529  bool receiveExt = true;
530 
531  /* *** Boards need redefining *****
532  for (CItBoardMaps
533  itBoard = boardMaps.begin();
534  itBoard != boardMaps.end(); ++itBoard) {
535 
536  int iPosition = itBoard->gtPositionDaqRecord();
537  if (iPosition > 0) {
538 
539  int iActiveBit = itBoard->gtBitDaqActiveBoards();
540  bool activeBoard = false;
541 
542  if (iActiveBit >= 0) {
543  activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
544  }
545 
546  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit < 0)
547  // in the record and ActiveBoardsMap, and active
548  if ((iActiveBit < 0) || activeBoard) {
549 
550 // ****** Decide what board manipulation (if any we want here)
551 
552  }
553  }
554 
555  }
556 */
557 
558  // Produce the Output Records for the GT
559  std::unique_ptr<GlobalAlgBlkBxCollection> uGtAlgRecord(
560  new GlobalAlgBlkBxCollection(0, minEmulBxInEvent, maxEmulBxInEvent));
561 
562  // * produce the GlobalObjectMapRecord
563  std::unique_ptr<GlobalObjectMapRecord> gtObjectMapRecord(new GlobalObjectMapRecord());
564 
565  // fill the boards not depending on the BxInEvent in the L1 GT DAQ record
566  // GMT, PSB and FDL depend on BxInEvent
567 
568  // fill in emulator the same bunch crossing (12 bits - hardwired number of bits...)
569  // and the same local bunch crossing for all boards
570  int bxCross = iEvent.bunchCrossing();
571  uint16_t bxCrossHw = 0;
572  if ((bxCross & 0xFFF) == bxCross) {
573  bxCrossHw = static_cast<uint16_t>(bxCross);
574  } else {
575  bxCrossHw = 0; // Bx number too large, set to 0!
576  if (m_verbosity) {
577  LogDebug("L1TGlobalProducer") << "\nBunch cross number [hex] = " << std::hex << bxCross
578  << "\n larger than 12 bits. Set to 0! \n"
579  << std::dec << std::endl;
580  }
581  }
582  LogDebug("L1TGlobalProducer") << "HW BxCross " << bxCrossHw << std::endl;
583 
584  // get the prescale factor from the configuration for now
585  // prescale set index counts from zero
586  unsigned int pfAlgoSetIndex = m_prescaleSet;
587 
588  auto max = (*m_prescaleFactorsAlgoTrig).size() - 1;
589  if (pfAlgoSetIndex > max) {
590  edm::LogWarning("L1TGlobalProducer") << "\nAttempting to access prescale algo set: " << m_prescaleSet
591  << "\nNumber of prescale algo sets available: 0.." << max
592  << "Setting former to latter." << std::endl;
593  pfAlgoSetIndex = max;
594  }
595 
596  const std::vector<double>& prescaleFactorsAlgoTrig = (*m_prescaleFactorsAlgoTrig).at(pfAlgoSetIndex);
597 
598  // For now, set masks according to prescale value of 0
600  for (unsigned int iAlgo = 0; iAlgo < prescaleFactorsAlgoTrig.size(); iAlgo++) {
601  unsigned int value = prescaleFactorsAlgoTrig[iAlgo];
602  value = (value == 0) ? 0 : 1;
604  }
606 
607  const std::vector<unsigned int>& triggerMaskAlgoTrig = *m_triggerMaskAlgoTrig;
608  const std::vector<int>& triggerMaskVetoAlgoTrig = *m_triggerMaskVetoAlgoTrig;
609 
610  LogDebug("L1TGlobalProducer") << "Size of prescale vector" << prescaleFactorsAlgoTrig.size() << std::endl;
611 
612  // Load the calorimeter input onto the uGt Board
613  m_uGtBrd->receiveCaloObjectData(iEvent,
620  receiveEG,
621  m_nrL1EG,
622  receiveTau,
623  m_nrL1Tau,
624  receiveJet,
625  m_nrL1Jet,
626  receiveEtSums,
627  receiveEtSumsZdc,
628  receiveCICADA);
629 
630  m_uGtBrd->receiveMuonObjectData(iEvent, m_muInputToken, receiveMu, m_nrL1Mu);
631 
632  if (m_useMuonShowers)
633  m_uGtBrd->receiveMuonShowerObjectData(iEvent, m_muShowerInputToken, receiveMuShower, m_nrL1MuShower);
634 
635  m_uGtBrd->receiveExternalData(iEvent, m_extInputToken, receiveExt);
636 
637  // loop over BxInEvent
638  for (int iBxInEvent = minEmulBxInEvent; iBxInEvent <= maxEmulBxInEvent; ++iBxInEvent) {
639  // run GTL
640  LogDebug("L1TGlobalProducer") << "\nL1TGlobalProducer : running GTL for bx = " << iBxInEvent << "\n" << std::endl;
641 
642  // Run the GTL for this BX
643  m_uGtBrd->runGTL(iEvent,
644  evSetup,
645  m_l1GtMenu.get(),
647  iBxInEvent,
648  gtObjectMapRecord,
650  m_nrL1Mu,
652  m_nrL1EG,
653  m_nrL1Tau,
654  m_nrL1Jet);
655 
656  // run FDL
657  LogDebug("L1TGlobalProducer") << "\nL1TGlobalProducer : running FDL for bx = " << iBxInEvent << "\n" << std::endl;
658 
659  // Run the Final Decision Logic for this BX
660  m_uGtBrd->runFDL(iEvent,
661  iBxInEvent,
664  prescaleFactorsAlgoTrig,
665  triggerMaskAlgoTrig,
666  triggerMaskVetoAlgoTrig,
669 
670  // Fill in the DAQ Records
672  m_uGtBrd->fillAlgRecord(iBxInEvent,
673  uGtAlgRecord,
675  m_l1GtMenu->gtTriggerMenuUUID(),
676  m_l1GtMenu->gtTriggerMenuImplementation());
677  }
678 
679  } //End Loop over Bx
680 
681  // Add explicit reset of Board
682  m_uGtBrd->reset();
683 
684  if (m_verbosity && m_isDebugEnabled) {
685  std::ostringstream myCoutStream;
686 
687  for (int bx = minEmulBxInEvent; bx < maxEmulBxInEvent; bx++) {
689  (uGtAlgRecord->at(bx, 0)).print(myCoutStream);
690  }
691 
692  LogTrace("L1TGlobalProducer") << "\n The following L1 GT DAQ readout record was produced:\n"
693  << myCoutStream.str() << "\n"
694  << std::endl;
695 
696  myCoutStream.str("");
697  myCoutStream.clear();
698 
699  const std::vector<GlobalObjectMap> objMapVec = gtObjectMapRecord->gtObjectMap();
700 
701  for (std::vector<GlobalObjectMap>::const_iterator it = objMapVec.begin(); it != objMapVec.end(); ++it) {
702  (*it).print(myCoutStream);
703  }
704 
705  LogDebug("L1TGlobalProducer") << "Test gtObjectMapRecord in L1TGlobalProducer \n\n"
706  << myCoutStream.str() << "\n\n"
707  << std::endl;
708 
709  myCoutStream.str("");
710  myCoutStream.clear();
711  }
712 
713  // register products
715  iEvent.put(std::move(uGtAlgRecord));
716  }
717 
719  iEvent.put(std::move(gtObjectMapRecord));
720  }
721 }
722 
723 //define this as a plug-in
726 #include <cstdint>
edm::EDGetTokenT< BXVector< float > > m_CICADAInputToken
const std::vector< std::vector< CorrelationTemplate > > & vecCorrelationTemplate() const
const std::vector< std::vector< MuonTemplate > > & vecMuonTemplate() const
get / set the vectors containing the conditions
bool isDebugEnabled()
edm::InputTag m_jetInputTag
unsigned int m_numberDaqPartitions
edm::InputTag m_algoblkInputTag
unsigned long long m_l1GtParCacheID
unsigned long long m_l1GtTmVetoAlgoCacheID
void setGtOrderConditionChip(const std::vector< int > &)
const std::vector< unsigned int > * m_triggerMaskAlgoTrig
int m_verbosity
verbosity level
const GlobalScales & gtScales() const
menu associated scales
uint16_t m_activeBoardsGtDaq
active boards in L1 GT DAQ record
edm::InputTag m_egInputTag
input tag for calorimeter collections from Calo Layer 2 (GCT) or Zero Degree Calorimeter (ZDC) ...
edm::EDGetTokenT< BXVector< l1t::Tau > > m_tauInputToken
const l1t::PrescalesVetosFractHelper * m_l1GtPrescalesVetosFract
prescale factors
bool m_produceL1GtObjectMapRecord
logical flag to produce the L1 GT object map record
int m_totalBxInEvent
total number of Bx&#39;s in the event coming from EventSetup
const std::string & gtTriggerMenuName() const
unsigned int m_numberPhysTriggers
const L1TGlobalParameters * m_l1GtStablePar
cached stuff
edm::EDGetTokenT< BXVector< GlobalExtBlk > > m_extInputToken
edm::ESGetToken< L1TGlobalParameters, L1TGlobalParametersRcd > m_l1GtStableParToken
delete x;
Definition: CaloConfig.h:22
BXVector< GlobalAlgBlk > GlobalAlgBlkBxCollection
Definition: GlobalAlgBlk.h:31
unsigned long long m_l1GtTmAlgoCacheID
std::vector< std::vector< double > > m_initialPrescaleFactorsAlgoTrig
edm::InputTag m_sumZdcInputTag
Log< level::Error, false > LogError
~L1TGlobalProducer() override
std::vector< unsigned int > m_initialTriggerMaskAlgoTrig
edm::ESGetToken< L1TGlobalPrescalesVetosFract, L1TGlobalPrescalesVetosFractRcd > m_l1GtPrescaleVetosToken
const std::vector< std::vector< CorrelationThreeBodyTemplate > > & vecCorrelationThreeBodyTemplate() const
const std::vector< int > * m_triggerMaskVetoAlgoTrig
unsigned int m_alternativeNrBxBoardDaq
#define LogTrace(id)
edm::InputTag m_sumInputTag
edm::InputTag m_muInputTag
input tag for muon collection from the Global Muon Trigger (GMT)
edm::InputTag m_extInputTag
input tag for external conditions
const std::vector< std::vector< CaloTemplate > > & vecCaloTemplate() const
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
void setGtPinsOnConditionChip(const unsigned int &)
unsigned long long m_l1GtMenuCacheID
edm::InputTag m_tauInputTag
void parseCondFormats(const L1TUtmTriggerMenu *utmMenu)
edm::InputTag m_muShowerInputTag
std::unique_ptr< TriggerMenu > m_l1GtMenu
const int gtTriggerMenuUUID() const
std::vector< int > m_initialTriggerMaskVetoAlgoTrig
bool m_produceL1GtDaqRecord
logical flag to produce the L1 GT DAQ readout record
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
T get() const
Definition: EventSetup.h:79
edm::EDGetTokenT< BXVector< l1t::Muon > > m_muInputToken
const std::vector< std::vector< EnergySumTemplate > > & vecEnergySumTemplate() const
const AlgorithmMap & gtAlgorithmAliasMap() const
get / set the algorithm map (by alias)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const std::string & gtScaleDbKey() const
menu associated scale key
Definition: value.py:1
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
const std::vector< std::vector< EnergySumZdcTemplate > > & vecEnergySumZdcTemplate() const
unsigned int m_prescaleSet
prescale set used
const std::vector< std::vector< EnergySumTemplate > > & corEnergySumTemplate() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::vector< std::vector< MuonTemplate > > & corMuonTemplate() const
edm::EDGetTokenT< BXVector< l1t::EtSum > > m_sumInputToken
int m_L1DataBxInEvent
Bx expected in Data coming to GT.
const unsigned long gtTriggerMenuImplementation() const
L1TGlobalProducer(const edm::ParameterSet &)
const std::vector< int > & triggerMaskVeto() const
unsigned long long m_l1GtBMCacheID
void setGtNumberConditionChips(const unsigned int &)
edm::InputTag m_CICADAInputTag
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isValid() const
Definition: HandleBase.h:70
const std::vector< std::vector< CaloTemplate > > & corCaloTemplate() const
edm::EDGetToken m_algoblkInputToken
unsigned int m_bstLengthBytes
length of BST record (in bytes) from event setup
const std::string & gtTriggerMenuInterface() const
get / set the trigger menu names
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
edm::EDGetTokenT< BXVector< l1t::EtSum > > m_sumZdcInputToken
const unsigned long getFirmwareUuidHashed() const
const std::vector< std::vector< MuonShowerTemplate > > & vecMuonShowerTemplate() const
const std::vector< std::vector< ExternalTemplate > > & vecExternalTemplate() const
const std::vector< std::vector< CorrelationWithOverlapRemovalTemplate > > & vecCorrelationWithOverlapRemovalTemplate() const
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > m_l1GtMenuToken
unsigned long long m_l1GtPfAlgoCacheID
std::unique_ptr< l1t::GlobalBoard > m_uGtBrd
Log< level::Warning, false > LogWarning
const std::vector< std::vector< CICADATemplate > > & vecCICADATemplate() const
const std::vector< std::vector< double > > * m_prescaleFactorsAlgoTrig
const std::vector< std::vector< AXOL1TLTemplate > > & vecAXOL1TLTemplate() const
edm::EDGetTokenT< BXVector< l1t::MuonShower > > m_muShowerInputToken
const std::vector< std::vector< double > > & prescaleTable() const
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< BXVector< l1t::Jet > > m_jetInputToken
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
edm::EDGetTokenT< BXVector< l1t::EGamma > > m_egInputToken
void setGtNumberPhysTriggers(const unsigned int &)
#define LogDebug(id)
void produce(edm::Event &, const edm::EventSetup &) override