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