CMS 3D CMS Logo

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