CMS 3D CMS Logo

GlobalBoard.cc
Go to the documentation of this file.
1 
28 // this class header
30 
31 // user include files
50 
51 // Conditions for uGT
62 
65 
66 // Constructor
68  : m_candL1Mu(new BXVector<const l1t::Muon*>),
69  m_candL1MuShower(new BXVector<std::shared_ptr<l1t::MuonShower>>),
70  m_candL1EG(new BXVector<const l1t::L1Candidate*>),
71  m_candL1Tau(new BXVector<const l1t::L1Candidate*>),
72  m_candL1Jet(new BXVector<const l1t::L1Candidate*>),
73  m_candL1EtSum(new BXVector<const l1t::EtSum*>),
74  m_candL1EtSumZdc(new BXVector<const l1t::EtSum*>),
75  m_candL1External(new BXVector<const GlobalExtBlk*>),
76  m_currentLumi(0),
77  m_isDebugEnabled(edm::isDebugEnabled()) {
79 
80  m_gtlAlgorithmOR.reset();
81  m_gtlDecisionWord.reset();
82 
84 
85  // Initialize cached IDs
86  m_l1GtMenuCacheID = 0ULL;
89 
90  // Counter for number of events board sees
92 
93  // A single uGT GlobalBoard is taken into account in the emulator
94  m_uGtBoardNumber = 0;
95  m_uGtFinalBoard = true;
96 }
97 
98 // Destructor
100  delete m_candL1Mu;
101  delete m_candL1MuShower;
102  delete m_candL1EG;
103  delete m_candL1Tau;
104  delete m_candL1Jet;
105  delete m_candL1EtSum;
106  delete m_candL1EtSumZdc;
107  delete m_candL1External;
108 }
109 
110 // Operations
111 void l1t::GlobalBoard::setBxFirst(int bx) { m_bxFirst_ = bx; }
112 
113 void l1t::GlobalBoard::setBxLast(int bx) { m_bxLast_ = bx; }
114 
115 void l1t::GlobalBoard::init(const int numberPhysTriggers,
116  const int nrL1Mu,
117  const int nrL1MuShower,
118  const int nrL1EG,
119  const int nrL1Tau,
120  const int nrL1Jet,
121  int bxFirst,
122  int bxLast) {
123  setBxFirst(bxFirst);
124  setBxLast(bxLast);
125 
126  m_candL1Mu->setBXRange(m_bxFirst_, m_bxLast_);
127  m_candL1MuShower->setBXRange(m_bxFirst_, m_bxLast_);
128  m_candL1EG->setBXRange(m_bxFirst_, m_bxLast_);
129  m_candL1Tau->setBXRange(m_bxFirst_, m_bxLast_);
130  m_candL1Jet->setBXRange(m_bxFirst_, m_bxLast_);
131  m_candL1EtSum->setBXRange(m_bxFirst_, m_bxLast_);
132  m_candL1EtSumZdc->setBXRange(m_bxFirst_, m_bxLast_);
133  m_candL1External->setBXRange(m_bxFirst_, m_bxLast_);
134 
135  m_uGtAlgBlk.reset();
136 
137  LogDebug("L1TGlobal") << "\t Initializing Board with bxFirst = " << m_bxFirst_ << ", bxLast = " << m_bxLast_;
138 }
139 
140 // receive data from Calorimeter
142  const edm::EDGetTokenT<BXVector<l1t::EGamma>>& egInputToken,
143  const edm::EDGetTokenT<BXVector<l1t::Tau>>& tauInputToken,
144  const edm::EDGetTokenT<BXVector<l1t::Jet>>& jetInputToken,
145  const edm::EDGetTokenT<BXVector<l1t::EtSum>>& sumInputToken,
146  const edm::EDGetTokenT<BXVector<l1t::EtSum>>& sumZdcInputToken,
147  const bool receiveEG,
148  const int nrL1EG,
149  const bool receiveTau,
150  const int nrL1Tau,
151  const bool receiveJet,
152  const int nrL1Jet,
153  const bool receiveEtSums,
154  const bool receiveEtSumsZdc) {
155  if (m_verbosity) {
156  LogDebug("L1TGlobal") << "\n**** Board receiving Calo Data ";
157  }
158 
159  resetCalo();
160 
161  // get data from Calorimeter
162  if (receiveEG) {
164  iEvent.getByToken(egInputToken, egData);
165 
166  if (!egData.isValid()) {
167  if (m_verbosity) {
168  edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector<l1t::EGamma> collection"
169  << "\nrequested in configuration, but not found in the event.\n";
170  }
171  } else {
172  // bx in EG data
173  for (int i = egData->getFirstBX(); i <= egData->getLastBX(); ++i) {
174  // Prevent from pushing back bx that is outside of allowed range
175  if (i < m_bxFirst_ || i > m_bxLast_)
176  continue;
177 
178  //Loop over EG in this bx
179  int nObj = 0;
180  for (std::vector<l1t::EGamma>::const_iterator eg = egData->begin(i); eg != egData->end(i); ++eg) {
181  if (nObj < nrL1EG) {
182  (*m_candL1EG).push_back(i, &(*eg));
183  } else {
184  edm::LogWarning("L1TGlobal") << " Too many EG (" << nObj << ") for uGT Configuration maxEG =" << nrL1EG;
185  }
186  LogDebug("L1TGlobal") << "EG Pt " << eg->hwPt() << " Eta " << eg->hwEta() << " Phi " << eg->hwPhi()
187  << " Qual " << eg->hwQual() << " Iso " << eg->hwIso();
188 
189  nObj++;
190  } //end loop over EG in bx
191  } //end loop over bx
192  } //end if over valid EG data
193  } //end if ReceiveEG data
194 
195  if (receiveTau) {
197  iEvent.getByToken(tauInputToken, tauData);
198 
199  if (!tauData.isValid()) {
200  if (m_verbosity) {
201  edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector<l1t::Tau> collection"
202  << "\nrequested in configuration, but not found in the event.\n";
203  }
204  } else {
205  // bx in tau data
206  for (int i = tauData->getFirstBX(); i <= tauData->getLastBX(); ++i) {
207  // Prevent from pushing back bx that is outside of allowed range
208  if (i < m_bxFirst_ || i > m_bxLast_)
209  continue;
210 
211  //Loop over tau in this bx
212  int nObj = 0;
213  for (std::vector<l1t::Tau>::const_iterator tau = tauData->begin(i); tau != tauData->end(i); ++tau) {
214  if (nObj < nrL1Tau) {
215  (*m_candL1Tau).push_back(i, &(*tau));
216  } else {
217  LogTrace("L1TGlobal") << " Too many Tau (" << nObj << ") for uGT Configuration maxTau =" << nrL1Tau;
218  }
219 
220  LogDebug("L1TGlobal") << "tau Pt " << tau->hwPt() << " Eta " << tau->hwEta() << " Phi " << tau->hwPhi()
221  << " Qual " << tau->hwQual() << " Iso " << tau->hwIso();
222  nObj++;
223 
224  } //end loop over tau in bx
225  } //end loop over bx
226  } //end if over valid tau data
227  } //end if ReceiveTau data
228 
229  if (receiveJet) {
231  iEvent.getByToken(jetInputToken, jetData);
232 
233  if (!jetData.isValid()) {
234  if (m_verbosity) {
235  edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector<l1t::Jet> collection"
236  << "\nrequested in configuration, but not found in the event.\n";
237  }
238  } else {
239  // bx in jet data
240  for (int i = jetData->getFirstBX(); i <= jetData->getLastBX(); ++i) {
241  // Prevent from pushing back bx that is outside of allowed range
242  if (i < m_bxFirst_ || i > m_bxLast_)
243  continue;
244 
245  //Loop over jet in this bx
246  int nObj = 0;
247  for (std::vector<l1t::Jet>::const_iterator jet = jetData->begin(i); jet != jetData->end(i); ++jet) {
248  if (nObj < nrL1Jet) {
249  (*m_candL1Jet).push_back(i, &(*jet));
250  } else {
251  edm::LogWarning("L1TGlobal") << " Too many Jets (" << nObj << ") for uGT Configuration maxJet =" << nrL1Jet;
252  }
253 
254  LogDebug("L1TGlobal") << "Jet Pt " << jet->hwPt() << " Eta " << jet->hwEta() << " Phi " << jet->hwPhi()
255  << " Qual " << jet->hwQual() << " Iso " << jet->hwIso();
256  nObj++;
257  } //end loop over jet in bx
258  } //end loop over bx
259  } //end if over valid jet data
260  } //end if ReceiveJet data
261 
262  if (receiveEtSums) {
264  iEvent.getByToken(sumInputToken, etSumData);
265 
266  if (!etSumData.isValid()) {
267  if (m_verbosity) {
268  edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector<l1t::EtSum> collection"
269  << "\nrequested in configuration, but not found in the event.\n";
270  }
271  } else {
272  for (int i = etSumData->getFirstBX(); i <= etSumData->getLastBX(); ++i) {
273  // Prevent from pushing back bx that is outside of allowed range
274  if (i < m_bxFirst_ || i > m_bxLast_)
275  continue;
276 
277  //Loop over EtSum objects in this bx
278  for (std::vector<l1t::EtSum>::const_iterator etsum = etSumData->begin(i); etsum != etSumData->end(i); ++etsum) {
279  (*m_candL1EtSum).push_back(i, &(*etsum));
280 
281  /* In case we need to split these out
282  switch ( etsum->getType() ) {
283  case l1t::EtSum::EtSumType::kMissingEt:
284  {
285  //(*m_candETM).push_back(i,&(*etsum));
286  LogDebug("L1TGlobal") << "ETM: Pt " << etsum->hwPt() << " Phi " << etsum->hwPhi();
287  }
288  break;
289  case l1t::EtSum::EtSumType::kMissingHt:
290  {
291  //(*m_candHTM).push_back(i,&(*etsum));
292  LogDebug("L1TGlobal") << "HTM: Pt " << etsum->hwPt() << " Phi " << etsum->hwPhi();
293  }
294  break;
295  case l1t::EtSum::EtSumType::kTotalEt:
296  {
297  //(*m_candETT).push_back(i,&(*etsum));
298  LogDebug("L1TGlobal") << "ETT: Pt " << etsum->hwPt();
299  }
300  break;
301  case l1t::EtSum::EtSumType::kTotalHt:
302  {
303  //(*m_candHTT).push_back(i,&(*etsum));
304  LogDebug("L1TGlobal") << "HTT: Pt " << etsum->hwPt();
305  }
306  break;
307  case l1t::EtSum::EtSumType::kTowerCount:
308  {
309  //(*m_candTowerCount).push_back(i,&(*etsum));
310  LogDebug("L1TGlobal") << "TowerCount: " << etsum->hwPt();
311  }
312  break;
313  default:
314  LogDebug("L1TGlobal") << "Default encounted ";
315  break;
316  }
317 */
318 
319  } //end loop over EtSum objects in bx
320  } //end loop over Bx
321  }
322  }
323 
324  if (receiveEtSumsZdc) {
326  iEvent.getByToken(sumZdcInputToken, etSumData);
327 
328  if (!etSumData.isValid()) {
329  if (m_verbosity) {
330  edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the ZDC Energy Sums collection"
331  << "\nrequested in configuration, but not found in the event.\n";
332  }
333  } else {
334  for (int i = etSumData->getFirstBX(); i <= etSumData->getLastBX(); ++i) {
335  // Prevent from pushing back bx that is outside of allowed range
336  if (i < m_bxFirst_ || i > m_bxLast_)
337  continue;
338 
339  for (std::vector<l1t::EtSum>::const_iterator etsum = etSumData->begin(i); etsum != etSumData->end(i); ++etsum) {
340  (*m_candL1EtSumZdc).push_back(i, &(*etsum));
341  }
342  } //end loop over Bx
343  }
344  }
345 }
346 
347 // receive data from Global Muon Trigger
349  const edm::EDGetTokenT<BXVector<l1t::Muon>>& muInputToken,
350  const bool receiveMu,
351  const int nrL1Mu) {
352  if (m_verbosity) {
353  LogDebug("L1TGlobal") << "\n**** GlobalBoard receiving muon data = ";
354  //<< "\n from input tag " << muInputTag << "\n"
355  }
356 
357  resetMu();
358 
359  // get data from Global Muon Trigger
360  if (receiveMu) {
362  iEvent.getByToken(muInputToken, muonData);
363 
364  if (!muonData.isValid()) {
365  if (m_verbosity) {
366  edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector<l1t::Muon> collection"
367  << "\nrequested in configuration, but not found in the event.\n";
368  }
369  } else {
370  // bx in muon data
371  for (int i = muonData->getFirstBX(); i <= muonData->getLastBX(); ++i) {
372  // Prevent from pushing back bx that is outside of allowed range
373  if (i < m_bxFirst_ || i > m_bxLast_)
374  continue;
375 
376  //Loop over Muons in this bx
377  int nObj = 0;
378  for (std::vector<l1t::Muon>::const_iterator mu = muonData->begin(i); mu != muonData->end(i); ++mu) {
379  if (nObj < nrL1Mu) {
380  (*m_candL1Mu).push_back(i, &(*mu));
381  } else {
382  edm::LogWarning("L1TGlobal") << " Too many Muons (" << nObj << ") for uGT Configuration maxMu =" << nrL1Mu;
383  }
384 
385  LogDebug("L1TGlobal") << "Muon Pt " << mu->hwPt() << " EtaAtVtx " << mu->hwEtaAtVtx() << " PhiAtVtx "
386  << mu->hwPhiAtVtx() << " Qual " << mu->hwQual() << " Iso " << mu->hwIso();
387  nObj++;
388  } //end loop over muons in bx
389  } //end loop over bx
390  } //end if over valid muon data
391  } //end if ReceiveMuon data
392 }
393 
394 // receive muon shower data from Global Muon Trigger
396  const edm::EDGetTokenT<BXVector<l1t::MuonShower>>& muShowerInputToken,
397  const bool receiveMuShower,
398  const int nrL1MuShower) {
399  // get data from Global Muon Trigger
400  if (receiveMuShower) {
402  iEvent.getByToken(muShowerInputToken, muonData);
403 
404  if (!muonData.isValid()) {
405  if (m_verbosity) {
406  edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector<l1t::MuonShower> collection"
407  << "\nrequested in configuration, but not found in the event.\n";
408  }
409  } else {
410  // Loop over bx in muon data
411  for (int i = muonData->getFirstBX(); i <= muonData->getLastBX(); ++i) {
412  // Prevent from pushing back bx that is outside of allowed range
413  if (i < m_bxFirst_ || i > m_bxLast_)
414  continue;
415 
416  // Loop over Muon Showers in this bx
417  int nObj = 0;
418  for (std::vector<l1t::MuonShower>::const_iterator mu = muonData->begin(i); mu != muonData->end(i); ++mu) {
419  if (nObj < nrL1MuShower) {
420  /* NOTE: here the single object is split up into 5 separate MuonShower objects
421  similarly to the description in the UTM library, where the conditions are four different objects.
422  */
423 
424  std::shared_ptr<l1t::MuonShower> musOneNominalInTime =
425  std::make_shared<l1t::MuonShower>(false, false, false, false, false, false);
426  std::shared_ptr<l1t::MuonShower> musOneTightInTime =
427  std::make_shared<l1t::MuonShower>(false, false, false, false, false, false);
428  std::shared_ptr<l1t::MuonShower> musTwoLooseDiffSectorsInTime =
429  std::make_shared<l1t::MuonShower>(false, false, false, false, false, false);
430  std::shared_ptr<l1t::MuonShower> musOutOfTime0 =
431  std::make_shared<l1t::MuonShower>(false, false, false, false, false, false);
432  std::shared_ptr<l1t::MuonShower> musOutOfTime1 =
433  std::make_shared<l1t::MuonShower>(false, false, false, false, false, false);
434 
435  musOneNominalInTime->setOneNominalInTime(mu->isOneNominalInTime());
436  musOneTightInTime->setOneTightInTime(mu->isOneTightInTime());
437  musTwoLooseDiffSectorsInTime->setTwoLooseDiffSectorsInTime(mu->isTwoLooseDiffSectorsInTime());
438  musOutOfTime0->setMusOutOfTime0(mu->musOutOfTime0());
439  musOutOfTime1->setMusOutOfTime1(mu->musOutOfTime1());
440 
441  (*m_candL1MuShower).push_back(i, musOneNominalInTime);
442  (*m_candL1MuShower).push_back(i, musOneTightInTime);
443  (*m_candL1MuShower).push_back(i, musTwoLooseDiffSectorsInTime);
444  (*m_candL1MuShower).push_back(i, musOutOfTime0);
445  (*m_candL1MuShower).push_back(i, musOutOfTime1);
446 
447  } else {
448  edm::LogWarning("L1TGlobal") << " Too many Muon Showers (" << nObj
449  << ") for uGT Configuration maxMuShower =" << nrL1MuShower;
450  }
451  nObj++;
452  } //end loop over muon showers in bx
453  } //end loop over bx
454  } //end if over valid muon shower data
455  } //end if ReceiveMuonShower data
456 }
457 
458 // receive data from Global External Conditions
460  const edm::EDGetTokenT<BXVector<GlobalExtBlk>>& extInputToken,
461  const bool receiveExt) {
462  if (m_verbosity) {
463  LogDebug("L1TGlobal") << "\n**** GlobalBoard receiving external data = ";
464  //<< "\n from input tag " << muInputTag << "\n"
465  }
466 
467  resetExternal();
468 
469  // get data from Global Muon Trigger
470  if (receiveExt) {
472  iEvent.getByToken(extInputToken, extData);
473 
474  if (!extData.isValid()) {
475  if (m_verbosity) {
476  edm::LogWarning("L1TGlobal") << "\nWarning: Input tag for the BXVector<GlobalExtBlk> collection"
477  << "\nrequested in configuration, but not found in the event.\n";
478  }
479  } else {
480  // bx in muon data
481  for (int i = extData->getFirstBX(); i <= extData->getLastBX(); ++i) {
482  // Prevent from pushing back bx that is outside of allowed range
483  if (i < m_bxFirst_ || i > m_bxLast_)
484  continue;
485 
486  //Loop over ext in this bx
487  for (std::vector<GlobalExtBlk>::const_iterator ext = extData->begin(i); ext != extData->end(i); ++ext) {
488  (*m_candL1External).push_back(i, &(*ext));
489  } //end loop over ext in bx
490  } //end loop over bx
491  } //end if over valid ext data
492  } //end if ReceiveExt data
493 }
494 
495 // run GTL
497  const edm::EventSetup& evSetup,
498  const TriggerMenu* m_l1GtMenu,
499  const bool produceL1GtObjectMapRecord,
500  const int iBxInEvent,
501  std::unique_ptr<GlobalObjectMapRecord>& gtObjectMapRecord,
502  const unsigned int numberPhysTriggers,
503  const int nrL1Mu,
504  const int nrL1MuShower,
505  const int nrL1EG,
506  const int nrL1Tau,
507  const int nrL1Jet) {
508  const std::vector<ConditionMap>& conditionMap = m_l1GtMenu->gtConditionMap();
509  const AlgorithmMap& algorithmMap = m_l1GtMenu->gtAlgorithmMap();
510  const GlobalScales& gtScales = m_l1GtMenu->gtScales();
511  const std::string scaleSetName = gtScales.getScalesName();
512  LogDebug("L1TGlobal") << " L1 Menu Scales -- Set Name: " << scaleSetName;
513 
514  // Reset AlgBlk for this bx
515  m_uGtAlgBlk.reset();
516  m_algInitialOr = false;
517  m_algPrescaledOr = false;
518  m_algIntermOr = false;
519  m_algFinalOr = false;
520  m_algFinalOrVeto = false;
521 
522  const std::vector<std::vector<MuonTemplate>>& corrMuon = m_l1GtMenu->corMuonTemplate();
523 
524  const std::vector<std::vector<CaloTemplate>>& corrCalo = m_l1GtMenu->corCaloTemplate();
525 
526  const std::vector<std::vector<EnergySumTemplate>>& corrEnergySum = m_l1GtMenu->corEnergySumTemplate();
527 
528  LogDebug("L1TGlobal") << "Size corrMuon " << corrMuon.size() << "\nSize corrCalo " << corrCalo.size()
529  << "\nSize corrSums " << corrEnergySum.size();
530 
531  // -----------------------------------------------------
532  // Loop over condition maps (one map per condition chip),
533  // then loop over conditions in the map and
534  // save the results in temporary maps
535  // -----------------------------------------------------
536  // never happens in production but at first event...
537  if (m_conditionResultMaps.size() != conditionMap.size()) {
538  m_conditionResultMaps.clear();
539  m_conditionResultMaps.resize(conditionMap.size());
540  }
541 
542  int iChip = -1;
543 
544  for (std::vector<ConditionMap>::const_iterator itCondOnChip = conditionMap.begin();
545  itCondOnChip != conditionMap.end();
546  itCondOnChip++) {
547  iChip++;
548 
549  AlgorithmEvaluation::ConditionEvaluationMap& cMapResults = m_conditionResultMaps[iChip];
550 
551  for (CItCond itCond = itCondOnChip->begin(); itCond != itCondOnChip->end(); itCond++) {
552  // evaluate condition
553  switch ((itCond->second)->condCategory()) {
554  case CondMuon: {
555  // BLW Not sure what to do with this for now
556  const int ifMuEtaNumberBits = 0;
557 
558  MuCondition* muCondition = new MuCondition(itCond->second, this, nrL1Mu, ifMuEtaNumberBits);
559 
560  muCondition->setVerbosity(m_verbosity);
561 
562  muCondition->evaluateConditionStoreResult(iBxInEvent);
563 
564  cMapResults[itCond->first] = muCondition;
565 
566  if (m_verbosity && m_isDebugEnabled) {
567  std::ostringstream myCout;
568  muCondition->print(myCout);
569 
570  LogTrace("L1TGlobal") << myCout.str();
571  }
572  //delete muCondition;
573 
574  } break;
575  case CondMuonShower: {
576  MuonShowerCondition* muShowerCondition = new MuonShowerCondition(itCond->second, this, nrL1MuShower);
577 
578  muShowerCondition->setVerbosity(m_verbosity);
579 
580  muShowerCondition->evaluateConditionStoreResult(iBxInEvent);
581 
582  cMapResults[itCond->first] = muShowerCondition;
583 
584  if (m_verbosity && m_isDebugEnabled) {
585  std::ostringstream myCout;
586  muShowerCondition->print(myCout);
587 
588  edm::LogWarning("L1TGlobal") << "MuonShowerCondition " << myCout.str();
589  }
590  //delete muShowerCondition;
591 
592  } break;
593  case CondCalo: {
594  // BLW Not sure w hat to do with this for now
595  const int ifCaloEtaNumberBits = 0;
596 
597  CaloCondition* caloCondition =
598  new CaloCondition(itCond->second, this, nrL1EG, nrL1Jet, nrL1Tau, ifCaloEtaNumberBits);
599 
600  caloCondition->setVerbosity(m_verbosity);
601 
602  caloCondition->evaluateConditionStoreResult(iBxInEvent);
603 
604  cMapResults[itCond->first] = caloCondition;
605 
606  if (m_verbosity && m_isDebugEnabled) {
607  std::ostringstream myCout;
608  caloCondition->print(myCout);
609 
610  LogTrace("L1TGlobal") << myCout.str();
611  }
612  // delete caloCondition;
613 
614  } break;
615  case CondEnergySum: {
616  EnergySumCondition* eSumCondition = new EnergySumCondition(itCond->second, this);
617 
618  eSumCondition->setVerbosity(m_verbosity);
619  eSumCondition->evaluateConditionStoreResult(iBxInEvent);
620 
621  cMapResults[itCond->first] = eSumCondition;
622 
623  if (m_verbosity && m_isDebugEnabled) {
624  std::ostringstream myCout;
625  eSumCondition->print(myCout);
626 
627  LogTrace("L1TGlobal") << myCout.str();
628  }
629  // delete eSumCondition;
630 
631  } break;
632  case CondEnergySumZdc: {
633  EnergySumZdcCondition* eSumZdcCondition = new EnergySumZdcCondition(itCond->second, this);
634 
635  eSumZdcCondition->setVerbosity(m_verbosity);
636  eSumZdcCondition->evaluateConditionStoreResult(iBxInEvent);
637 
638  cMapResults[itCond->first] = eSumZdcCondition;
639 
640  if (m_verbosity && m_isDebugEnabled) {
641  std::ostringstream myCout;
642  eSumZdcCondition->print(myCout);
643 
644  LogTrace("L1TGlobal") << myCout.str();
645  }
646  // delete eSumZdcCondition;
647 
648  } break;
649  case CondAXOL1TL: {
650  AXOL1TLCondition* axol1tlCondition = new AXOL1TLCondition(itCond->second, this);
651 
652  axol1tlCondition->setVerbosity(m_verbosity);
653 
654  axol1tlCondition->evaluateConditionStoreResult(iBxInEvent);
655 
656  cMapResults[itCond->first] = axol1tlCondition;
657 
658  if (m_verbosity && m_isDebugEnabled) {
659  std::ostringstream myCout;
660  axol1tlCondition->print(myCout);
661 
662  edm::LogWarning("L1TGlobal") << "axol1tlCondition " << myCout.str();
663  }
664  //delete axol1tlCCondition;
665 
666  } break;
667 
668  case CondExternal: {
669  ExternalCondition* extCondition = new ExternalCondition(itCond->second, this);
670 
671  extCondition->setVerbosity(m_verbosity);
672  extCondition->evaluateConditionStoreResult(iBxInEvent);
673 
674  cMapResults[itCond->first] = extCondition;
675 
676  if (m_verbosity && m_isDebugEnabled) {
677  std::ostringstream myCout;
678  extCondition->print(myCout);
679 
680  LogTrace("L1TGlobal") << myCout.str();
681  }
682  // delete extCondition;
683 
684  } break;
685  case CondCorrelation: {
686  // get first the subconditions
687  const CorrelationTemplate* corrTemplate = static_cast<const CorrelationTemplate*>(itCond->second);
688  const GtConditionCategory cond0Categ = corrTemplate->cond0Category();
689  const GtConditionCategory cond1Categ = corrTemplate->cond1Category();
690  const int cond0Ind = corrTemplate->cond0Index();
691  const int cond1Ind = corrTemplate->cond1Index();
692 
693  const GlobalCondition* cond0Condition = nullptr;
694  const GlobalCondition* cond1Condition = nullptr;
695 
696  // maximum number of objects received for evaluation of l1t::Type1s condition
697  int cond0NrL1Objects = 0;
698  int cond1NrL1Objects = 0;
699  LogDebug("L1TGlobal") << " cond0NrL1Objects" << cond0NrL1Objects << " cond1NrL1Objects "
700  << cond1NrL1Objects;
701 
702  switch (cond0Categ) {
703  case CondMuon: {
704  cond0Condition = &((corrMuon[iChip])[cond0Ind]);
705  } break;
706  case CondCalo: {
707  cond0Condition = &((corrCalo[iChip])[cond0Ind]);
708  } break;
709  case CondEnergySum: {
710  cond0Condition = &((corrEnergySum[iChip])[cond0Ind]);
711  } break;
712  default: {
713  // do nothing, should not arrive here
714  } break;
715  }
716 
717  switch (cond1Categ) {
718  case CondMuon: {
719  cond1Condition = &((corrMuon[iChip])[cond1Ind]);
720  } break;
721  case CondCalo: {
722  cond1Condition = &((corrCalo[iChip])[cond1Ind]);
723  } break;
724  case CondEnergySum: {
725  cond1Condition = &((corrEnergySum[iChip])[cond1Ind]);
726  } break;
727  default: {
728  // do nothing, should not arrive here
729  } break;
730  }
731 
732  CorrCondition* correlationCond = new CorrCondition(itCond->second, cond0Condition, cond1Condition, this);
733 
734  correlationCond->setVerbosity(m_verbosity);
735  correlationCond->setScales(&gtScales);
736  correlationCond->evaluateConditionStoreResult(iBxInEvent);
737 
738  cMapResults[itCond->first] = correlationCond;
739 
740  if (m_verbosity && m_isDebugEnabled) {
741  std::ostringstream myCout;
742  correlationCond->print(myCout);
743 
744  LogTrace("L1TGlobal") << myCout.str();
745  }
746 
747  // delete correlationCond;
748 
749  } break;
751  // get first the subconditions
752  const CorrelationThreeBodyTemplate* corrTemplate =
753  static_cast<const CorrelationThreeBodyTemplate*>(itCond->second);
754  const GtConditionCategory cond0Categ = corrTemplate->cond0Category();
755  const GtConditionCategory cond1Categ = corrTemplate->cond1Category();
756  const GtConditionCategory cond2Categ = corrTemplate->cond2Category();
757  const int cond0Ind = corrTemplate->cond0Index();
758  const int cond1Ind = corrTemplate->cond1Index();
759  const int cond2Ind = corrTemplate->cond2Index();
760 
761  const GlobalCondition* cond0Condition = nullptr;
762  const GlobalCondition* cond1Condition = nullptr;
763  const GlobalCondition* cond2Condition = nullptr;
764 
765  // maximum number of objects received for evaluation of l1t::Type1s condition
766  int cond0NrL1Objects = 0;
767  int cond1NrL1Objects = 0;
768  int cond2NrL1Objects = 0;
769  LogDebug("L1TGlobal") << " cond0NrL1Objects " << cond0NrL1Objects << " cond1NrL1Objects "
770  << cond1NrL1Objects << " cond2NrL1Objects " << cond2NrL1Objects;
771  if (cond0Categ == CondMuon) {
772  cond0Condition = &((corrMuon[iChip])[cond0Ind]);
773  } else {
774  LogDebug("L1TGlobal") << "No muon0 to evaluate three-body correlation condition";
775  }
776  if (cond1Categ == CondMuon) {
777  cond1Condition = &((corrMuon[iChip])[cond1Ind]);
778  } else {
779  LogDebug("L1TGlobal") << "No muon1 to evaluate three-body correlation condition";
780  }
781  if (cond2Categ == CondMuon) {
782  cond2Condition = &((corrMuon[iChip])[cond2Ind]);
783  } else {
784  LogDebug("L1TGlobal") << "No muon2 to evaluate three-body correlation condition";
785  }
786 
787  CorrThreeBodyCondition* correlationThreeBodyCond =
788  new CorrThreeBodyCondition(itCond->second, cond0Condition, cond1Condition, cond2Condition, this);
789 
790  correlationThreeBodyCond->setVerbosity(m_verbosity);
791  correlationThreeBodyCond->setScales(&gtScales);
792  correlationThreeBodyCond->evaluateConditionStoreResult(iBxInEvent);
793  cMapResults[itCond->first] = correlationThreeBodyCond;
794 
795  if (m_verbosity && m_isDebugEnabled) {
796  std::ostringstream myCout;
797  correlationThreeBodyCond->print(myCout);
798 
799  LogTrace("L1TGlobal") << myCout.str();
800  }
801  // delete correlationThreeBodyCond;
802  } break;
803 
805  // get first the subconditions
806  const CorrelationWithOverlapRemovalTemplate* corrTemplate =
807  static_cast<const CorrelationWithOverlapRemovalTemplate*>(itCond->second);
808  const GtConditionCategory cond0Categ = corrTemplate->cond0Category();
809  const GtConditionCategory cond1Categ = corrTemplate->cond1Category();
810  const GtConditionCategory cond2Categ = corrTemplate->cond2Category();
811  const int cond0Ind = corrTemplate->cond0Index();
812  const int cond1Ind = corrTemplate->cond1Index();
813  const int cond2Ind = corrTemplate->cond2Index();
814 
815  const GlobalCondition* cond0Condition = nullptr;
816  const GlobalCondition* cond1Condition = nullptr;
817  const GlobalCondition* cond2Condition = nullptr;
818 
819  // maximum number of objects received for evaluation of l1t::Type1s condition
820  int cond0NrL1Objects = 0;
821  int cond1NrL1Objects = 0;
822  int cond2NrL1Objects = 0;
823  LogDebug("L1TGlobal") << " cond0NrL1Objects" << cond0NrL1Objects << " cond1NrL1Objects " << cond1NrL1Objects
824  << " cond2NrL1Objects " << cond2NrL1Objects;
825 
826  switch (cond0Categ) {
827  case CondMuon: {
828  cond0Condition = &((corrMuon[iChip])[cond0Ind]);
829  } break;
830  case CondCalo: {
831  cond0Condition = &((corrCalo[iChip])[cond0Ind]);
832  } break;
833  case CondEnergySum: {
834  cond0Condition = &((corrEnergySum[iChip])[cond0Ind]);
835  } break;
836  default: {
837  // do nothing, should not arrive here
838  } break;
839  }
840 
841  switch (cond1Categ) {
842  case CondMuon: {
843  cond1Condition = &((corrMuon[iChip])[cond1Ind]);
844  } break;
845  case CondCalo: {
846  cond1Condition = &((corrCalo[iChip])[cond1Ind]);
847  } break;
848  case CondEnergySum: {
849  cond1Condition = &((corrEnergySum[iChip])[cond1Ind]);
850  } break;
851  default: {
852  // do nothing, should not arrive here
853  } break;
854  }
855 
856  switch (cond2Categ) {
857  case CondMuon: {
858  cond2Condition = &((corrMuon[iChip])[cond2Ind]);
859  } break;
860  case CondCalo: {
861  cond2Condition = &((corrCalo[iChip])[cond2Ind]);
862  } break;
863  case CondEnergySum: {
864  cond2Condition = &((corrEnergySum[iChip])[cond2Ind]);
865  } break;
866  default: {
867  // do nothing, should not arrive here
868  } break;
869  }
870 
871  CorrWithOverlapRemovalCondition* correlationCondWOR =
872  new CorrWithOverlapRemovalCondition(itCond->second, cond0Condition, cond1Condition, cond2Condition, this);
873 
874  correlationCondWOR->setVerbosity(m_verbosity);
875  correlationCondWOR->setScales(&gtScales);
876  correlationCondWOR->evaluateConditionStoreResult(iBxInEvent);
877 
878  cMapResults[itCond->first] = correlationCondWOR;
879 
880  if (m_verbosity && m_isDebugEnabled) {
881  std::ostringstream myCout;
882  correlationCondWOR->print(myCout);
883 
884  LogTrace("L1TGlobal") << myCout.str();
885  }
886 
887  // delete correlationCondWOR;
888 
889  } break;
890  case CondNull: {
891  // do nothing
892 
893  } break;
894  default: {
895  // do nothing
896 
897  } break;
898  }
899  }
900  }
901 
902  // -----------------------
903  // Loop over algorithm map
904  // -----------------------
905  // Empty vector for object maps - filled during loop
906  std::vector<GlobalObjectMap> objMapVec;
907  if (produceL1GtObjectMapRecord && (iBxInEvent == 0))
908  objMapVec.reserve(numberPhysTriggers);
909 
910  for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
911  AlgorithmEvaluation gtAlg(itAlgo->second);
912  gtAlg.evaluateAlgorithm((itAlgo->second).algoChipNumber(), m_conditionResultMaps);
913 
914  int algBitNumber = (itAlgo->second).algoBitNumber();
915  bool algResult = gtAlg.gtAlgoResult();
916 
917  LogDebug("L1TGlobal") << " ===> for iBxInEvent = " << iBxInEvent << ":\t algBitName = " << itAlgo->first
918  << ",\t algBitNumber = " << algBitNumber << ",\t algResult = " << algResult;
919 
920  if (algResult) {
921  // m_gtlAlgorithmOR.set(algBitNumber);
922  m_uGtAlgBlk.setAlgoDecisionInitial(algBitNumber, algResult);
923  m_algInitialOr = true;
924  }
925 
926  if (m_verbosity && m_isDebugEnabled) {
927  std::ostringstream myCout;
928  (itAlgo->second).print(myCout);
929  gtAlg.print(myCout);
930 
931  LogTrace("L1TGlobal") << myCout.str();
932  }
933 
934  // object maps only for BxInEvent = 0
935  if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
936  std::vector<L1TObjectTypeInCond> otypes;
937  for (auto iop = gtAlg.operandTokenVector().begin(); iop != gtAlg.operandTokenVector().end(); ++iop) {
938  //cout << "INFO: operand name: " << iop->tokenName << "\n";
939  int found = 0;
941  for (auto imap = conditionMap.begin(); imap != conditionMap.end(); imap++) {
942  auto match = imap->find(iop->tokenName);
943 
944  if (match != imap->end()) {
945  found = 1;
946  //cout << "DEBUG: found match for " << iop->tokenName << " at " << match->first << "\n";
947 
948  otype = match->second->objectType();
949 
950  for (auto itype = otype.begin(); itype != otype.end(); itype++) {
951  //cout << "type: " << *itype << "\n";
952  }
953  }
954  }
955  if (!found) {
956  edm::LogWarning("L1TGlobal") << "\n Failed to find match for operand token " << iop->tokenName << "\n";
957  } else {
958  otypes.push_back(otype);
959  }
960  }
961 
962  // set object map
963  GlobalObjectMap objMap;
964 
965  objMap.setAlgoName(itAlgo->first);
966  objMap.setAlgoBitNumber(algBitNumber);
967  objMap.setAlgoGtlResult(algResult);
970  // gtAlg is empty now...
971  objMap.swapObjectTypeVector(otypes);
972 
973  if (m_verbosity && m_isDebugEnabled) {
974  std::ostringstream myCout1;
975  objMap.print(myCout1);
976 
977  LogTrace("L1TGlobal") << myCout1.str();
978  }
979 
980  objMapVec.push_back(objMap);
981  }
982  }
983 
984  // object maps only for BxInEvent = 0
985  if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
986  gtObjectMapRecord->swapGtObjectMap(objMapVec);
987  }
988 
989  // loop over condition maps (one map per condition chip)
990  // then loop over conditions in the map
991  // delete the conditions created with new, zero pointer, do not clear map, keep the vector as is...
992  for (std::vector<AlgorithmEvaluation::ConditionEvaluationMap>::iterator itCondOnChip = m_conditionResultMaps.begin();
993  itCondOnChip != m_conditionResultMaps.end();
994  itCondOnChip++) {
995  for (AlgorithmEvaluation::ItEvalMap itCond = itCondOnChip->begin(); itCond != itCondOnChip->end(); itCond++) {
996  delete itCond->second;
997  itCond->second = nullptr;
998  }
999  }
1000 }
1001 
1002 // -------
1003 // Run GTL
1004 // -------
1006  const int iBxInEvent,
1007  const int totalBxInEvent,
1008  const unsigned int numberPhysTriggers,
1009  const std::vector<double>& prescaleFactorsAlgoTrig,
1010  const std::vector<unsigned int>& triggerMaskAlgoTrig,
1011  const std::vector<int>& triggerMaskVetoAlgoTrig,
1012  const bool algorithmTriggersUnprescaled,
1013  const bool algorithmTriggersUnmasked) {
1014  if (m_verbosity) {
1015  LogDebug("L1TGlobal") << "\n**** GlobalBoard apply Final Decision Logic ";
1016  }
1017 
1018  // update and clear prescales at the beginning of the luminosity segment
1019  if (m_prescaleCounterAlgoTrig.empty() or
1020  (m_currentLumi != iEvent.luminosityBlock() and m_resetPSCountersEachLumiSec)) {
1021  m_prescaleCounterAlgoTrig.clear();
1022  m_prescaleCounterAlgoTrig.reserve(totalBxInEvent);
1023  auto const& prescaleCountersAlgoTrig =
1024  m_semiRandomInitialPSCounters ? prescaleCountersWithSemirandomInitialCounter(prescaleFactorsAlgoTrig, iEvent)
1025  : prescaleCounters(prescaleFactorsAlgoTrig);
1026  for (int iBxInEvent = 0; iBxInEvent < totalBxInEvent; ++iBxInEvent) {
1027  m_prescaleCounterAlgoTrig.push_back(prescaleCountersAlgoTrig);
1028  }
1029 
1030  m_currentLumi = iEvent.luminosityBlock();
1031  }
1032 
1033  // Copy Algorithm bits to Prescaled word
1034  // Prescaling and Masking done below if requested.
1035  m_uGtAlgBlk.copyInitialToInterm();
1036 
1037  // -------------------------------------------
1038  // Apply Prescales or skip if turned off
1039  // -------------------------------------------
1040  if (!algorithmTriggersUnprescaled) {
1041  // iBxInEvent is ... -2 -1 0 1 2 ... while counters are 0 1 2 3 4 ...
1042  int const inBxInEvent = totalBxInEvent / 2 + iBxInEvent;
1043 
1044  bool temp_algPrescaledOr = false;
1045  bool alreadyReported = false;
1046  for (unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit) {
1047  bool const bitValue = m_uGtAlgBlk.getAlgoDecisionInitial(iBit);
1048  if (bitValue) {
1049  // Make sure algo bit in range, warn otherwise
1050  if (iBit < prescaleFactorsAlgoTrig.size()) {
1051  if (prescaleFactorsAlgoTrig.at(iBit) != 1) {
1052  bool const triggered = m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit).accept();
1053  if (triggered) {
1054  temp_algPrescaledOr = true;
1055  } else {
1056  // change bit to false in prescaled word and final decision word
1057  m_uGtAlgBlk.setAlgoDecisionInterm(iBit, false);
1058  } //if Prescale counter reached zero
1059  } //if prescale factor is not 1 (ie. no prescale)
1060  else {
1061  temp_algPrescaledOr = true;
1062  }
1063  } // require bit in range
1064  else if (!alreadyReported) {
1065  alreadyReported = true;
1066  edm::LogWarning("L1TGlobal") << "\nWarning: algoBit >= prescaleFactorsAlgoTrig.size() in bx " << iBxInEvent;
1067  }
1068  } //if algo bit is set true
1069  } //loop over alg bits
1070 
1071  m_algPrescaledOr = temp_algPrescaledOr; //temp
1072 
1073  } else {
1074  // Since not Prescaling just take OR of Initial Work
1075  m_algPrescaledOr = m_algInitialOr;
1076 
1077  } //if we are going to apply prescales.
1078 
1079  // Copy Algorithm bits fron Prescaled word to Final Word
1080  // Masking done below if requested.
1081  m_uGtAlgBlk.copyIntermToFinal();
1082 
1083  if (!algorithmTriggersUnmasked) {
1084  bool temp_algFinalOr = false;
1085  bool alreadyReported = false;
1086  for (unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit) {
1087  const bool bitValue = m_uGtAlgBlk.getAlgoDecisionInterm(iBit);
1088 
1089  if (bitValue) {
1090  //bool isMasked = ( triggerMaskAlgoTrig.at(iBit) == 0 );
1091  bool isMasked = false;
1092  if (iBit < triggerMaskAlgoTrig.size())
1093  isMasked = (triggerMaskAlgoTrig.at(iBit) == 0);
1094  else if (!alreadyReported) {
1095  alreadyReported = true;
1096  edm::LogWarning("L1TGlobal") << "\nWarning: algoBit >= triggerMaskAlgoTrig.size() in bx " << iBxInEvent;
1097  }
1098 
1099  bool const passMask = (bitValue && !isMasked);
1100 
1101  if (passMask)
1102  temp_algFinalOr = true;
1103  else
1104  m_uGtAlgBlk.setAlgoDecisionFinal(iBit, false);
1105 
1106  // Check if veto mask is true, if it is, set the event veto flag.
1107  if (triggerMaskVetoAlgoTrig.at(iBit) == 1)
1108  m_algFinalOrVeto = true;
1109  }
1110  }
1111 
1112  m_algIntermOr = temp_algFinalOr;
1113 
1114  } else {
1115  m_algIntermOr = m_algPrescaledOr;
1116 
1117  }
1118 
1119  // --------------------------
1120  // Set FinalOR for this board
1121  // --------------------------
1122  m_algFinalOr = (m_algIntermOr & !m_algFinalOrVeto);
1123 }
1124 
1125 // Fill DAQ Record
1127  std::unique_ptr<GlobalAlgBlkBxCollection>& uGtAlgRecord,
1128  int prescaleSet,
1129  int menuUUID,
1130  int firmwareUUID) {
1131  if (m_verbosity) {
1132  LogDebug("L1TGlobal") << "\n**** GlobalBoard fill DAQ Records for bx= " << iBxInEvent;
1133  }
1134 
1135  // Set header information
1136  m_uGtAlgBlk.setbxInEventNr((iBxInEvent & 0xF));
1137  m_uGtAlgBlk.setPreScColumn(prescaleSet);
1138  m_uGtAlgBlk.setL1MenuUUID(menuUUID);
1139  m_uGtAlgBlk.setL1FirmwareUUID(firmwareUUID);
1140 
1141  m_uGtAlgBlk.setFinalORVeto(m_algFinalOrVeto);
1142  m_uGtAlgBlk.setFinalORPreVeto(m_algIntermOr);
1143  m_uGtAlgBlk.setFinalOR(m_algFinalOr);
1144 
1145  uGtAlgRecord->push_back(iBxInEvent, m_uGtAlgBlk);
1146 }
1147 
1148 // clear GTL
1150  resetMu();
1151  resetMuonShower();
1152  resetCalo();
1153  resetExternal();
1154 
1155  m_uGtAlgBlk.reset();
1156 
1157  m_gtlDecisionWord.reset();
1158  m_gtlAlgorithmOR.reset();
1159 }
1160 
1161 // clear muon
1163  m_candL1Mu->clear();
1164  m_candL1Mu->setBXRange(m_bxFirst_, m_bxLast_);
1165 }
1166 
1167 // clear muon shower
1169  m_candL1MuShower->clear();
1170  m_candL1MuShower->setBXRange(m_bxFirst_, m_bxLast_);
1171 }
1172 
1173 // clear calo
1175  m_candL1EG->clear();
1176  m_candL1Tau->clear();
1177  m_candL1Jet->clear();
1178  m_candL1EtSum->clear();
1179  m_candL1EtSumZdc->clear();
1180 
1181  m_candL1EG->setBXRange(m_bxFirst_, m_bxLast_);
1182  m_candL1Tau->setBXRange(m_bxFirst_, m_bxLast_);
1183  m_candL1Jet->setBXRange(m_bxFirst_, m_bxLast_);
1184  m_candL1EtSum->setBXRange(m_bxFirst_, m_bxLast_);
1185  m_candL1EtSumZdc->setBXRange(m_bxFirst_, m_bxLast_);
1186 }
1187 
1189  m_candL1External->clear();
1190  m_candL1External->setBXRange(m_bxFirst_, m_bxLast_);
1191 }
1192 
1193 // print Global Muon Trigger data received
1194 void l1t::GlobalBoard::printGmtData(const int iBxInEvent) const {
1195  LogTrace("L1TGlobal") << "\nl1t::L1GlobalTrigger: uGMT data received for BxInEvent = " << iBxInEvent;
1196 
1197  int nrL1Mu = m_candL1Mu->size(iBxInEvent);
1198  LogTrace("L1TGlobal") << "Number of GMT muons = " << nrL1Mu << "\n";
1199 }
1200 
1201 // initialize prescale counters to zero
1202 std::vector<l1t::GlobalBoard::PrescaleCounter> l1t::GlobalBoard::prescaleCounters(
1203  std::vector<double> const& prescaleFactorsAlgoTrig) {
1204  std::vector<PrescaleCounter> out;
1205  out.reserve(prescaleFactorsAlgoTrig.size());
1206  for (size_t iAlgo = 0; iAlgo < prescaleFactorsAlgoTrig.size(); ++iAlgo) {
1207  out.emplace_back(prescaleFactorsAlgoTrig[iAlgo]);
1208  }
1209  return out;
1210 }
1211 
1212 // initialises prescale counters with a semi-random value in the range [0, prescale*10^precision - 1]
1213 std::vector<l1t::GlobalBoard::PrescaleCounter> l1t::GlobalBoard::prescaleCountersWithSemirandomInitialCounter(
1214  std::vector<double> const& prescaleFactorsAlgoTrig, edm::Event const& iEvent) {
1215  // pick a (semi)random number seeding based on run, lumi, event numbers,
1216  // this leads to different (semi)random numbers for different streams,
1217  // reminder: different streams have different initial event number
1218  std::srand(iEvent.id().run());
1219  std::srand(std::rand() + iEvent.id().luminosityBlock());
1220  std::srand(std::rand() + iEvent.id().event());
1221  int const semirandom = std::rand();
1222 
1223  std::vector<PrescaleCounter> out;
1224  out.reserve(prescaleFactorsAlgoTrig.size());
1225 
1226  for (size_t iAlgo = 0; iAlgo < prescaleFactorsAlgoTrig.size(); ++iAlgo) {
1227  out.emplace_back(prescaleFactorsAlgoTrig[iAlgo]);
1228  // initialise trigger_counter to a (semi)random integer
1229  // between 0 and prescale_count - 1 (both inclusive)
1230  // (this only changes the behaviour of triggers with PS > 1)
1231  auto& prescaleCounter = out.back();
1232  if (prescaleCounter.prescale_count > 0) {
1233  prescaleCounter.trigger_counter = semirandom % prescaleCounter.prescale_count;
1234  }
1235  }
1236 
1237  return out;
1238 }
1239 
1240 // return decision of PrescalCounter, and update its internal counter
1242  trigger_counter += m_singlestep;
1243 
1244  if (prescale_count == 0 or trigger_counter < prescale_count)
1245  return false;
1246 
1247  trigger_counter -= prescale_count;
1248 
1249  return true;
1250 }
bool isDebugEnabled()
void setAlgoBitNumber(int algoBitNumberValue)
void print(std::ostream &myCout) const override
print condition
const int cond0Index() const
get / set the index of the two sub-conditions in the cor* vector from menu
const l1t::GlobalScales & gtScales() const
get the scales
Definition: TriggerMenu.h:208
void evaluateConditionStoreResult(const int bxEval)
call evaluateCondition and save last result
std::vector< l1t::GlobalObject > L1TObjectTypeInCond
void swapOperandTokenVector(std::vector< GlobalLogicParser::OperandToken > &operandTokenVectorValue)
const std::vector< std::vector< CaloTemplate > > & corCaloTemplate() const
Definition: TriggerMenu.h:185
void print(std::ostream &myCout) const override
print condition
Definition: MuCondition.cc:516
void print(std::ostream &myCout) const override
print condition
void print(std::ostream &myCout) const override
print condition
const l1t::AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
Definition: TriggerMenu.h:198
static std::vector< PrescaleCounter > prescaleCountersWithSemirandomInitialCounter(std::vector< double > const &prescaleFactorsAlgoTrig, edm::Event const &iEvent)
void setVerbosity(const int verbosity)
const int cond1Index() const
virtual std::string getScalesName() const
Definition: GlobalScales.cc:27
void fillAlgRecord(int iBxInEvent, std::unique_ptr< GlobalAlgBlkBxCollection > &uGtAlgRecord, int prescaleSet, int menuUUID, int firmwareUUID)
Fill the Daq Records.
const std::vector< std::vector< MuonTemplate > > & corMuonTemplate() const
Definition: TriggerMenu.h:180
unsigned long long m_l1MuTriggerScalesCacheID
Definition: GlobalBoard.h:222
delete x;
Definition: CaloConfig.h:22
void setBxLast(int bx)
Definition: GlobalBoard.cc:113
const l1t::GtConditionCategory cond1Category() const
void runFDL(const edm::Event &iEvent, const int iBxInEvent, const int totalBxInEvent, const unsigned int numberPhysTriggers, const std::vector< double > &prescaleFactorsAlgoTrig, const std::vector< unsigned int > &triggerMaskAlgoTrig, const std::vector< int > &triggerMaskVetoAlgoTrig, const bool algorithmTriggersUnprescaled, const bool algorithmTriggersUnmasked)
run the uGT FDL (Apply Prescales and Veto)
const int cond0Index() const
get / set the index of the two sub-conditions in the cor* vector from menu
void print(std::ostream &myCout) const
print the full object map
const l1t::GtConditionCategory cond1Category() const
void swapObjectTypeVector(std::vector< L1TObjectTypeInCond > &objectTypeVectorValue)
void swapCombinationVector(std::vector< CombinationsInCond > &combinationVectorValue)
ConditionEvaluationMap::iterator ItEvalMap
void printGmtData(const int iBxInEvent) const
print received Muon dataWord
void print(std::ostream &myCout) const
unsigned long long m_l1GtMenuCacheID
Definition: GlobalBoard.h:215
void print(std::ostream &myCout) const override
print condition
#define LogTrace(id)
static std::vector< PrescaleCounter > prescaleCounters(std::vector< double > const &prescaleFactorsAlgoTrig)
const l1t::GtConditionCategory cond2Category() const
std::bitset< GlobalAlgBlk::maxPhysicsTriggers > m_gtlDecisionWord
Definition: GlobalBoard.h:246
ConditionMap::const_iterator CItCond
iterators through map containing the conditions
GtConditionCategory
condition categories
const l1t::GtConditionCategory cond0Category() const
get / set the category of the thre sub-conditions
int iEvent
Definition: GenABIO.cc:224
const l1t::GtConditionCategory cond0Category() const
get / set the category of the two sub-conditions
unsigned int m_boardEventCount
Definition: GlobalBoard.h:268
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
Definition: Muon.py:1
void print(std::ostream &myCout) const override
print condition
void reset()
reset the content of a GlobalAlgBlk
void print(std::ostream &myCout) const override
print condition
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void runGTL(const edm::Event &iEvent, const edm::EventSetup &evSetup, const TriggerMenu *m_l1GtMenu, const bool produceL1GtObjectMapRecord, const int iBxInEvent, std::unique_ptr< GlobalObjectMapRecord > &gtObjectMapRecord, const unsigned int numberPhysTriggers, const int nrL1Mu, const int nrL1MuShower, const int nrL1EG, const int nrL1Tau, const int nrL1Jet)
run the uGT GTL (Conditions and Algorithms)
Definition: GlobalBoard.cc:496
void reset()
clear uGT
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
unsigned long long m_l1CaloGeometryCacheID
Definition: GlobalBoard.h:219
const l1t::GtConditionCategory cond1Category() const
void setAlgoGtlResult(bool algoGtlResultValue)
std::vector< CombinationsInCond > & gtAlgoCombinationVector()
std::vector< std::vector< PrescaleCounter > > m_prescaleCounterAlgoTrig
Definition: GlobalBoard.h:304
void setScales(const GlobalScales *)
void evaluateAlgorithm(const int chipNumber, const std::vector< ConditionEvaluationMap > &)
evaluate an algorithm
void receiveExternalData(const edm::Event &, const edm::EDGetTokenT< BXVector< GlobalExtBlk >> &, const bool receiveExt)
Definition: GlobalBoard.cc:459
bool gtAlgoResult() const
get / set the result of the algorithm
GlobalAlgBlk m_uGtAlgBlk
Definition: GlobalBoard.h:248
void setBxFirst(int bx)
Definition: GlobalBoard.cc:111
void setAlgoName(const std::string &algoNameValue)
const std::vector< l1t::ConditionMap > & gtConditionMap() const
get / set / build the condition maps
Definition: TriggerMenu.h:83
bool isValid() const
Definition: HandleBase.h:70
void receiveCaloObjectData(const edm::Event &, const edm::EDGetTokenT< BXVector< l1t::EGamma >> &, const edm::EDGetTokenT< BXVector< l1t::Tau >> &, const edm::EDGetTokenT< BXVector< l1t::Jet >> &, const edm::EDGetTokenT< BXVector< l1t::EtSum >> &, const edm::EDGetTokenT< BXVector< l1t::EtSum >> &, const bool receiveEG, const int nrL1EG, const bool receiveTau, const int nrL1Tau, const bool receiveJet, const int nrL1Jet, const bool receiveEtSums, const bool receiveEtSumsZdc)
receive data from Global Muon Trigger
Definition: GlobalBoard.cc:141
const std::vector< std::vector< EnergySumTemplate > > & corEnergySumTemplate() const
Definition: TriggerMenu.h:191
HLT enums.
void print(std::ostream &myCout) const override
print condition
virtual ~GlobalBoard()
Definition: GlobalBoard.cc:99
std::vector< GlobalLogicParser::OperandToken > & operandTokenVector()
void setScales(const GlobalScales *)
const int cond0Index() const
get / set the index of the three subconditions in the cor* vector from menu
void init(const int numberPhysTriggers, const int nrL1Mu, const int nrL1MuShower, const int nrL1EG, const int nrL1Tau, const int nrL1Jet, int bxFirst, int bxLast)
initialize the class (mainly reserve)
Definition: GlobalBoard.cc:115
void print(std::ostream &myCout) const override
print condition
std::unordered_map< std::string, ConditionEvaluation * > ConditionEvaluationMap
copy constructor
const l1t::GtConditionCategory cond0Category() const
get / set the category of the three subconditions
Log< level::Warning, false > LogWarning
Definition: memstream.h:15
std::bitset< GlobalAlgBlk::maxPhysicsTriggers > m_gtlAlgorithmOR
Definition: GlobalBoard.h:245
std::map< std::string, GlobalAlgorithm > AlgorithmMap
map containing the algorithms
const l1t::GtConditionCategory cond2Category() const
void receiveMuonShowerObjectData(const edm::Event &, const edm::EDGetTokenT< BXVector< l1t::MuonShower >> &, const bool receiveMuShower, const int nrL1MuShower)
Definition: GlobalBoard.cc:395
void receiveMuonObjectData(const edm::Event &, const edm::EDGetTokenT< BXVector< l1t::Muon >> &, const bool receiveMu, const int nrL1Mu)
Definition: GlobalBoard.cc:348
void print(std::ostream &myCout) const override
print condition
#define LogDebug(id)