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