test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_ );
129  m_candL1External->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  for(std::vector<l1t::EGamma>::const_iterator eg = egData->begin(i); eg != egData->end(i); ++eg) {
183 
184  (*m_candL1EG).push_back(i,&(*eg));
185  LogDebug("L1TGlobal") << "EG Pt " << eg->hwPt() << " Eta " << eg->hwEta() << " Phi " << eg->hwPhi() << " Qual " << eg->hwQual() <<" Iso " << eg->hwIso() << std::endl;
186  } //end loop over EG in bx
187  } //end loop over bx
188 
189  } //end if over valid EG data
190 
191  } //end if ReveiveEG data
192 
193 
194  if (receiveTau) {
196  iEvent.getByToken(tauInputToken, tauData);
197 
198  if (!tauData.isValid()) {
199  if (m_verbosity) {
200  edm::LogWarning("L1TGlobal")
201  << "\nWarning: BXVector<l1t::Tau> with input tag "
202  //<< caloInputTag
203  << "\nrequested in configuration, but not found in the event.\n"
204  << std::endl;
205  }
206  } else {
207  // bx in tau data
208  for(int i = tauData->getFirstBX(); i <= tauData->getLastBX(); ++i) {
209 
210  // Prevent from pushing back bx that is outside of allowed range
211  if( i < m_bxFirst_ || i > m_bxLast_ ) continue;
212 
213  //Loop over tau in this bx
214  for(std::vector<l1t::Tau>::const_iterator tau = tauData->begin(i); tau != tauData->end(i); ++tau) {
215 
216  (*m_candL1Tau).push_back(i,&(*tau));
217  LogDebug("L1TGlobal") << "tau Pt " << tau->hwPt() << " Eta " << tau->hwEta() << " Phi " << tau->hwPhi() << " Qual " << tau->hwQual() <<" Iso " << tau->hwIso() << std::endl;
218  } //end loop over tau in bx
219  } //end loop over bx
220 
221  } //end if over valid tau data
222 
223  } //end if ReveiveTau data
224 
225 
226  if (receiveJet) {
228  iEvent.getByToken(jetInputToken, jetData);
229 
230  if (!jetData.isValid()) {
231  if (m_verbosity) {
232  edm::LogWarning("L1TGlobal")
233  << "\nWarning: BXVector<l1t::Jet> with input tag "
234  //<< caloInputTag
235  << "\nrequested in configuration, but not found in the event.\n"
236  << std::endl;
237  }
238  } else {
239  // bx in jet data
240  for(int i = jetData->getFirstBX(); i <= jetData->getLastBX(); ++i) {
241 
242  // Prevent from pushing back bx that is outside of allowed range
243  if( i < m_bxFirst_ || i > m_bxLast_ ) continue;
244 
245  //Loop over jet in this bx
246  for(std::vector<l1t::Jet>::const_iterator jet = jetData->begin(i); jet != jetData->end(i); ++jet) {
247 
248  (*m_candL1Jet).push_back(i,&(*jet));
249  LogDebug("L1TGlobal") << "Jet Pt " << jet->hwPt() << " Eta " << jet->hwEta() << " Phi " << jet->hwPhi() << " Qual " << jet->hwQual() <<" Iso " << jet->hwIso() << std::endl;
250  } //end loop over jet in bx
251  } //end loop over bx
252 
253  } //end if over valid jet data
254 
255  } //end if ReveiveJet data
256 
257 
258  if(receiveEtSums) {
260  iEvent.getByToken(sumInputToken, etSumData);
261 
262  if(!etSumData.isValid()) {
263  if (m_verbosity) {
264  edm::LogWarning("L1TGlobal")
265  << "\nWarning: BXVector<l1t::EtSum> with input tag "
266  //<< caloInputTag
267  << "\nrequested in configuration, but not found in the event.\n"
268  << std::endl;
269  }
270  } else {
271 
272  for(int i = etSumData->getFirstBX(); i <= etSumData->getLastBX(); ++i) {
273 
274  // Prevent from pushing back bx that is outside of allowed range
275  if( i < m_bxFirst_ || i > m_bxLast_ ) continue;
276 
277  //Loop over jet in this bx
278  for(std::vector<l1t::EtSum>::const_iterator etsum = etSumData->begin(i); etsum != etSumData->end(i); ++etsum) {
279 
280  (*m_candL1EtSum).push_back(i,&(*etsum));
281 
282 /* In case we need to split these out
283  switch ( etsum->getType() ) {
284  case l1t::EtSum::EtSumType::kMissingEt:
285  (*m_candETM).push_back(i,&(*etsum));
286  LogDebug("L1TGlobal") << "ETM: Pt " << etsum->hwPt() << " Phi " << etsum->hwPhi() << std::endl;
287  break;
288  case l1t::EtSum::EtSumType::kMissingHt:
289  (*m_candHTM.push_back(i,&(*etsum);
290  LogDebug("L1TGlobal") << "HTM: Pt " << etsum->hwPt() << " Phi " << etsum->hwPhi() << std::endl;
291  break;
292  case l1t::EtSum::EtSumType::kTotalEt:
293  (*m_candETT.push_back(i,&(*etsum);
294  LogDebug("L1TGlobal") << "ETT: Pt " << etsum->hwPt() << std::endl;
295  break;
296  case l1t::EtSum::EtSumType::kTotalHt:
297  (*m_candHTT.push_back(i,&(*etsum);
298  LogDebug("L1TGlobal") << "HTT: Pt " << etsum->hwPt() << std::endl;
299  break;
300  }
301 */
302 
303  } //end loop over jet in bx
304  } //end loop over Bx
305 
306  }
307 
308 
309  }
310 
311 }
312 
313 
314 // receive data from Global Muon Trigger
316  const edm::EDGetTokenT<BXVector<l1t::Muon> >& muInputToken, const bool receiveMu,
317  const int nrL1Mu) {
318 
319  if (m_verbosity) {
320  LogDebug("L1TGlobal")
321  << "\n**** GlobalBoard receiving muon data = "
322  //<< "\n from input tag " << muInputTag << "\n"
323  << std::endl;
324  }
325 
326  resetMu();
327 
328  // get data from Global Muon Trigger
329  if (receiveMu) {
331  iEvent.getByToken(muInputToken, muonData);
332 
333  if (!muonData.isValid()) {
334  if (m_verbosity) {
335  edm::LogWarning("L1TGlobal")
336  << "\nWarning: BXVector<l1t::Muon> with input tag "
337  //<< muInputTag
338  << "\nrequested in configuration, but not found in the event.\n"
339  << std::endl;
340  }
341  } else {
342  // bx in muon data
343  for(int i = muonData->getFirstBX(); i <= muonData->getLastBX(); ++i) {
344 
345  // Prevent from pushing back bx that is outside of allowed range
346  if( i < m_bxFirst_ || i > m_bxLast_ ) continue;
347 
348  //Loop over Muons in this bx
349  for(std::vector<l1t::Muon>::const_iterator mu = muonData->begin(i); mu != muonData->end(i); ++mu) {
350 
351  (*m_candL1Mu).push_back(i,&(*mu));
352  LogDebug("L1TGlobal") << "Muon Pt " << mu->hwPt() << " Eta " << mu->hwEta() << " Phi " << mu->hwPhi() << " Qual " << mu->hwQual() <<" Iso " << mu->hwIso() << std::endl;
353  } //end loop over muons in bx
354  } //end loop over bx
355 
356  } //end if over valid muon data
357 
358  } //end if ReveiveMuon data
359 
360 
361 }
362 
363 // receive data from Global External Conditions
365  const edm::EDGetTokenT<BXVector<GlobalExtBlk> >& extInputToken, const bool receiveExt
366  ) {
367 
368  if (m_verbosity) {
369  LogDebug("L1TGlobal")
370  << "\n**** GlobalBoard receiving external data = "
371  //<< "\n from input tag " << muInputTag << "\n"
372  << std::endl;
373  }
374 
375  resetExternal();
376 
377  // get data from Global Muon Trigger
378  if (receiveExt) {
380  iEvent.getByToken(extInputToken, extData);
381 
382  if (!extData.isValid()) {
383  if (m_verbosity) {
384  edm::LogWarning("L1TGlobal")
385  << "\nWarning: BXVector<GlobalExtBlk> with input tag "
386  //<< muInputTag
387  << "\nrequested in configuration, but not found in the event.\n"
388  << std::endl;
389  }
390  } else {
391  // bx in muon data
392  for(int i = extData->getFirstBX(); i <= extData->getLastBX(); ++i) {
393 
394  // Prevent from pushing back bx that is outside of allowed range
395  if( i < m_bxFirst_ || i > m_bxLast_ ) continue;
396 
397  //Loop over ext in this bx
398  for(std::vector<GlobalExtBlk>::const_iterator ext = extData->begin(i); ext != extData->end(i); ++ext) {
399 
400  (*m_candL1External).push_back(i,&(*ext));
401  } //end loop over ext in bx
402  } //end loop over bx
403 
404  } //end if over valid ext data
405 
406  } //end if ReveiveExt data
407 
408 }
409 
410 
411 // run GTL
413  edm::Event& iEvent, const edm::EventSetup& evSetup, const TriggerMenu* m_l1GtMenu,
414  const bool produceL1GtObjectMapRecord,
415  const int iBxInEvent,
416  std::auto_ptr<GlobalObjectMapRecord>& gtObjectMapRecord,
417  const unsigned int numberPhysTriggers,
418  const int nrL1Mu,
419  const int nrL1EG,
420  const int nrL1Tau,
421  const int nrL1Jet ) {
422 
423  const std::vector<ConditionMap>& conditionMap = m_l1GtMenu->gtConditionMap();
424  const AlgorithmMap& algorithmMap = m_l1GtMenu->gtAlgorithmMap();
425  const GlobalScales& gtScales = m_l1GtMenu->gtScales();
426  const std::string scaleSetName = gtScales.getScalesName();
427  LogDebug("L1TGlobal") << " L1 Menu Scales -- Set Name: " << scaleSetName << std::endl;
428 
429  // Reset AlgBlk for this bx
430  m_uGtAlgBlk.reset();
431  m_algInitialOr=false;
432  m_algPrescaledOr=false;
433  m_algIntermOr=false;
434  m_algFinalOr=false;
435  m_algFinalOrVeto=false;
436 
437 
438  const std::vector<std::vector<MuonTemplate> >& corrMuon =
439  m_l1GtMenu->corMuonTemplate();
440 
441  // Comment out for now
442  const std::vector<std::vector<CaloTemplate> >& corrCalo =
443  m_l1GtMenu->corCaloTemplate();
444 
445  const std::vector<std::vector<EnergySumTemplate> >& corrEnergySum =
446  m_l1GtMenu->corEnergySumTemplate();
447 
448  LogDebug("L1TGlobal") << "Size corrMuon " << corrMuon.size()
449  << "\nSize corrCalo " << corrCalo.size()
450  << "\nSize corrSums " << corrEnergySum.size() << std::endl;
451 
452 
453  // loop over condition maps (one map per condition chip)
454  // then loop over conditions in the map
455  // save the results in temporary maps
456 
457  // never happens in production but at first event...
458  if (m_conditionResultMaps.size() != conditionMap.size()) {
459  m_conditionResultMaps.clear();
460  m_conditionResultMaps.resize(conditionMap.size());
461  }
462 
463  int iChip = -1;
464 
465  for (std::vector<ConditionMap>::const_iterator
466  itCondOnChip = conditionMap.begin(); itCondOnChip != conditionMap.end(); itCondOnChip++) {
467 
468  iChip++;
469 
471  m_conditionResultMaps[iChip];
472 
473 
474 
475  for (CItCond itCond = itCondOnChip->begin(); itCond != itCondOnChip->end(); itCond++) {
476 
477  // evaluate condition
478  switch ((itCond->second)->condCategory()) {
479  case CondMuon: {
480 
481  // BLW Not sure what to do with this for now
482  const int ifMuEtaNumberBits = 0;
483 
484  MuCondition* muCondition = new MuCondition(itCond->second, this,
485  nrL1Mu, ifMuEtaNumberBits);
486 
487  muCondition->setVerbosity(m_verbosity);
488 
489  muCondition->evaluateConditionStoreResult(iBxInEvent);
490 
491  // BLW COmment out for now
492  cMapResults[itCond->first] = muCondition;
493 
494  if (m_verbosity && m_isDebugEnabled) {
495  std::ostringstream myCout;
496  muCondition->print(myCout);
497 
498  LogTrace("L1TGlobal") << myCout.str() << std::endl;
499  }
500  //delete muCondition;
501 
502  }
503  break;
504  case CondCalo: {
505 
506  // BLW Not sure w hat to do with this for now
507  const int ifCaloEtaNumberBits = 0;
508 
509  CaloCondition* caloCondition = new CaloCondition(
510  itCond->second, this,
511  nrL1EG,
512  nrL1Jet,
513  nrL1Tau,
514  ifCaloEtaNumberBits);
515 
516  caloCondition->setVerbosity(m_verbosity);
517 
518  caloCondition->evaluateConditionStoreResult(iBxInEvent);
519 
520 
521  cMapResults[itCond->first] = caloCondition;
522 
523  if (m_verbosity && m_isDebugEnabled) {
524  std::ostringstream myCout;
525  caloCondition->print(myCout);
526 
527  LogTrace("L1TGlobal") << myCout.str() << std::endl;
528  }
529  // delete caloCondition;
530 
531  }
532  break;
533  case CondEnergySum: {
534 
535  EnergySumCondition* eSumCondition = new EnergySumCondition(
536  itCond->second, this);
537 
538  eSumCondition->setVerbosity(m_verbosity);
539  eSumCondition->evaluateConditionStoreResult(iBxInEvent);
540 
541  cMapResults[itCond->first] = eSumCondition;
542 
543  if (m_verbosity && m_isDebugEnabled) {
544  std::ostringstream myCout;
545  eSumCondition->print(myCout);
546 
547  LogTrace("L1TGlobal") << myCout.str() << std::endl;
548  }
549  // delete eSumCondition;
550 
551  }
552  break;
553 
554  case CondExternal: {
555 
556  ExternalCondition* extCondition = new ExternalCondition(
557  itCond->second, this);
558 
559  extCondition->setVerbosity(m_verbosity);
560  extCondition->evaluateConditionStoreResult(iBxInEvent);
561 
562  cMapResults[itCond->first] = extCondition;
563 
564  if (m_verbosity && m_isDebugEnabled) {
565  std::ostringstream myCout;
566  extCondition->print(myCout);
567 
568  LogTrace("L1TGlobal") << myCout.str() << std::endl;
569  }
570  // delete extCondition;
571 
572 
573  }
574  break;
575  case CondCorrelation: {
576 
577 
578 
579 
580  // get first the sub-conditions
581  const CorrelationTemplate* corrTemplate =
582  static_cast<const CorrelationTemplate*>(itCond->second);
583  const GtConditionCategory cond0Categ = corrTemplate->cond0Category();
584  const GtConditionCategory cond1Categ = corrTemplate->cond1Category();
585  const int cond0Ind = corrTemplate->cond0Index();
586  const int cond1Ind = corrTemplate->cond1Index();
587 
588  const GlobalCondition* cond0Condition = 0;
589  const GlobalCondition* cond1Condition = 0;
590 
591  // maximum number of objects received for evaluation of l1t::Type1s condition
592  int cond0NrL1Objects = 0;
593  int cond1NrL1Objects = 0;
594  LogDebug("L1TGlobal") << " cond0NrL1Objects" << cond0NrL1Objects << " cond1NrL1Objects " << cond1NrL1Objects << std::endl;
595 
596 
597  switch (cond0Categ) {
598  case CondMuon: {
599  cond0Condition = &((corrMuon[iChip])[cond0Ind]);
600  }
601  break;
602  case CondCalo: {
603  cond0Condition = &((corrCalo[iChip])[cond0Ind]);
604  }
605  break;
606  case CondEnergySum: {
607  cond0Condition = &((corrEnergySum[iChip])[cond0Ind]);
608  }
609  break;
610  default: {
611  // do nothing, should not arrive here
612  }
613  break;
614  }
615 
616  switch (cond1Categ) {
617  case CondMuon: {
618  cond1Condition = &((corrMuon[iChip])[cond1Ind]);
619  }
620  break;
621  case CondCalo: {
622  cond1Condition = &((corrCalo[iChip])[cond1Ind]);
623  }
624  break;
625  case CondEnergySum: {
626  cond1Condition = &((corrEnergySum[iChip])[cond1Ind]);
627  }
628  break;
629  default: {
630  // do nothing, should not arrive here
631  }
632  break;
633  }
634 
635  CorrCondition* correlationCond =
636  new CorrCondition(itCond->second, cond0Condition, cond1Condition, this);
637 
638  correlationCond->setVerbosity(m_verbosity);
639  correlationCond->setScales(&gtScales);
640  correlationCond->evaluateConditionStoreResult(iBxInEvent);
641 
642  cMapResults[itCond->first] = correlationCond;
643 
644  if (m_verbosity && m_isDebugEnabled) {
645  std::ostringstream myCout;
646  correlationCond->print(myCout);
647 
648  LogTrace("L1TGlobal") << myCout.str() << std::endl;
649  }
650 
651  // delete correlationCond;
652 
653 
654  }
655  break;
656  case CondNull: {
657 
658  // do nothing
659 
660  }
661  break;
662  default: {
663  // do nothing
664 
665  }
666  break;
667  }
668 
669  }
670 
671  }
672 
673  // loop over algorithm map
675  // empty vector for object maps - filled during loop
676  std::vector<GlobalObjectMap> objMapVec;
677  if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) objMapVec.reserve(numberPhysTriggers);
678 
679  for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
680  AlgorithmEvaluation gtAlg(itAlgo->second);
681  gtAlg.evaluateAlgorithm((itAlgo->second).algoChipNumber(), m_conditionResultMaps);
682 
683  int algBitNumber = (itAlgo->second).algoBitNumber();
684  bool algResult = gtAlg.gtAlgoResult();
685 
686  LogDebug("L1TGlobal") << " ===> for iBxInEvent = " << iBxInEvent << ":\t algBitName = " << itAlgo->first << ",\t algBitNumber = " << algBitNumber << ",\t algResult = " << algResult << std::endl;
687 
688  if (algResult) {
689 // m_gtlAlgorithmOR.set(algBitNumber);
690  m_uGtAlgBlk.setAlgoDecisionInitial(algBitNumber,algResult);
691  m_algInitialOr = true;
692  }
693 
694  if (m_verbosity && m_isDebugEnabled) {
695  std::ostringstream myCout;
696  ( itAlgo->second ).print(myCout);
697  gtAlg.print(myCout);
698 
699  LogTrace("L1TGlobal") << myCout.str() << std::endl;
700  }
701 
702 
703  // object maps only for BxInEvent = 0
704  if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
705 
706  std::vector<ObjectTypeInCond> otypes;
707  for (auto iop = gtAlg.operandTokenVector().begin(); iop != gtAlg.operandTokenVector().end(); ++iop){
708  //cout << "INFO: operand name: " << iop->tokenName << "\n";
709  int myChip = -1;
710  int found =0;
711  ObjectTypeInCond otype;
712  for (auto imap = conditionMap.begin(); imap != conditionMap.end(); imap++) {
713  myChip++;
714  auto match = imap->find(iop->tokenName);
715 
716  if (match != imap->end()){
717  found = 1;
718  //cout << "DEBUG: found match for " << iop->tokenName << " at " << match->first << "\n";
719 
720  otype = match->second->objectType();
721 
722  for (auto itype = otype.begin(); itype != otype.end() ; itype++){
723  //cout << "type: " << *itype << "\n";
724  }
725  }
726  }
727  if (!found){
728  edm::LogWarning("L1TGlobal") << "\n Failed to find match for operand token " << iop->tokenName << "\n";
729  } else {
730  otypes.push_back(otype);
731  }
732  }
733 
734  // set object map
735  GlobalObjectMap objMap;
736 
737  objMap.setAlgoName(itAlgo->first);
738  objMap.setAlgoBitNumber(algBitNumber);
739  objMap.setAlgoGtlResult(algResult);
742  // gtAlg is empty now...
743  objMap.swapObjectTypeVector(otypes);
744 
745  if (m_verbosity && m_isDebugEnabled) {
746  std::ostringstream myCout1;
747  objMap.print(myCout1);
748 
749  LogTrace("L1TGlobal") << myCout1.str() << std::endl;
750  }
751 
752  objMapVec.push_back(objMap);
753 
754  }
755 
756 
757  }
758 
759  // object maps only for BxInEvent = 0
760  if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
761  gtObjectMapRecord->swapGtObjectMap(objMapVec);
762  }
763 
764  // loop over condition maps (one map per condition chip)
765  // then loop over conditions in the map
766  // delete the conditions created with new, zero pointer, do not clear map, keep the vector as is...
767  for (std::vector<AlgorithmEvaluation::ConditionEvaluationMap>::iterator
768  itCondOnChip = m_conditionResultMaps.begin();
769  itCondOnChip != m_conditionResultMaps.end(); itCondOnChip++) {
770 
772  itCond = itCondOnChip->begin();
773  itCond != itCondOnChip->end(); itCond++) {
774 
775  delete itCond->second;
776  itCond->second = 0;
777  }
778  }
779 
780 }
781 
782 
783 // run GTL
785  const int iBxInEvent,
786  const int totalBxInEvent,
787  const unsigned int numberPhysTriggers,
788  const std::vector<int>& prescaleFactorsAlgoTrig,
789  const std::vector<unsigned int>& triggerMaskAlgoTrig,
790  const std::vector<unsigned int>& triggerMaskVetoAlgoTrig,
791  const bool algorithmTriggersUnprescaled,
792  const bool algorithmTriggersUnmasked ){
793 
794 
795  if (m_verbosity) {
796  LogDebug("L1TGlobal")
797  << "\n**** GlobalBoard apply Final Decision Logic "
798  << std::endl;
799 
800  }
801 
802 
803  // prescale counters are reset at the beginning of the luminosity segment
804  if( m_firstEv ){
805  // prescale counters: numberPhysTriggers counters per bunch cross
806  m_prescaleCounterAlgoTrig.reserve(numberPhysTriggers*totalBxInEvent);
807 
808  for( int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent ){
809  m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
810  }
811  m_firstEv = false;
812  }
813 
814  // TODO FIXME find the beginning of the luminosity segment
815  if( m_firstEvLumiSegment ){
816 
817  m_prescaleCounterAlgoTrig.clear();
818  for( int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent ){
819  m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
820  }
821 
822  m_firstEvLumiSegment = false;
823  }
824 
825  // Copy Algorithm bits to Prescaled word
826  // Prescaling and Masking done below if requested.
827  m_uGtAlgBlk.copyInitialToInterm();
828 
829 
830  // ----------------------------------------------------
831  // Apply absBXmasking or skip if turned off TO DO
832  // ----------------------------------------------------
833  if( !algorithmTriggersUnmasked ){
834 
835 /* TO DO get absBX masking
836  bool temp_algBxMaskOr = false;
837  for( unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit ){
838 
839  bool bitValue = m_uGtAlgBlk.getAlgoDecisionInterm( iBit );
840 
841  if( bitValue ){
842  bool isMasked = ( triggerMaskAlgoTrig.at(iBit) == 0 );
843 
844  bool passMask = ( bitValue && !isMasked );
845 
846  if( passMask ) temp_algBxMaskOr = true;
847  else m_uGtAlgBlk.setAlgoDecisionFinal(iBit,false);
848 
849  }
850  }
851 
852  m_algIntermOr = temp_algBxMaskOr; */
853  m_algIntermOr = m_algInitialOr;
854 
855  }
856  else {
857 
858  m_algIntermOr = m_algInitialOr;
859 
860  }
861 
862 
863  // Copy Algorithm bits fron Prescaled word to Final Word
864  // Masking done below if requested.
865  m_uGtAlgBlk.copyIntermToFinal();
866 
867  // -------------------------------------------
868  // Apply Prescales or skip if turned off
869  // -------------------------------------------
870  if( !algorithmTriggersUnprescaled ){
871 
872  // iBxInEvent is ... -2 -1 0 1 2 ... while counters are 0 1 2 3 4 ...
873  int inBxInEvent = totalBxInEvent/2 + iBxInEvent;
874 
875  bool temp_algPrescaledOr = false;
876  for( unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit ){
877 
878  bool bitValue = m_uGtAlgBlk.getAlgoDecisionInitial( iBit );
879  if( bitValue ){
880  if( prescaleFactorsAlgoTrig.at(iBit) != 1 ){
881 
882  (m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit))--;
883  if( m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) == 0 ){
884 
885  // bit already true in algoDecisionWord, just reset counter
886  m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) = prescaleFactorsAlgoTrig.at(iBit);
887  temp_algPrescaledOr = true;
888 
889  // Check if veto mask is true, if it is, set the event veto flag.
890  if ( triggerMaskVetoAlgoTrig.at(iBit) == 1 ) m_algFinalOrVeto = true;
891  }
892  else {
893 
894  // change bit to false in prescaled word and final decision word
895  m_uGtAlgBlk.setAlgoDecisionFinal(iBit,false);
896 
897  } //if Prescale counter reached zero
898  } //if prescale factor is not 1 (ie. no prescale)
899  else {
900 
901  temp_algPrescaledOr = true;
902 
903  // Check if veto mask is true, if it is, set the event veto flag.
904  if ( triggerMaskVetoAlgoTrig.at(iBit) == 1 ) m_algFinalOrVeto = true;
905 
906  }
907  } //if algo bit is set true
908  } //loop over alg bits
909 
910  m_algPrescaledOr = temp_algPrescaledOr; //temp
911 
912  }
913  else {
914  // Since not Prescaling just take OR of Initial Work
915  m_algPrescaledOr = m_algIntermOr;
916 
917  }//if we are going to apply prescales.
918 
919 
920 // Set local and FinalOR for this board
921 // FIX ME: Currently in one board operation we are setting the global FINOR as well.
922  m_algFinalOr = (m_algPrescaledOr & !m_algFinalOrVeto);
923 
924 
925 }
926 
927 // Fill DAQ Record
928 void l1t::GlobalBoard::fillAlgRecord(int iBxInEvent,
929  std::auto_ptr<GlobalAlgBlkBxCollection>& uGtAlgRecord,
930  int prescaleSet,
931  int menuUUID,
932  int firmwareUUID
933  )
934 {
935 
936  if (m_verbosity) {
937  LogDebug("L1TGlobal")
938  << "\n**** GlobalBoard fill DAQ Records for bx= " << iBxInEvent
939  << std::endl;
940 
941  }
942 
943 // Set header information
944  m_uGtAlgBlk.setbxInEventNr((iBxInEvent & 0xF));
945  m_uGtAlgBlk.setPreScColumn(prescaleSet);
946  m_uGtAlgBlk.setL1MenuUUID(menuUUID);
947  m_uGtAlgBlk.setL1FirmwareUUID(firmwareUUID);
948 
949  m_uGtAlgBlk.setFinalORVeto(m_algFinalOrVeto);
950  m_uGtAlgBlk.setFinalORPreVeto(m_algPrescaledOr);
951  m_uGtAlgBlk.setFinalOR(m_algFinalOr);
952 
953 
954  uGtAlgRecord->push_back(iBxInEvent, m_uGtAlgBlk);
955 
956 }
957 
958 
959 // clear GTL
961 
962  resetMu();
963  resetCalo();
964  resetExternal();
965 
966  m_uGtAlgBlk.reset();
967 
968  m_gtlDecisionWord.reset();
969  m_gtlAlgorithmOR.reset();
970 
971 
972 
973 }
974 
975 // clear muon
977 
978  m_candL1Mu->clear();
979  m_candL1Mu->setBXRange( m_bxFirst_, m_bxLast_ );
980 
981 }
982 
983 // clear calo
985 
986  m_candL1EG->clear();
987  m_candL1Tau->clear();
988  m_candL1Jet->clear();
989  m_candL1EtSum->clear();
990 
991  m_candL1EG->setBXRange( m_bxFirst_, m_bxLast_ );
992  m_candL1Tau->setBXRange( m_bxFirst_, m_bxLast_ );
993  m_candL1Jet->setBXRange( m_bxFirst_, m_bxLast_ );
994  m_candL1EtSum->setBXRange( m_bxFirst_, m_bxLast_ );
995 
996 }
997 
999 
1000  m_candL1External->clear();
1001  m_candL1External->setBXRange( m_bxFirst_, m_bxLast_ );
1002 
1003 }
1004 
1005 
1006 // print Global Muon Trigger data received
1007 void l1t::GlobalBoard::printGmtData(const int iBxInEvent) const {
1008 
1009  LogTrace("L1TGlobal")
1010  << "\nl1t::L1GlobalTrigger: uGMT data received for BxInEvent = "
1011  << iBxInEvent << std::endl;
1012 
1013  int nrL1Mu = m_candL1Mu->size(iBxInEvent);
1014  LogTrace("L1TGlobal")
1015  << "Number of GMT muons = " << nrL1Mu << "\n"
1016  << std::endl;
1017 
1018  LogTrace("L1TGlobal") << std::endl;
1019 
1020 }
#define LogDebug(id)
bool isDebugEnabled()
void receiveMuonObjectData(edm::Event &, const edm::EDGetTokenT< BXVector< l1t::Muon > > &, const bool receiveMu, const int nrL1Mu)
Definition: GlobalBoard.cc:315
void print(std::ostream &myCout) const
print condition
int i
Definition: DBlmapReader.cc:9
void setAlgoBitNumber(int algoBitNumberValue)
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 evaluateConditionStoreResult(const int bxEval)
call evaluateCondition and save last result
void swapOperandTokenVector(std::vector< GlobalLogicParser::OperandToken > &operandTokenVectorValue)
void print(std::ostream &myCout) const
const l1t::GlobalScales & gtScales() const
get the scales
Definition: TriggerMenu.h:205
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void fillAlgRecord(int iBxInEvent, std::auto_ptr< GlobalAlgBlkBxCollection > &uGtAlgRecord, int prescaleSet, int menuUUID, int firmwareUUID)
Fill the Daq Records.
Definition: GlobalBoard.cc:928
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
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
const std::vector< std::vector< EnergySumTemplate > > & corEnergySumTemplate() const
Definition: TriggerMenu.h:180
unsigned long long m_l1MuTriggerScalesCacheID
Definition: GlobalBoard.h:227
void setBxLast(int bx)
Definition: GlobalBoard.cc:112
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 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
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
void reset()
reset the content of a GlobalAlgBlk
void reset()
clear uGT
Definition: GlobalBoard.cc:960
void receiveExternalData(edm::Event &, const edm::EDGetTokenT< BXVector< GlobalExtBlk > > &, const bool receiveExt)
Definition: GlobalBoard.cc:364
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 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
bool isValid() const
Definition: HandleBase.h:75
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)
std::vector< L1GtObject > ObjectTypeInCond
void evaluateAlgorithm(const int chipNumber, const std::vector< ConditionEvaluationMap > &)
evaluate an algorithm
Definition: Muon.h:16
void swapObjectTypeVector(std::vector< ObjectTypeInCond > &objectTypeVectorValue)
GlobalAlgBlk m_uGtAlgBlk
Definition: GlobalBoard.h:252
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< unsigned int > &triggerMaskVetoAlgoTrig, const bool algorithmTriggersUnprescaled, const bool algorithmTriggersUnmasked)
run the uGT FDL (Apply Prescales and Veto)
Definition: GlobalBoard.cc:784
void setBxFirst(int bx)
Definition: GlobalBoard.cc:106
string const
Definition: compareJSON.py:14
void setAlgoName(const std::string &algoNameValue)
virtual ~GlobalBoard()
Definition: GlobalBoard.cc:91
std::vector< GlobalLogicParser::OperandToken > & operandTokenVector()
const std::vector< std::vector< MuonTemplate > > & corMuonTemplate() const
Definition: TriggerMenu.h:164
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::bitset< GlobalAlgBlk::maxPhysicsTriggers > m_gtlAlgorithmOR
Definition: GlobalBoard.h:249
std::map< std::string, GlobalAlgorithm > AlgorithmMap
map containing the algorithms
virtual std::string getScalesName() const
Definition: GlobalScales.cc:36
void runGTL(edm::Event &iEvent, const edm::EventSetup &evSetup, const TriggerMenu *m_l1GtMenu, const bool produceL1GtObjectMapRecord, const int iBxInEvent, std::auto_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:412