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