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