CMS 3D CMS Logo

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