CMS 3D CMS Logo

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