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