CMS 3D CMS Logo

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