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