CMS 3D CMS Logo

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