CMS 3D CMS Logo

L1GlobalCaloTrigger.cc
Go to the documentation of this file.
2 
5 
14 
16 
17 using std::vector;
18 
19 //DEFINE STATICS
23 
24 // constructor
26  : theJetLeafCards(N_JET_LEAF_CARDS),
27  theJetFinders(N_JET_LEAF_CARDS * 3),
28  theEmLeafCards(N_EM_LEAF_CARDS),
29  theIsoElectronSorters(N_EM_LEAF_CARDS * 2),
30  theNonIsoElectronSorters(N_EM_LEAF_CARDS * 2),
31  theWheelJetFpgas(N_WHEEL_CARDS),
32  theWheelEnergyFpgas(N_WHEEL_CARDS),
33  m_jetFinderParams(nullptr),
34  m_jetEtCalLuts(),
35  m_inputChannelMask(nullptr),
36  m_bxRangeAuto(true),
37  m_bxStart(0),
38  m_numOfBx(1),
39  m_allInputEmCands(),
40  m_allInputRegions() {
41  // construct hardware
42  build(jfType, jetLeafMask);
43 }
44 
47  // Delete the components of the GCT that we made in build()
48  // (But not the LUTs, since these don't belong to us)
49 
50  if (theNonIsoEmFinalStage != nullptr)
51  delete theNonIsoEmFinalStage;
52 
53  if (theIsoEmFinalStage != nullptr)
54  delete theIsoEmFinalStage;
55 
56  if (theEnergyFinalStage != nullptr)
57  delete theEnergyFinalStage;
58 
59  if (theJetFinalStage != nullptr)
60  delete theJetFinalStage;
61 
62  for (unsigned i = 0; i < theWheelEnergyFpgas.size(); ++i) {
63  if (theWheelEnergyFpgas.at(i) != nullptr)
64  delete theWheelEnergyFpgas.at(i);
65  }
66  theWheelEnergyFpgas.clear();
67 
68  for (unsigned i = 0; i < theWheelJetFpgas.size(); ++i) {
69  if (theWheelJetFpgas.at(i) != nullptr)
70  delete theWheelJetFpgas.at(i);
71  }
72  theWheelJetFpgas.clear();
73 
74  for (unsigned i = 0; i < theEmLeafCards.size(); ++i) {
75  if (theEmLeafCards.at(i) != nullptr)
76  delete theEmLeafCards.at(i);
77  }
78  theEmLeafCards.clear();
79 
80  for (unsigned i = 0; i < theJetLeafCards.size(); ++i) {
81  if (theJetLeafCards.at(i) != nullptr)
82  delete theJetLeafCards.at(i);
83  }
84  theJetLeafCards.clear();
85 }
86 
92  // Input data
93  m_allInputEmCands.clear();
94  m_allInputRegions.clear();
95 
96  if (m_bxRangeAuto) {
97  m_bxStart = 0;
98  m_numOfBx = 1;
99  }
100 
101  // EM Leaf Card
102  for (int i = 0; i < N_EM_LEAF_CARDS; i++) {
103  theEmLeafCards.at(i)->reset();
104  }
105 
106  // Jet Leaf cards
107  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
108  theJetLeafCards.at(i)->reset();
109  }
110 
111  // Jet Finders
112  for (int i = 0; i < N_JET_LEAF_CARDS * 3; i++) {
113  theJetFinders.at(i)->reset();
114  }
115 
116  // Wheel Cards
117  for (int i = 0; i < N_WHEEL_CARDS; i++) {
118  theWheelJetFpgas.at(i)->reset();
119  }
120 
121  for (int i = 0; i < N_WHEEL_CARDS; i++) {
122  theWheelEnergyFpgas.at(i)->reset();
123  }
124 
125  // Electron Final Stage
128 
129  // Jet Final Stage
131 
132  // Energy Final Stage
134 }
135 
137  // Shouldn't get here unless the setup has been completed
138  if (setupOk()) {
140  sortInputData();
141  // Extract the earliest and latest bunch crossing
142  // in the input if required, and forward to the processors
143  // to determine the size of the output vectors
144  bxSetup();
145 
146  vector<L1CaloEmCand>::iterator emc = m_allInputEmCands.begin();
147  vector<L1CaloRegion>::iterator rgn = m_allInputRegions.begin();
148  int bx = m_bxStart;
149 
150  // Loop over bunch crossings
151  for (int i = 0; i < m_numOfBx; i++) {
152  // Perform partial reset (reset processing logic but preserve pipeline contents)
153  bxReset(bx);
154  // Fill input data into processors for this bunch crossing
155  fillEmCands(emc, bx);
156  fillRegions(rgn, bx);
157  // Process this bunch crossing
158  bxProcess(bx);
159  bx++;
160  }
161  }
162 }
163 
168 }
169 
172  // Assume input data have been sorted by bunch crossing number
173  if (m_bxRangeAuto) {
174  // Find parameters defining the range of bunch crossings to be processed
175  int16_t firstBxEmCand = (m_allInputEmCands.empty() ? 0 : m_allInputEmCands.front().bx());
176  int16_t firstBxRegion = (m_allInputRegions.empty() ? 0 : m_allInputRegions.front().bx());
177  int16_t lastBxEmCand = (m_allInputEmCands.empty() ? 0 : m_allInputEmCands.back().bx());
178  int16_t lastBxRegion = (m_allInputRegions.empty() ? 0 : m_allInputRegions.back().bx());
179  m_bxStart = std::min(firstBxEmCand, firstBxRegion);
180  m_numOfBx = std::max(lastBxEmCand, lastBxRegion) - m_bxStart + 1;
181  } else {
182  // Remove any input from before the start of the requested range
183  for (vector<L1CaloEmCand>::iterator emc = m_allInputEmCands.begin(); emc != m_allInputEmCands.end(); emc++) {
184  if (emc->bx() >= m_bxStart)
185  break;
186  m_allInputEmCands.erase(emc);
187  }
188 
189  for (vector<L1CaloRegion>::iterator rgn = m_allInputRegions.begin(); rgn != m_allInputRegions.end(); rgn++) {
190  if (rgn->bx() >= m_bxStart)
191  break;
192  m_allInputRegions.erase(rgn);
193  }
194  }
195 
196  // Setup pipeline lengths
197  // EM Leaf Card
198  for (int i = 0; i < N_EM_LEAF_CARDS; i++) {
199  theEmLeafCards.at(i)->setBxRange(m_bxStart, m_numOfBx);
200  }
201 
202  // Jet Leaf cards
203  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
204  theJetLeafCards.at(i)->setBxRange(m_bxStart, m_numOfBx);
205  }
206 
207  // Wheel Cards
208  for (int i = 0; i < N_WHEEL_CARDS; i++) {
209  theWheelJetFpgas.at(i)->setBxRange(m_bxStart, m_numOfBx);
210  }
211 
212  for (int i = 0; i < N_WHEEL_CARDS; i++) {
213  theWheelEnergyFpgas.at(i)->setBxRange(m_bxStart, m_numOfBx);
214  }
215 
216  // Electron Final Stage
219 
220  // Jet Final Stage
222 
223  // Energy Final Stage
225 }
226 
229  // EM Leaf Card
230  for (int i = 0; i < N_EM_LEAF_CARDS; i++) {
231  theEmLeafCards.at(i)->setNextBx(bx);
232  }
233 
234  // Jet Leaf cards
235  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
236  theJetLeafCards.at(i)->setNextBx(bx);
237  }
238 
239  // Wheel Cards
240  for (int i = 0; i < N_WHEEL_CARDS; i++) {
241  theWheelJetFpgas.at(i)->setNextBx(bx);
242  }
243 
244  for (int i = 0; i < N_WHEEL_CARDS; i++) {
245  theWheelEnergyFpgas.at(i)->setNextBx(bx);
246  }
247 
248  // Electron Final Stage
251 
252  // Jet Final Stage
254 
255  // Energy Final Stage
257 }
258 
261  // EM Leaf Card
262  for (int i = 0; i < N_EM_LEAF_CARDS; i++) {
263  theEmLeafCards.at(i)->fetchInput();
264  theEmLeafCards.at(i)->process();
265  }
266 
267  // Jet Leaf cards - first stage processing
268  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
269  theJetLeafCards.at(i)->fetchInput();
270  }
271 
272  // Jet Leaf cards - second stage processing
273  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
274  theJetLeafCards.at(i)->process();
275  }
276 
277  // Wheel Cards
278  for (int i = 0; i < N_WHEEL_CARDS; i++) {
279  theWheelJetFpgas.at(i)->fetchInput();
280  theWheelJetFpgas.at(i)->process();
281  }
282 
283  for (int i = 0; i < N_WHEEL_CARDS; i++) {
284  theWheelEnergyFpgas.at(i)->fetchInput();
285  theWheelEnergyFpgas.at(i)->process();
286  }
287 
288  // Electron Final Stage
291 
294 
295  // Jet Final Stage
298 
299  // Energy Final Stage
302 }
303 
309  // Some parameters not (yet?) implemented
310  if ((jfpars->getCenForJetEtaBoundary() == 7) && (jfpars->getCenJetEtSeedGct() == jfpars->getTauJetEtSeedGct())) {
311  m_jetFinderParams = jfpars;
312  // Need to propagate the new parameters to all the JetFinders
313  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
314  theJetLeafCards.at(i)->getJetFinderA()->setJetFinderParams(jfpars);
315  theJetLeafCards.at(i)->getJetFinderB()->setJetFinderParams(jfpars);
316  theJetLeafCards.at(i)->getJetFinderC()->setJetFinderParams(jfpars);
317  }
318  // Also send to the final energy calculation (for missing Ht)
320  }
321 }
322 
325  m_jetEtCalLuts = jfluts;
326  // Need to propagate the new lut to all the JetFinders
327  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
328  theJetLeafCards.at(i)->getJetFinderA()->setJetEtCalibrationLuts(jfluts);
329  theJetLeafCards.at(i)->getJetFinderB()->setJetEtCalibrationLuts(jfluts);
330  theJetLeafCards.at(i)->getJetFinderC()->setJetEtCalibrationLuts(jfluts);
331  }
332 }
333 
335 void L1GlobalCaloTrigger::setupTauAlgo(const bool useImprovedAlgo, const bool ignoreVetoBitsForIsolation) {
336  // Need to propagate the new parameters to all the JetFinders
337  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
338  theJetLeafCards.at(i)->getJetFinderA()->setupTauAlgo(useImprovedAlgo, ignoreVetoBitsForIsolation);
339  theJetLeafCards.at(i)->getJetFinderB()->setupTauAlgo(useImprovedAlgo, ignoreVetoBitsForIsolation);
340  theJetLeafCards.at(i)->getJetFinderC()->setupTauAlgo(useImprovedAlgo, ignoreVetoBitsForIsolation);
341  }
342 }
343 
346  if (theEnergyFinalStage != nullptr) {
348  }
349 }
350 
353  if (getHfSumProcessor() != nullptr) {
355  }
356 }
357 
361  // Need to propagate the new mask to all the JetFinders
362  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
363  theJetLeafCards.at(i)->getJetFinderA()->setEnergySumMasks(mask);
364  theJetLeafCards.at(i)->getJetFinderB()->setEnergySumMasks(mask);
365  theJetLeafCards.at(i)->getJetFinderC()->setEnergySumMasks(mask);
366  }
367 }
368 
371  bool result = true;
372  result &= (m_inputChannelMask != nullptr);
373  // EM Leaf Card
374  for (int i = 0; i < N_EM_LEAF_CARDS; i++) {
375  result &= theEmLeafCards.at(i)->setupOk();
376  }
377 
378  // Jet Leaf cards
379  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
380  result &= theJetLeafCards.at(i)->setupOk();
381  }
382 
383  // Jet Finders
384  for (int i = 0; i < N_JET_LEAF_CARDS * 3; i++) {
385  result &= theJetFinders.at(i)->setupOk();
386  }
387 
388  // Wheel Cards
389  for (int i = 0; i < N_WHEEL_CARDS; i++) {
390  result &= theWheelJetFpgas.at(i)->setupOk();
391  }
392 
393  for (int i = 0; i < N_WHEEL_CARDS; i++) {
394  result &= theWheelEnergyFpgas.at(i)->setupOk();
395  }
396 
397  // Electron Final Stage
400 
401  // Jet Final Stage
403 
404  // Energy Final Stage
406 
407  // All done.
408  return result;
409 }
410 
413  L1GctGlobalHfSumAlgos* result = nullptr;
414  if (theEnergyFinalStage != nullptr) {
416  }
417  return result;
418 }
419 
422 void L1GlobalCaloTrigger::setBxRange(const int firstBx, const int lastBx) {
423  m_bxStart = firstBx;
424  m_numOfBx = lastBx - firstBx + 1;
425  m_bxRangeAuto = false;
426 }
429  m_bxStart = -numOfBx;
430  m_numOfBx = 2 * numOfBx + 1;
431  m_bxRangeAuto = false;
432 }
435  m_bxStart = 0;
436  m_numOfBx = 1;
437  m_bxRangeAuto = true;
438 }
439 
445 void L1GlobalCaloTrigger::fillRegions(const vector<L1CaloRegion>& rgn) {
446  // To enable multiple bunch crossing operation, we copy the input regions into a vector,
447  // from which they will be extracted one bunch crossing at a time and sent to the processors
448  vector<L1CaloRegion>::iterator itr = m_allInputRegions.end();
449  m_allInputRegions.insert(itr, rgn.begin(), rgn.end());
450 }
451 
453 void L1GlobalCaloTrigger::fillEmCands(const vector<L1CaloEmCand>& em) {
454  // To enable multiple bunch crossing operation, we copy the input electrons into a vector,
455  // from which they will be extracted one bunch crossing at a time and sent to the processors
456  vector<L1CaloEmCand>::iterator itr = m_allInputEmCands.end();
457  m_allInputEmCands.insert(itr, em.begin(), em.end());
458 }
459 
461 void L1GlobalCaloTrigger::fillRegions(vector<L1CaloRegion>::iterator& rgn, const int bx) {
462  while (rgn != m_allInputRegions.end() && rgn->bx() == bx) {
463  setRegion(*rgn++);
464  }
465 }
466 
468 void L1GlobalCaloTrigger::fillEmCands(vector<L1CaloEmCand>::iterator& emc, const int bx) {
469  while (emc != m_allInputEmCands.end() && emc->bx() == bx) {
470  if (emc->isolated()) {
471  setIsoEm(*emc);
472  } else {
473  setNonIsoEm(*emc);
474  }
475  emc++;
476  }
477 }
478 
483  if (!m_inputChannelMask->regionMask(region.gctEta(), region.gctPhi())) {
484  unsigned crate = region.rctCrate();
485  // Find the relevant jetFinders
486  static const unsigned NPHI = L1CaloRegionDetId::N_PHI / 2;
487  unsigned prevphi = crate % NPHI;
488  unsigned thisphi = (crate + 1) % NPHI;
489  unsigned nextphi = (crate + 2) % NPHI;
490 
491  // Send the region to six jetFinders.
492  theJetFinders.at(thisphi)->setInputRegion(region);
493  theJetFinders.at(nextphi)->setInputRegion(region);
494  theJetFinders.at(prevphi)->setInputRegion(region);
495  theJetFinders.at(thisphi + NPHI)->setInputRegion(region);
496  theJetFinders.at(nextphi + NPHI)->setInputRegion(region);
497  theJetFinders.at(prevphi + NPHI)->setInputRegion(region);
498  }
499 }
500 
504  const unsigned et, const unsigned ieta, const unsigned iphi, const bool overFlow, const bool fineGrain) {
505  // L1CaloRegion temp = L1CaloRegion::makeRegionFromGctIndices(et, overFlow, fineGrain, false, false, ieta, iphi, 0);
506  L1CaloRegion temp(et, overFlow, fineGrain, false, false, ieta, iphi, 0);
507  setRegion(temp);
508 }
509 
515  theIsoElectronSorters.at(sorterNo(em))->setInputEmCand(em);
516 }
517 
523  theNonIsoElectronSorters.at(sorterNo(em))->setInputEmCand(em);
524 }
525 
530  using edm::LogInfo;
531  using std::endl;
532 
533  LogInfo("L1GlobalCaloTrigger") << "=== Global Calo Trigger ===" << endl;
534  LogInfo("L1GlobalCaloTrigger") << "=== START DEBUG OUTPUT ===" << endl;
535 
536  LogInfo("L1GlobalCaloTrigger") << endl;
537  LogInfo("L1GlobalCaloTrigger") << "N Jet Leaf Cards " << theJetLeafCards.size() << endl;
538  LogInfo("L1GlobalCaloTrigger") << "N Wheel Jet Fpgas " << theWheelJetFpgas.size() << endl;
539  LogInfo("L1GlobalCaloTrigger") << "N Wheel Energy Fpgas " << theWheelEnergyFpgas.size() << endl;
540  LogInfo("L1GlobalCaloTrigger") << "N Em Leaf Cards " << theEmLeafCards.size() << endl;
541  LogInfo("L1GlobalCaloTrigger") << endl;
542 
543  for (unsigned i = 0; i < theJetLeafCards.size(); i++) {
544  LogInfo("L1GlobalCaloTrigger") << "Jet Leaf Card " << i << " : " << theJetLeafCards.at(i) << endl;
545  LogInfo("L1GlobalCaloTrigger") << (*theJetLeafCards.at(i));
546  }
547  LogInfo("L1GlobalCaloTrigger") << endl;
548 
549  for (unsigned i = 0; i < theWheelJetFpgas.size(); i++) {
550  LogInfo("L1GlobalCaloTrigger") << "Wheel Jet FPGA " << i << " : " << theWheelJetFpgas.at(i) << endl;
551  LogInfo("L1GlobalCaloTrigger") << (*theWheelJetFpgas.at(i));
552  }
553  LogInfo("L1GlobalCaloTrigger") << endl;
554 
555  for (unsigned i = 0; i < theWheelEnergyFpgas.size(); i++) {
556  LogInfo("L1GlobalCaloTrigger") << "Wheel Energy FPGA " << i << " : " << theWheelEnergyFpgas.at(i) << endl;
557  LogInfo("L1GlobalCaloTrigger") << (*theWheelEnergyFpgas.at(i));
558  }
559  LogInfo("L1GlobalCaloTrigger") << endl;
560 
561  LogInfo("L1GlobalCaloTrigger") << (*theJetFinalStage);
562  LogInfo("L1GlobalCaloTrigger") << endl;
563 
564  LogInfo("L1GlobalCaloTrigger") << (*theEnergyFinalStage);
565  LogInfo("L1GlobalCaloTrigger") << endl;
566 
567  for (unsigned i = 0; i < theEmLeafCards.size(); i++) {
568  LogInfo("L1GlobalCaloTrigger") << ((i == 0) ? "Positive eta " : "Negative eta ");
569  LogInfo("L1GlobalCaloTrigger") << "EM Leaf Card " << i << " : " << theEmLeafCards.at(i) << endl;
570  LogInfo("L1GlobalCaloTrigger") << (*theEmLeafCards.at(i));
571  }
572  LogInfo("L1GlobalCaloTrigger") << endl;
573 
574  LogInfo("L1GlobalCaloTrigger") << (*theIsoEmFinalStage);
575  LogInfo("L1GlobalCaloTrigger") << endl;
576 
577  LogInfo("L1GlobalCaloTrigger") << (*theNonIsoEmFinalStage);
578 
579  LogInfo("L1GlobalCaloTrigger") << "=== Global Calo Trigger ===" << endl;
580  LogInfo("L1GlobalCaloTrigger") << "=== END DEBUG OUTPUT ===" << endl;
581 }
582 
586 // isolated EM outputs
588 
589 // non isolated EM outputs
592 }
593 
594 // central jet outputs to GT
596 
597 // forward jet outputs to GT
599 
600 // tau jet outputs to GT
602 
606 
607  // Loop over jetfinders, find the internal jets and add them to the list
608  for (unsigned jf = 0; jf < theJetFinders.size(); jf++) {
609  jfJets = theJetFinders.at(jf)->getInternalJets();
610  allJets.insert(allJets.end(), jfJets.begin(), jfJets.end());
611  }
612 
613  return allJets;
614 }
615 
616 // total Et output
619  int bx = m_bxStart;
620  for (int i = 0; i < m_numOfBx; i++) {
622  theEnergyFinalStage->getEtSumColl().at(i).value(), theEnergyFinalStage->getEtSumColl().at(i).overFlow(), bx++);
623  result.at(i) = temp;
624  }
625  return result;
626 }
627 
630  int bx = m_bxStart;
631  for (int i = 0; i < m_numOfBx; i++) {
633  theEnergyFinalStage->getEtHadColl().at(i).value(), theEnergyFinalStage->getEtHadColl().at(i).overFlow(), bx++);
634  result.at(i) = temp;
635  }
636  return result;
637 }
638 
641  int bx = m_bxStart;
642  for (int i = 0; i < m_numOfBx; i++) {
644  theEnergyFinalStage->getEtMissPhiColl().at(i).value(),
645  theEnergyFinalStage->getEtMissColl().at(i).overFlow(),
646  bx++);
647  result.at(i) = temp;
648  }
649  return result;
650 }
651 
654  int bx = m_bxStart;
655  for (int i = 0; i < m_numOfBx; i++) {
657  theEnergyFinalStage->getHtMissPhiColl().at(i).value(),
658  theEnergyFinalStage->getHtMissColl().at(i).overFlow(),
659  bx++);
660  result.at(i) = temp;
661  }
662  return result;
663 }
664 
666  L1GctInternEtSumCollection allSums, procSums;
667 
668  // Go through all the processor types that process et sums
669  // JetFinders
670  for (unsigned jf = 0; jf < theJetFinders.size(); jf++) {
671  procSums = theJetFinders.at(jf)->getInternalEtSums();
672  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
673  }
674 
675  // Jet Leaf cards
676  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
677  procSums = theJetLeafCards.at(i)->getInternalEtSums();
678  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
679  }
680 
681  // Wheel Cards
682  for (int i = 0; i < N_WHEEL_CARDS; i++) {
683  procSums = theWheelEnergyFpgas.at(i)->getInternalEtSums();
684  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
685  }
686 
687  return allSums;
688 }
689 
691  L1GctInternHtMissCollection allSums, procSums;
692 
693  // Go through all the processor types that process et sums
694  // JetFinders
695  for (unsigned jf = 0; jf < theJetFinders.size(); jf++) {
696  procSums = theJetFinders.at(jf)->getInternalHtMiss();
697  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
698  }
699 
700  // Jet Leaf cards
701  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
702  procSums = theJetLeafCards.at(i)->getInternalHtMiss();
703  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
704  }
705 
706  // Wheel Cards
707  for (int i = 0; i < N_WHEEL_CARDS; i++) {
708  procSums = theWheelJetFpgas.at(i)->getInternalHtMiss();
709  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
710  }
711 
712  return allSums;
713 }
714 
717  if (getHfSumProcessor() != nullptr) {
718  int bx = m_bxStart;
719  for (int i = 0; i < m_numOfBx; i++) {
721  static_cast<int16_t>(bx),
726  result.at(i) = temp;
727  bx++;
728  }
729  }
730  return result;
731 }
732 
735  if (getHfSumProcessor() != nullptr) {
736  int bx = m_bxStart;
737  for (int i = 0; i < m_numOfBx; i++) {
739  static_cast<int16_t>(bx),
744  result.at(i) = temp;
745  bx++;
746  }
747  }
748  return result;
749 }
750 
753  // EM Leaf Card
754  for (int i = 0; i < N_EM_LEAF_CARDS; i++) {
755  theEmLeafCards.at(i)->setVerbose();
756  }
757 
758  // Jet Leaf cards
759  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
760  theJetLeafCards.at(i)->setVerbose();
761  }
762 
763  // Jet Finders
764  for (int i = 0; i < N_JET_LEAF_CARDS * 3; i++) {
765  theJetFinders.at(i)->setVerbose();
766  }
767 
768  // Wheel Cards
769  for (int i = 0; i < N_WHEEL_CARDS; i++) {
770  theWheelJetFpgas.at(i)->setVerbose();
771  }
772 
773  for (int i = 0; i < N_WHEEL_CARDS; i++) {
774  theWheelEnergyFpgas.at(i)->setVerbose();
775  }
776 
777  // Electron Final Stage
780 
781  // Jet Final Stage
783 
784  // Energy Final Stage
786 }
787 
789  // EM Leaf Card
790  for (int i = 0; i < N_EM_LEAF_CARDS; i++) {
791  theEmLeafCards.at(i)->setTerse();
792  }
793 
794  // Jet Leaf cards
795  for (int i = 0; i < N_JET_LEAF_CARDS; i++) {
796  theJetLeafCards.at(i)->setTerse();
797  }
798 
799  // Jet Finders
800  for (int i = 0; i < N_JET_LEAF_CARDS * 3; i++) {
801  theJetFinders.at(i)->setTerse();
802  }
803 
804  // Wheel Cards
805  for (int i = 0; i < N_WHEEL_CARDS; i++) {
806  theWheelJetFpgas.at(i)->setTerse();
807  }
808 
809  for (int i = 0; i < N_WHEEL_CARDS; i++) {
810  theWheelEnergyFpgas.at(i)->setTerse();
811  }
812 
813  // Electron Final Stage
816 
817  // Jet Final Stage
819 
820  // Energy Final Stage
822 }
823 
824 /* PRIVATE METHODS */
825 
826 // instantiate hardware/algorithms
828  // The first half of the jet leaf cards are at negative eta,
829  // followed by positive eta
830  // Jet Leaf cards
831  if (jetLeafMask == 0) {
832  for (int jlc = 0; jlc < N_JET_LEAF_CARDS; jlc++) {
833  theJetLeafCards.at(jlc) = new L1GctJetLeafCard(jlc, jlc % 3, jfType);
834  theJetFinders.at(3 * jlc) = theJetLeafCards.at(jlc)->getJetFinderA();
835  theJetFinders.at(3 * jlc + 1) = theJetLeafCards.at(jlc)->getJetFinderB();
836  theJetFinders.at(3 * jlc + 2) = theJetLeafCards.at(jlc)->getJetFinderC();
837  }
838  } else {
839  // Setup for hardware testing with reduced number of leaf cards
840  unsigned mask = jetLeafMask;
841  for (int jlc = 0; jlc < N_JET_LEAF_CARDS; jlc++) {
842  if ((mask & 1) == 0) {
843  theJetLeafCards.at(jlc) = new L1GctJetLeafCard(jlc, jlc % 3, jfType);
844  } else {
846  }
847  theJetFinders.at(3 * jlc) = theJetLeafCards.at(jlc)->getJetFinderA();
848  theJetFinders.at(3 * jlc + 1) = theJetLeafCards.at(jlc)->getJetFinderB();
849  theJetFinders.at(3 * jlc + 2) = theJetLeafCards.at(jlc)->getJetFinderC();
850  mask = mask >> 1;
851  }
852  }
853 
854  //Link jet leaf cards together
855  vector<L1GctJetLeafCard*> neighbours(2);
856  for (int jlc = 0; jlc < N_JET_LEAF_CARDS / 2; jlc++) {
857  // Define local constant for ease of typing
858  static const int NL = N_JET_LEAF_CARDS / 2;
859  int nlc = (jlc + 1) % NL;
860  int mlc = (jlc + (NL - 1)) % NL;
861  neighbours.at(0) = theJetLeafCards.at(mlc);
862  neighbours.at(1) = theJetLeafCards.at(nlc);
863  theJetLeafCards.at(jlc)->setNeighbourLeafCards(neighbours);
864  neighbours.at(0) = theJetLeafCards.at(NL + mlc);
865  neighbours.at(1) = theJetLeafCards.at(NL + nlc);
866  theJetLeafCards.at(NL + jlc)->setNeighbourLeafCards(neighbours);
867  }
868 
869  // EM leaf cards
870  // Card 0 is positive eta, card 1 is negative eta
871  for (int i = 0; i < N_EM_LEAF_CARDS; i++) {
872  theEmLeafCards.at(i) = new L1GctEmLeafCard(i);
873  theIsoElectronSorters.at(2 * i) = theEmLeafCards.at(i)->getIsoElectronSorterU1();
874  theIsoElectronSorters.at(2 * i + 1) = theEmLeafCards.at(i)->getIsoElectronSorterU2();
875  theNonIsoElectronSorters.at(2 * i) = theEmLeafCards.at(i)->getNonIsoElectronSorterU1();
876  theNonIsoElectronSorters.at(2 * i + 1) = theEmLeafCards.at(i)->getNonIsoElectronSorterU2();
877  }
878 
879  // Wheel Fpgas
880  vector<L1GctJetLeafCard*> wheelJetLeafCards(3);
881  vector<L1GctJetLeafCard*> wheelEnergyLeafCards(3);
882 
883  // The first wheel card is at negative eta,
884  // the second one is at positive eta
885  for (int i = 0; i < N_WHEEL_CARDS; i++) {
886  for (int j = 0; j < 3; j++) {
887  wheelJetLeafCards.at(j) = theJetLeafCards.at(i * 3 + j);
888  wheelEnergyLeafCards.at(j) = theJetLeafCards.at(i * 3 + j);
889  }
890  theWheelJetFpgas.at(i) = new L1GctWheelJetFpga(i, wheelJetLeafCards);
891  theWheelEnergyFpgas.at(i) = new L1GctWheelEnergyFpga(i, wheelEnergyLeafCards);
892  }
893 
894  // Jet Final Stage
896 
897  // Electron Final Sort
900 
901  // Global Energy Algos
903 }
904 
912 unsigned L1GlobalCaloTrigger::sorterNo(const L1CaloEmCand& em) const {
913  unsigned crate = em.rctCrate();
914  unsigned result = (((crate % 9) < 4) ? 1 : 0);
915  if (crate >= 9)
916  result += 2;
917  if (crate >= 18)
918  result = 0;
919  return result;
920 }
static L1GctHFRingEtSums fromGctEmulator(const int16_t bx, const uint16_t etSumPosEtaRing1, const uint16_t etSumNegEtaRing1, const uint16_t etSumPosEtaRing2, const uint16_t etSumNegEtaRing2)
named ctor for GCT emulator
Emulates the energy summing on a GCT Wheel card.
std::vector< reco::JetBaseRef > allJets(const Container &)
fill list of all jets associated with values. Return # of jets in the list
void reset()
complete reset of processor
L1GctJetFinderBase::lutPtrVector lutPtrVector
std::vector< etMissType > getEtMissColl() const
void process() override
process the data, fill output buffers
void bxReset(const int bx)
Partial reset for a new bunch crossing.
L1GctJetCandCollection getForwardJets() const
forward jet outputs to GT
void fillEmCands(const std::vector< L1CaloEmCand > &rgn)
set electrons from the RCT at the input to be processed
L1GctInternHtMissCollection getInternalHtMiss() const
L1GctEtMissCollection getEtMissCollection() const
Etmiss output to GT.
std::vector< L1GctJetLeafCard * > theJetLeafCards
pointers to the Jet Leaf cards
void reset()
clear internal buffers
void setupTauAlgo(const bool useImprovedAlgo, const bool ignoreVetoBitsForIsolation)
setup the tau algorithm parameters
void fetchInput() override
get input data from sources
void sortInputData()
Sort the input data by bunch crossing number.
L1GctGlobalHfSumAlgos * getHfSumProcessor() const
provide access to hf sum processor
std::vector< L1GctEtMiss > L1GctEtMissCollection
Represents a GCT Wheel Jet FPGA.
std::vector< L1CaloEmCand > m_allInputEmCands
static const int N_WHEEL_CARDS
Number of Wheel Cards.
Emulates the GCT summing and packing of Hf Et sums and tower-over-threshold counts.
std::vector< L1GctHFRingEtSums > L1GctHFRingEtSumsCollection
std::vector< L1GctWheelEnergyFpga * > theWheelEnergyFpgas
Wheel Card Energy Fpgas.
void fetchInput() override
get input data from sources
void setJetFinderParams(const L1GctJetFinderParams *const jfpars)
unsigned sorterNo(const L1CaloEmCand &em) const
L1GctGlobalEnergyAlgos * theEnergyFinalStage
energy final stage algos
std::vector< L1GctEtHad > L1GctEtHadCollection
const L1GctChannelMask * m_inputChannelMask
Input channel mask.
void setIsoEm(const L1CaloEmCand &em)
set an isolated EM candidate to be processed
std::vector< L1GctInternHtMiss > L1GctInternHtMissCollection
void process() override
process the data, fill output buffers
L1GctHFRingEtSumsCollection getHFRingEtSumsCollection() const
bool m_bxRangeAuto
Multiple bunch crossing operation.
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:17
JetVector getTauJets() const
get the tau jets output data
L1GctHFBitCountsCollection getHFBitCountsCollection() const
JetVector getCentralJets() const
get the central jets output data
Persistable copy of missing Et measured at Level-1.
Definition: L1GctEtMiss.h:17
void setJetFinderParams(const L1GctJetFinderParams *const jfpars)
~L1GlobalCaloTrigger()
dismantle the GCT
L1GctElectronFinalSort * theNonIsoEmFinalStage
non-iso electron final stage sorter
lutPtrVector m_jetEtCalLuts
Jet Et calibration LUT.
std::vector< etMissType > getHtMissColl() const
return output missing Ht magnitude
bool emCrateMask(unsigned crate) const
get EM masks for an RCT crate
constexpr uint32_t mask
Definition: gpuClustering.h:26
std::vector< L1GctJetFinderBase * > theJetFinders
pointers to the Jet Finders
std::vector< L1GctWheelJetFpga * > theWheelJetFpgas
Wheel Card Jet Fpgas.
std::vector< L1GctEtTotal > L1GctEtTotalCollection
void setHtMissScale(const L1CaloEtScale *const scale)
JetVector getForwardJets() const
get the forward jets output data
std::vector< L1GctHFBitCounts > L1GctHFBitCountsCollection
std::vector< L1GctJetCand > L1GctJetCandCollection
Represents the final stage of L1 jet processing.
CompareBx< L1CaloRegion > rgnBxComparator
L1GctJetCandCollection getTauJets() const
tau jet outputs to GT
void setVerbose()
control output messages
L1GctEmCandCollection getNonIsoElectrons() const
non-iso electron outputs to GT
L1GctElectronFinalSort * theIsoEmFinalStage
iso electron final stage sorter
void setHtMissScale(const L1CaloEtScale *const scale)
setup scale for missing Ht
L1 GCT HF ring Et sums.
unsigned getCenForJetEtaBoundary() const
std::vector< etHadType > getEtHadColl() const
return std::vector< output calibrated jet Et
unsigned rctCrate() const
get RCT crate
Definition: L1CaloEmCand.h:51
void fetchInput() override
get input data from sources
Persistable copy of total Et measured at Level-1.
Definition: L1GctEtTotal.h:17
static const int N_JET_LEAF_CARDS
Number of Leaf Cards configured for jet processing.
void fillRegions(const std::vector< L1CaloRegion > &rgn)
L1GctGlobalHfSumAlgos * getHfSumProcessor() const
provide access to hf sum processor
std::vector< L1GctElectronSorter * > theIsoElectronSorters
pointers to the electron sorters
std::vector< etMissPhiType > getHtMissPhiColl() const
return output missing Ht value
Emulates the GCT global energy algorithms.
bool regionMask(unsigned ieta, unsigned iphi) const
get region masks
void process() override
process the data, fill output buffers
void setupHfSumLuts(const L1CaloEtScale *const scale)
setup Hf sum LUTs
void setBxRange(const int firstBx, const int lastBx)
L1GctInternJetDataCollection getInternalJets() const
all jets from jetfinders in raw format
void setNonIsoEm(const L1CaloEmCand &em)
set a non-isolated EM candidate to be processed
void bxProcess(const int bx)
Process a new bunch crossing.
void setBxRange(const int firstBx, const int numberOfBx)
define the bunch crossing range to process
CompareBx< L1CaloEmCand > emcBxComparator
void setBxRange(const int firstBx, const int numberOfBx)
define the bunch crossing range to process
L1GctInternEtSumCollection getInternalEtSums() const
Et sums and components in internal format.
Persistable copy of total Ht measured at Level-1.
Definition: L1GctEtHad.h:17
L1GctJetCandCollection getCentralJets() const
central jet outputs to GT
void reset()
Reset internal buffers.
L1 GCT HF ring Et sums.
void setChannelMask(const L1GctChannelMask *const mask)
setup the input channel mask
void bxSetup()
Setup bunch crossing range (depending on input data)
Log< level::Info, false > LogInfo
std::vector< L1GctHtMiss > L1GctHtMissCollection
void setJetEtCalibrationLuts(const lutPtrVector &jfluts)
setup the Jet Calibration Luts
void setBxRangeAutomatic()
process all crossings present in the input (and only those crossings)
L1GctEtHadCollection getEtHadCollection() const
Total hadronic Et output to GT.
Persistable copy of missing Et measured at Level-1.
Definition: L1GctHtMiss.h:16
L1GlobalCaloTrigger(const L1GctJetLeafCard::jetFinderType jfType=L1GctJetLeafCard::hardwareJetFinder, unsigned jetLeafMask=0)
construct the GCT
L1GctEmCandCollection getIsoElectrons() const
static const int N_EM_LEAF_CARDS
Number of Leaf Cards configured for EM processing.
std::vector< L1GctInternJetData > L1GctInternJetDataCollection
std::vector< etTotalType > getEtSumColl() const
return output total scalar Et
bool setupOk() const
check setup
L1GctEtTotalCollection getEtSumCollection() const
Total Et output to GT.
std::vector< L1GctElectronSorter * > theNonIsoElectronSorters
std::vector< L1CaloRegion > m_allInputRegions
std::vector< L1GctEmCand > getOutputCands() const
return output data
void build(L1GctJetLeafCard::jetFinderType jfType, unsigned jetLeafMask)
instantiate the hardware & algo objects and wire up the system
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:21
void setRegion(const L1CaloRegion &region)
std::vector< L1GctInternEtSum > L1GctInternEtSumCollection
void setBxRangeSymmetric(const int numOfBx)
process crossings from (-numOfBx) to (numOfBx)
static const unsigned N_PHI
void setupLuts(const L1CaloEtScale *scale)
Setup luts.
bool setupOk() const
check we have done all the setup
void setNextBx(const int bx)
partially clear buffers
void setNextBx(const int bxnum)
clear input data buffers and process a new bunch crossing
unsigned getCenJetEtSeedGct() const
L1GctJetFinalStage * theJetFinalStage
jet final stage algo
static L1GctHFBitCounts fromGctEmulator(const int16_t bx, const uint16_t bitCountPosEtaRing1, const uint16_t bitCountNegEtaRing1, const uint16_t bitCountPosEtaRing2, const uint16_t bitCountNegEtaRing2)
named ctor for GCT emulator
std::vector< L1GctEmLeafCard * > theEmLeafCards
pointers to the EM Leaf cards
void process()
process an event
unsigned getTauJetEtSeedGct() const
const L1GctJetFinderParams * m_jetFinderParams
Jetfinder parameters.
bool setupOk() const
check setup
Emulates a leaf card programmed for electron sorting.
void setVerbose()
control output messages
L1GctHtMissCollection getHtMissCollection() const
Htmiss output to GT.
std::vector< L1GctEmCand > L1GctEmCandCollection
std::vector< etMissPhiType > getEtMissPhiColl() const
return output missing Et value