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