test
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"
65 
66 
67 // 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<L1GtEnergySumTemplate> >& 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 /* Don't access conditions for now
599  L1GtEnergySumCondition* eSumCondition = new L1GtEnergySumCondition(
600  itCond->second, this);
601 
602  eSumCondition->setVerbosity(m_verbosity);
603  eSumCondition->evaluateConditionStoreResult();
604 
605  cMapResults[itCond->first] = eSumCondition;
606 
607  if (m_verbosity && m_isDebugEnabled) {
608  std::ostringstream myCout;
609  eSumCondition->print(myCout);
610 
611  LogTrace("l1t|Global") << myCout.str() << std::endl;
612  }
613  // delete eSumCondition;
614 
615  }
616  break;
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  }
636  break;
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 
806  // do nothing
807 
808  }
809  break;
810  }
811 
812  }
813 
814  }
815 
816  // loop over algorithm map
818  // empty vector for object maps - filled during loop
819  std::vector<L1GlobalTriggerObjectMap> objMapVec;
820  if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) objMapVec.reserve(numberPhysTriggers);
821 
822  for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
823  AlgorithmEvaluation gtAlg(itAlgo->second);
824  gtAlg.evaluateAlgorithm((itAlgo->second).algoChipNumber(), m_conditionResultMaps);
825 
826  int algBitNumber = (itAlgo->second).algoBitNumber();
827  bool algResult = gtAlg.gtAlgoResult();
828 
829  LogDebug("l1t|Global") << " ===> for iBxInEvent = " << iBxInEvent << ":\t algBitName = " << itAlgo->first << ",\t algBitNumber = " << algBitNumber << ",\t algResult = " << algResult << std::endl;
830 
831  if (algResult) {
832 // m_gtlAlgorithmOR.set(algBitNumber);
833  m_uGtAlgBlk.setAlgoDecisionInitial(algBitNumber,algResult);
834  m_algInitialOr = true;
835  }
836 
837  if (m_verbosity && m_isDebugEnabled) {
838  std::ostringstream myCout;
839  ( itAlgo->second ).print(myCout);
840  gtAlg.print(myCout);
841 
842  LogTrace("l1t|Global") << myCout.str() << std::endl;
843  }
844 
845 
846  // object maps only for BxInEvent = 0
847  if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
848 
849  // set object map
851 
852  objMap.setAlgoName(itAlgo->first);
853  objMap.setAlgoBitNumber(algBitNumber);
854  objMap.setAlgoGtlResult(algResult);
857  // gtAlg is empty now...
858 
859  if (m_verbosity && m_isDebugEnabled) {
860  std::ostringstream myCout1;
861  objMap.print(myCout1);
862 
863  LogTrace("l1t|Global") << myCout1.str() << std::endl;
864  }
865 
866  objMapVec.push_back(objMap);
867 
868  }
869 
870 
871  }
872 
873  // object maps only for BxInEvent = 0
874  if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
875  gtObjectMapRecord->swapGtObjectMap(objMapVec);
876  }
877 
878  // loop over condition maps (one map per condition chip)
879  // then loop over conditions in the map
880  // delete the conditions created with new, zero pointer, do not clear map, keep the vector as is...
881  for (std::vector<AlgorithmEvaluation::ConditionEvaluationMap>::iterator
882  itCondOnChip = m_conditionResultMaps.begin();
883  itCondOnChip != m_conditionResultMaps.end(); itCondOnChip++) {
884 
886  itCond = itCondOnChip->begin();
887  itCond != itCondOnChip->end(); itCond++) {
888 
889  delete itCond->second;
890  itCond->second = 0;
891  }
892  }
893 
894 }
895 
896 
897 // run GTL
899  const int iBxInEvent,
900  const bool algorithmTriggersUnprescaled,
901  const bool algorithmTriggersUnmasked ){
902 
903 
904  if (m_verbosity) {
905  LogDebug("l1t|Global")
906  << "\n**** GtBoard apply Final Decision Logic "
907  << std::endl;
908 
909  }
910 
911 /* Nothing with prescales right now.
912  // prescale counters are reset at the beginning of the luminosity segment
913  if (m_firstEv) {
914 
915  m_firstEv = false;
916  }
917 
918  // TODO FIXME find the beginning of the luminosity segment
919  if (m_firstEvLumiSegment) {
920 
921  m_firstEvLumiSegment = false;
922 
923  }
924 */
925 
926  // Copy Algorithm bits to Prescaled word
927  // Prescaling and Masking done below if requested.
928  m_uGtAlgBlk.copyInitialToPrescaled();
929 
930 
931  // -------------------------------------------
932  // Apply Prescales or skip if turned off
933  // -------------------------------------------
934  if (!algorithmTriggersUnprescaled){
935 /*
936  for (unsigned int iBit = 0; iBit < numberPhysTriggers; ++iBit) {
937 
938  if (prescaleFactorsAlgoTrig.at(iBit) != 1) {
939 
940  bool bitValue = algoDecisionWord.at( iBit );
941  if (bitValue) {
942 
943  (m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit))--;
944  if (m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) == 0) {
945 
946  // bit already true in algoDecisionWord, just reset counter
947  m_prescaleCounterAlgoTrig.at(inBxInEvent).at(iBit) =
948  prescaleFactorsAlgoTrig.at(iBit);
949  } else {
950 
951  // change bit to false in prescaled word and final decision word
952  algoDecisionWord[iBit] = false;
953 
954  } //if Prescale counter reached zero
955  } //if algo bit is set true
956  } //if prescale factor is not 1 (ie. no prescale)
957  } //loop over alg bits
958 */
959  m_algPrescaledOr = m_algInitialOr; //temp
960 
961  } else {
962 
963  // Since not Prescaling just take OR of Initial Work
964  m_algPrescaledOr = m_algInitialOr;
965 
966  }//if we are going to apply prescales.
967 
968 
969 
970  // Copy Algorithm bits fron Prescaled word to Final Word
971  // Masking done below if requested.
972  m_uGtAlgBlk.copyPrescaledToFinal();
973 
974  if(!algorithmTriggersUnmasked) {
975 
976 
977 /*
978  masking the bits goes here.
979 */
980  m_algFinalOr = m_algPrescaledOr;
981 
982  } else {
983 
984  m_algFinalOr = m_algPrescaledOr;
985 
986  }
987 
988 
989 
990 }
991 
992 // Fill DAQ Record
993 void l1t::GtBoard::fillAlgRecord(int iBxInEvent,
994  std::auto_ptr<GlobalAlgBlkBxCollection>& uGtAlgRecord,
995  cms_uint64_t orbNr,
996  int bxNr
997  )
998 {
999 
1000  if (m_verbosity) {
1001  LogDebug("l1t|Global")
1002  << "\n**** GtBoard fill DAQ Records for bx= " << iBxInEvent
1003  << std::endl;
1004 
1005  }
1006 
1007 // Set header information
1008  m_uGtAlgBlk.setOrbitNr((unsigned int)(orbNr & 0xFFFFFFFF));
1009  m_uGtAlgBlk.setbxNr((bxNr & 0xFFFF));
1010  m_uGtAlgBlk.setbxInEventNr((iBxInEvent & 0xF));
1011 
1012 // Set the header information and Final OR
1013  int finalOR = 0x0;
1014  if(m_algFinalOr) finalOR = (finalOR | 0x2);
1015  if(m_uGtFinalBoard) {
1016  finalOR = (finalOR | 0x8);
1017  if( (finalOR >>1) & 0x1 ) finalOR = (finalOR | 0x1);
1018  }
1019  m_uGtAlgBlk.setFinalOR(finalOR);
1020 
1021 
1022  uGtAlgRecord->push_back(iBxInEvent, m_uGtAlgBlk);
1023 
1024 }
1025 
1026 // Fill DAQ Record
1027 void l1t::GtBoard::fillExtRecord(int iBxInEvent,
1028  std::auto_ptr<GlobalExtBlkBxCollection>& uGtExtRecord,
1029  cms_uint64_t orbNr,
1030  int bxNr
1031  )
1032 {
1033 
1034  if (m_verbosity) {
1035  LogDebug("l1t|Global")
1036  << "\n**** Board fill DAQ Records for bx= " << iBxInEvent
1037  << std::endl;
1038 
1039  }
1040 // Set header information
1041  m_uGtExtBlk.setOrbitNr((unsigned int)(orbNr & 0xFFFFFFFF));
1042  m_uGtExtBlk.setbxNr((bxNr & 0xFFFF));
1043  m_uGtExtBlk.setbxInEventNr((iBxInEvent & 0xF));
1044 
1045  uGtExtRecord->push_back(iBxInEvent, m_uGtExtBlk);
1046 
1047 }
1048 
1049 
1050 // clear GTL
1052 
1053  resetMu();
1054  resetCalo();
1055 
1056  m_uGtAlgBlk.reset();
1057  m_uGtExtBlk.reset();
1058 
1059  m_gtlDecisionWord.reset();
1060  m_gtlAlgorithmOR.reset();
1061 
1062 
1063 
1064 }
1065 
1066 // clear muon
1068 
1069  m_candL1Mu->clear();
1070  m_candL1Mu->setBXRange( m_bxFirst_, m_bxLast_ );
1071 
1072 }
1073 
1074 // clear calo
1076 
1077  m_candL1EG->clear();
1078  m_candL1Tau->clear();
1079  m_candL1Jet->clear();
1080  m_candL1EtSum->clear();
1081 
1082  m_candL1EG->setBXRange( m_bxFirst_, m_bxLast_ );
1083  m_candL1Tau->setBXRange( m_bxFirst_, m_bxLast_ );
1084  m_candL1Jet->setBXRange( m_bxFirst_, m_bxLast_ );
1085  m_candL1EtSum->setBXRange( m_bxFirst_, m_bxLast_ );
1086 
1087 }
1088 
1089 // print Global Muon Trigger data received by GTL
1090 void l1t::GtBoard::printGmtData(const int iBxInEvent) const {
1091 
1092  LogTrace("l1t|Global")
1093  << "\nL1GlobalTrigger: GMT data received for BxInEvent = "
1094  << iBxInEvent << std::endl;
1095 
1096  int nrL1Mu = m_candL1Mu->size(iBxInEvent);
1097  LogTrace("l1t|Global")
1098  << "Number of GMT muons = " << nrL1Mu << "\n"
1099  << std::endl;
1100 /*
1101  for (std::vector<const L1MuGMTCand*>::const_iterator iter =
1102  m_candL1Mu->begin(); iter != m_candL1Mu->end(); iter++) {
1103 
1104  LogTrace("l1t|Global") << *(*iter) << std::endl;
1105 
1106  }
1107 */
1108  LogTrace("l1t|Global") << std::endl;
1109 
1110 }
#define LogDebug(id)
GlobalExtBlk m_uGtExtBlk
Definition: GtBoard.h:242
bool isDebugEnabled()
int i
Definition: DBlmapReader.cc:9
void resetMu()
Definition: GtBoard.cc:1067
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:1090
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:898
virtual ~GtBoard()
Definition: GtBoard.cc:121
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:8
void setVerbosity(const int verbosity)
void print(std::ostream &myCout) const
print condition
Definition: MuCondition.cc:592
__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
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#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:1051
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:62
void resetCalo()
Definition: GtBoard.cc:1075
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:1027
void fillAlgRecord(int iBxInEvent, std::auto_ptr< GlobalAlgBlkBxCollection > &uGtAlgRecord, cms_uint64_t orbNr, int bxNr)
Fill the Daq Records.
Definition: GtBoard.cc:993
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