CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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(0),
34  m_jetEtCalLuts(),
35  m_inputChannelMask(0),
36  m_bxRangeAuto(true),
37  m_bxStart(0), m_numOfBx(1),
38  m_allInputEmCands(), m_allInputRegions()
39 {
40 
41  // construct hardware
42  build(jfType, jetLeafMask);
43 }
44 
47 {
48  // Delete the components of the GCT that we made in build()
49  // (But not the LUTs, since these don't belong to us)
50 
52 
53  if (theIsoEmFinalStage != 0) delete theIsoEmFinalStage;
54 
55  if (theEnergyFinalStage != 0) delete theEnergyFinalStage;
56 
57  if (theJetFinalStage != 0) delete theJetFinalStage;
58 
59  for (unsigned i=0; i<theWheelEnergyFpgas.size(); ++i) {
60  if (theWheelEnergyFpgas.at(i) != 0) delete theWheelEnergyFpgas.at(i); }
61  theWheelEnergyFpgas.clear();
62 
63  for (unsigned i=0; i<theWheelJetFpgas.size(); ++i) {
64  if (theWheelJetFpgas.at(i) != 0) delete theWheelJetFpgas.at(i); }
65  theWheelJetFpgas.clear();
66 
67  for (unsigned i=0; i<theEmLeafCards.size(); ++i) {
68  if (theEmLeafCards.at(i) != 0) delete theEmLeafCards.at(i); }
69  theEmLeafCards.clear();
70 
71  for (unsigned i=0; i<theJetLeafCards.size(); ++i) {
72  if (theJetLeafCards.at(i) != 0) delete theJetLeafCards.at(i); }
73  theJetLeafCards.clear();
74 
75 }
76 
82 
83  // Input data
84  m_allInputEmCands.clear();
85  m_allInputRegions.clear();
86 
87  if (m_bxRangeAuto) {
88  m_bxStart = 0;
89  m_numOfBx = 1;
90  }
91 
92  // EM Leaf Card
93  for (int i=0; i<N_EM_LEAF_CARDS; i++) {
94  theEmLeafCards.at(i)->reset();
95  }
96 
97  // Jet Leaf cards
98  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
99  theJetLeafCards.at(i)->reset();
100  }
101 
102  // Jet Finders
103  for (int i=0; i<N_JET_LEAF_CARDS*3; i++) {
104  theJetFinders.at(i)->reset();
105  }
106 
107  // Wheel Cards
108  for (int i=0; i<N_WHEEL_CARDS; i++) {
109  theWheelJetFpgas.at(i)->reset();
110  }
111 
112  for (int i=0; i<N_WHEEL_CARDS; i++) {
113  theWheelEnergyFpgas.at(i)->reset();
114  }
115 
116  // Electron Final Stage
119 
120  // Jet Final Stage
122 
123  // Energy Final Stage
125 
126 }
127 
129 
130  // Shouldn't get here unless the setup has been completed
131  if (setupOk()) {
132 
134  sortInputData();
135  // Extract the earliest and latest bunch crossing
136  // in the input if required, and forward to the processors
137  // to determine the size of the output vectors
138  bxSetup();
139 
140  vector<L1CaloEmCand>::iterator emc=m_allInputEmCands.begin();
141  vector<L1CaloRegion>::iterator rgn=m_allInputRegions.begin();
142  int bx = m_bxStart;
143 
144  // Loop over bunch crossings
145  for (int i=0; i<m_numOfBx; i++) {
146  // Perform partial reset (reset processing logic but preserve pipeline contents)
147  bxReset(bx);
148  // Fill input data into processors for this bunch crossing
149  fillEmCands(emc, bx);
150  fillRegions(rgn, bx);
151  // Process this bunch crossing
152  bxProcess(bx);
153  bx++;
154  }
155  }
156 }
157 
160  std::sort(m_allInputEmCands.begin(), m_allInputEmCands.end(), emcBxComparator);
161  std::sort(m_allInputRegions.begin(), m_allInputRegions.end(), rgnBxComparator);
162 }
163 
166  // Assume input data have been sorted by bunch crossing number
167  if (m_bxRangeAuto) {
168  // Find parameters defining the range of bunch crossings to be processed
169  int16_t firstBxEmCand = (m_allInputEmCands.size()==0 ? 0 : m_allInputEmCands.front().bx() );
170  int16_t firstBxRegion = (m_allInputRegions.size()==0 ? 0 : m_allInputRegions.front().bx() );
171  int16_t lastBxEmCand = (m_allInputEmCands.size()==0 ? 0 : m_allInputEmCands.back().bx() );
172  int16_t lastBxRegion = (m_allInputRegions.size()==0 ? 0 : m_allInputRegions.back().bx() );
173  m_bxStart = std::min(firstBxEmCand, firstBxRegion);
174  m_numOfBx = std::max( lastBxEmCand, lastBxRegion) - m_bxStart + 1;
175  } else {
176  // Remove any input from before the start of the requested range
177  for (vector<L1CaloEmCand>::iterator emc=m_allInputEmCands.begin(); emc != m_allInputEmCands.end(); emc++) {
178  if (emc->bx() >= m_bxStart) break;
179  m_allInputEmCands.erase(emc);
180  }
181 
182  for (vector<L1CaloRegion>::iterator rgn=m_allInputRegions.begin(); rgn != m_allInputRegions.end(); rgn++) {
183  if (rgn->bx() >= m_bxStart) break;
184  m_allInputRegions.erase(rgn);
185  }
186  }
187 
188  // Setup pipeline lengths
189  // EM Leaf Card
190  for (int i=0; i<N_EM_LEAF_CARDS; i++) {
191  theEmLeafCards.at(i)->setBxRange(m_bxStart, m_numOfBx);
192  }
193 
194  // Jet Leaf cards
195  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
196  theJetLeafCards.at(i)->setBxRange(m_bxStart, m_numOfBx);
197  }
198 
199  // Wheel Cards
200  for (int i=0; i<N_WHEEL_CARDS; i++) {
201  theWheelJetFpgas.at(i)->setBxRange(m_bxStart, m_numOfBx);
202  }
203 
204  for (int i=0; i<N_WHEEL_CARDS; i++) {
205  theWheelEnergyFpgas.at(i)->setBxRange(m_bxStart, m_numOfBx);
206  }
207 
208  // Electron Final Stage
211 
212  // Jet Final Stage
214 
215  // Energy Final Stage
217 }
218 
220 void L1GlobalCaloTrigger::bxReset(const int bx) {
221  // EM Leaf Card
222  for (int i=0; i<N_EM_LEAF_CARDS; i++) {
223  theEmLeafCards.at(i)->setNextBx(bx);
224  }
225 
226  // Jet Leaf cards
227  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
228  theJetLeafCards.at(i)->setNextBx(bx);
229  }
230 
231  // Wheel Cards
232  for (int i=0; i<N_WHEEL_CARDS; i++) {
233  theWheelJetFpgas.at(i)->setNextBx(bx);
234  }
235 
236  for (int i=0; i<N_WHEEL_CARDS; i++) {
237  theWheelEnergyFpgas.at(i)->setNextBx(bx);
238  }
239 
240  // Electron Final Stage
243 
244  // Jet Final Stage
246 
247  // Energy Final Stage
249 
250 }
251 
253 void L1GlobalCaloTrigger::bxProcess(const int bx) {
254 
255  // EM Leaf Card
256  for (int i=0; i<N_EM_LEAF_CARDS; i++) {
257  theEmLeafCards.at(i)->fetchInput();
258  theEmLeafCards.at(i)->process();
259  }
260 
261  // Jet Leaf cards - first stage processing
262  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
263  theJetLeafCards.at(i)->fetchInput();
264  }
265 
266  // Jet Leaf cards - second stage processing
267  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
268  theJetLeafCards.at(i)->process();
269  }
270 
271  // Wheel Cards
272  for (int i=0; i<N_WHEEL_CARDS; i++) {
273  theWheelJetFpgas.at(i)->fetchInput();
274  theWheelJetFpgas.at(i)->process();
275  }
276 
277  for (int i=0; i<N_WHEEL_CARDS; i++) {
278  theWheelEnergyFpgas.at(i)->fetchInput();
279  theWheelEnergyFpgas.at(i)->process();
280  }
281 
282  // Electron Final Stage
285 
288 
289 
290  // Jet Final Stage
293 
294  // Energy Final Stage
297 
298 }
299 
305 
306  // Some parameters not (yet?) implemented
307  if ((jfpars->getCenForJetEtaBoundary()==7) &&
308  (jfpars->getCenJetEtSeedGct()==jfpars->getTauJetEtSeedGct())) {
309 
310  m_jetFinderParams = jfpars;
311  // Need to propagate the new parameters to all the JetFinders
312  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
313  theJetLeafCards.at(i)->getJetFinderA()->setJetFinderParams(jfpars);
314  theJetLeafCards.at(i)->getJetFinderB()->setJetFinderParams(jfpars);
315  theJetLeafCards.at(i)->getJetFinderC()->setJetFinderParams(jfpars);
316  }
317  // Also send to the final energy calculation (for missing Ht)
319  }
320 }
321 
324 
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 {
337  // Need to propagate the new parameters to all the JetFinders
338  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
339  theJetLeafCards.at(i)->getJetFinderA()->setupTauAlgo(useImprovedAlgo, ignoreVetoBitsForIsolation);
340  theJetLeafCards.at(i)->getJetFinderB()->setupTauAlgo(useImprovedAlgo, ignoreVetoBitsForIsolation);
341  theJetLeafCards.at(i)->getJetFinderC()->setupTauAlgo(useImprovedAlgo, ignoreVetoBitsForIsolation);
342  }
343 }
344 
347  if (theEnergyFinalStage != 0) {
349  }
350 }
351 
354  if (getHfSumProcessor() != 0) {
355  getHfSumProcessor()->setupLuts(scale);
356  }
357 }
358 
361  m_inputChannelMask = mask;
362  // Need to propagate the new mask to all the JetFinders
363  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
364  theJetLeafCards.at(i)->getJetFinderA()->setEnergySumMasks(mask);
365  theJetLeafCards.at(i)->getJetFinderB()->setEnergySumMasks(mask);
366  theJetLeafCards.at(i)->getJetFinderC()->setEnergySumMasks(mask);
367  }
368 }
369 
372  bool result = true;
373  result &= (m_inputChannelMask != 0);
374  // EM Leaf Card
375  for (int i=0; i<N_EM_LEAF_CARDS; i++) {
376  result &= theEmLeafCards.at(i)->setupOk();
377  }
378 
379  // Jet Leaf cards
380  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
381  result &= theJetLeafCards.at(i)->setupOk();
382  }
383 
384  // Jet Finders
385  for (int i=0; i<N_JET_LEAF_CARDS*3; i++) {
386  result &= theJetFinders.at(i)->setupOk();
387  }
388 
389  // Wheel Cards
390  for (int i=0; i<N_WHEEL_CARDS; i++) {
391  result &= theWheelJetFpgas.at(i)->setupOk();
392  }
393 
394  for (int i=0; i<N_WHEEL_CARDS; i++) {
395  result &= theWheelEnergyFpgas.at(i)->setupOk();
396  }
397 
398  // Electron Final Stage
399  result &= theIsoEmFinalStage->setupOk();
400  result &= theNonIsoEmFinalStage->setupOk();
401 
402  // Jet Final Stage
403  result &= theJetFinalStage->setupOk();
404 
405  // Energy Final Stage
406  result &= theEnergyFinalStage->setupOk();
407 
408  // All done.
409  return result;
410 }
411 
414 {
416  if (theEnergyFinalStage !=0) {
418  }
419  return result;
420 }
421 
424 void L1GlobalCaloTrigger::setBxRange(const int firstBx, const int lastBx) { m_bxStart = firstBx; m_numOfBx = lastBx - firstBx + 1; m_bxRangeAuto = false; }
426 void L1GlobalCaloTrigger::setBxRangeSymmetric(const int numOfBx) { m_bxStart = -numOfBx; m_numOfBx = 2*numOfBx + 1; m_bxRangeAuto = false; }
429 
435 void L1GlobalCaloTrigger::fillRegions(const vector<L1CaloRegion>& rgn)
436 {
437  // To enable multiple bunch crossing operation, we copy the input regions into a vector,
438  // from which they will be extracted one bunch crossing at a time and sent to the processors
439  vector<L1CaloRegion>::iterator itr=m_allInputRegions.end();
440  m_allInputRegions.insert(itr, rgn.begin(), rgn.end());
441 }
442 
444 void L1GlobalCaloTrigger::fillEmCands(const vector<L1CaloEmCand>& em)
445 {
446  // To enable multiple bunch crossing operation, we copy the input electrons into a vector,
447  // from which they will be extracted one bunch crossing at a time and sent to the processors
448  vector<L1CaloEmCand>::iterator itr=m_allInputEmCands.end();
449  m_allInputEmCands.insert(itr, em.begin(), em.end());
450 }
451 
453 void L1GlobalCaloTrigger::fillRegions(vector<L1CaloRegion>::iterator& rgn, const int bx) {
454  while (rgn != m_allInputRegions.end() && rgn->bx() == bx) {
455  setRegion(*rgn++);
456  }
457 }
458 
460 void L1GlobalCaloTrigger::fillEmCands(vector<L1CaloEmCand>::iterator& emc, const int bx){
461  while (emc != m_allInputEmCands.end() && emc->bx() == bx) {
462  if (emc->isolated()) {
463  setIsoEm(*emc);
464  } else {
465  setNonIsoEm(*emc);
466  }
467  emc++;
468  }
469 }
470 
475 {
476  if ( !m_inputChannelMask->regionMask( region.gctEta(), region.gctPhi() ) ) {
477  unsigned crate = region.rctCrate();
478  // Find the relevant jetFinders
479  static const unsigned NPHI = L1CaloRegionDetId::N_PHI/2;
480  unsigned prevphi = crate % NPHI;
481  unsigned thisphi = (crate+1) % NPHI;
482  unsigned nextphi = (crate+2) % NPHI;
483 
484  // Send the region to six jetFinders.
485  theJetFinders.at(thisphi)->setInputRegion(region);
486  theJetFinders.at(nextphi)->setInputRegion(region);
487  theJetFinders.at(prevphi)->setInputRegion(region);
488  theJetFinders.at(thisphi+NPHI)->setInputRegion(region);
489  theJetFinders.at(nextphi+NPHI)->setInputRegion(region);
490  theJetFinders.at(prevphi+NPHI)->setInputRegion(region);
491  }
492 }
493 
496 void L1GlobalCaloTrigger::setRegion(const unsigned et, const unsigned ieta, const unsigned iphi,
497  const bool overFlow, const bool fineGrain)
498 {
499  // L1CaloRegion temp = L1CaloRegion::makeRegionFromGctIndices(et, overFlow, fineGrain, false, false, ieta, iphi, 0);
500  L1CaloRegion temp(et, overFlow, fineGrain, false, false, ieta, iphi, 0);
501  setRegion(temp);
502 }
503 
508 {
509  if ( !m_inputChannelMask->emCrateMask( em.rctCrate() ) )
510  theIsoElectronSorters.at(sorterNo(em))->setInputEmCand(em);
511 }
512 
517 {
518  if ( !m_inputChannelMask->emCrateMask( em.rctCrate() ) )
519  theNonIsoElectronSorters.at(sorterNo(em))->setInputEmCand(em);
520 }
521 
526 
527  using edm::LogInfo;
528  using std::endl;
529 
530  LogInfo("L1GlobalCaloTrigger") << "=== Global Calo Trigger ===" << endl;
531  LogInfo("L1GlobalCaloTrigger") << "=== START DEBUG OUTPUT ===" << endl;
532 
533  LogInfo("L1GlobalCaloTrigger") << endl;
534  LogInfo("L1GlobalCaloTrigger") << "N Jet Leaf Cards " << theJetLeafCards.size() << endl;
535  LogInfo("L1GlobalCaloTrigger") << "N Wheel Jet Fpgas " << theWheelJetFpgas.size() << endl;
536  LogInfo("L1GlobalCaloTrigger") << "N Wheel Energy Fpgas " << theWheelEnergyFpgas.size() << endl;
537  LogInfo("L1GlobalCaloTrigger") << "N Em Leaf Cards " << theEmLeafCards.size() << endl;
538  LogInfo("L1GlobalCaloTrigger") << endl;
539 
540  for (unsigned i=0; i<theJetLeafCards.size(); i++) {
541  LogInfo("L1GlobalCaloTrigger") << "Jet Leaf Card " << i << " : " << theJetLeafCards.at(i) << endl;
542  LogInfo("L1GlobalCaloTrigger") << (*theJetLeafCards.at(i));
543  }
544  LogInfo("L1GlobalCaloTrigger") << endl;
545 
546  for (unsigned i=0; i<theWheelJetFpgas.size(); i++) {
547  LogInfo("L1GlobalCaloTrigger") << "Wheel Jet FPGA " << i << " : " << theWheelJetFpgas.at(i) << endl;
548  LogInfo("L1GlobalCaloTrigger") << (*theWheelJetFpgas.at(i));
549  }
550  LogInfo("L1GlobalCaloTrigger") << endl;
551 
552  for (unsigned i=0; i<theWheelEnergyFpgas.size(); i++) {
553  LogInfo("L1GlobalCaloTrigger") << "Wheel Energy FPGA " << i <<" : " << theWheelEnergyFpgas.at(i) << endl;
554  LogInfo("L1GlobalCaloTrigger") << (*theWheelEnergyFpgas.at(i));
555  }
556  LogInfo("L1GlobalCaloTrigger") << endl;
557 
558  LogInfo("L1GlobalCaloTrigger") << (*theJetFinalStage);
559  LogInfo("L1GlobalCaloTrigger") << endl;
560 
561  LogInfo("L1GlobalCaloTrigger") << (*theEnergyFinalStage);
562  LogInfo("L1GlobalCaloTrigger") << endl;
563 
564  for (unsigned i=0; i<theEmLeafCards.size(); i++) {
565  LogInfo("L1GlobalCaloTrigger") << ( (i==0) ? "Positive eta " : "Negative eta " );
566  LogInfo("L1GlobalCaloTrigger") << "EM Leaf Card " << i << " : " << theEmLeafCards.at(i) << endl;
567  LogInfo("L1GlobalCaloTrigger") << (*theEmLeafCards.at(i));
568  }
569  LogInfo("L1GlobalCaloTrigger") << endl;
570 
571  LogInfo("L1GlobalCaloTrigger") << (*theIsoEmFinalStage);
572  LogInfo("L1GlobalCaloTrigger") << endl;
573 
574  LogInfo("L1GlobalCaloTrigger") << (*theNonIsoEmFinalStage);
575 
576  LogInfo("L1GlobalCaloTrigger") << "=== Global Calo Trigger ===" << endl;
577  LogInfo("L1GlobalCaloTrigger") << "=== END DEBUG OUTPUT ===" << endl;
578 
579 }
580 
584 // isolated EM outputs
587 }
588 
589 // non isolated EM outputs
592 }
593 
594 // central jet outputs to GT
597 }
598 
599 // forward jet outputs to GT
601  return theJetFinalStage->getForwardJets();
602 }
603 
604 // tau jet outputs to GT
606  return theJetFinalStage->getTauJets();
607 }
608 
612 
613  // Loop over jetfinders, find the internal jets and add them to the list
614  for (unsigned jf=0; jf<theJetFinders.size(); jf++) {
615  jfJets = theJetFinders.at(jf)->getInternalJets();
616  allJets.insert(allJets.end(), jfJets.begin(), jfJets.end());
617  }
618 
619  return allJets;
620 }
621 
622 // total Et output
625  int bx = m_bxStart;
626  for (int i=0; i<m_numOfBx; i++) {
628  theEnergyFinalStage->getEtSumColl().at(i).overFlow(),
629  bx++ );
630  result.at(i) = temp;
631  }
632  return result;
633 }
634 
637  int bx = m_bxStart;
638  for (int i=0; i<m_numOfBx; i++) {
640  theEnergyFinalStage->getEtHadColl().at(i).overFlow(),
641  bx++ );
642  result.at(i) = temp;
643  }
644  return result;
645 }
646 
649  int bx = m_bxStart;
650  for (int i=0; i<m_numOfBx; i++) {
652  theEnergyFinalStage->getEtMissPhiColl().at(i).value(),
653  theEnergyFinalStage->getEtMissColl().at(i).overFlow(),
654  bx++ );
655  result.at(i) = temp;
656  }
657  return result;
658 }
659 
662  int bx = m_bxStart;
663  for (int i=0; i<m_numOfBx; i++) {
665  theEnergyFinalStage->getHtMissPhiColl().at(i).value(),
666  theEnergyFinalStage->getHtMissColl().at(i).overFlow(),
667  bx++ );
668  result.at(i) = temp;
669  }
670  return result;
671 }
672 
674 {
675  L1GctInternEtSumCollection allSums, procSums;
676 
677  // Go through all the processor types that process et sums
678  // JetFinders
679  for (unsigned jf=0; jf<theJetFinders.size(); jf++) {
680  procSums = theJetFinders.at(jf)->getInternalEtSums();
681  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
682  }
683 
684  // Jet Leaf cards
685  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
686  procSums = theJetLeafCards.at(i)->getInternalEtSums();
687  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
688  }
689 
690  // Wheel Cards
691  for (int i=0; i<N_WHEEL_CARDS; i++) {
692  procSums = theWheelEnergyFpgas.at(i)->getInternalEtSums();
693  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
694  }
695 
696  return allSums;
697 }
698 
700 {
701  L1GctInternHtMissCollection allSums, procSums;
702 
703  // Go through all the processor types that process et sums
704  // JetFinders
705  for (unsigned jf=0; jf<theJetFinders.size(); jf++) {
706  procSums = theJetFinders.at(jf)->getInternalHtMiss();
707  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
708  }
709 
710  // Jet Leaf cards
711  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
712  procSums = theJetLeafCards.at(i)->getInternalHtMiss();
713  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
714  }
715 
716  // Wheel Cards
717  for (int i=0; i<N_WHEEL_CARDS; i++) {
718  procSums = theWheelJetFpgas.at(i)->getInternalHtMiss();
719  allSums.insert(allSums.end(), procSums.begin(), procSums.end());
720  }
721 
722  return allSums;
723 }
724 
725 
728  if (getHfSumProcessor() != 0) {
729  int bx = m_bxStart;
730  for (int i=0; i<m_numOfBx; i++) {
732  L1GctHFBitCounts::fromGctEmulator(static_cast<int16_t>(bx),
737  result.at(i) = temp;
738  bx++;
739  }
740  }
741  return result;
742 }
743 
746  if (getHfSumProcessor() != 0) {
747  int bx = m_bxStart;
748  for (int i=0; i<m_numOfBx; i++) {
750  L1GctHFRingEtSums::fromGctEmulator(static_cast<int16_t>(bx),
755  result.at(i) = temp;
756  bx++;
757  }
758  }
759  return result;
760 }
761 
762 
765  // EM Leaf Card
766  for (int i=0; i<N_EM_LEAF_CARDS; i++) {
767  theEmLeafCards.at(i)->setVerbose();
768  }
769 
770  // Jet Leaf cards
771  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
772  theJetLeafCards.at(i)->setVerbose();
773  }
774 
775  // Jet Finders
776  for (int i=0; i<N_JET_LEAF_CARDS*3; i++) {
777  theJetFinders.at(i)->setVerbose();
778  }
779 
780  // Wheel Cards
781  for (int i=0; i<N_WHEEL_CARDS; i++) {
782  theWheelJetFpgas.at(i)->setVerbose();
783  }
784 
785  for (int i=0; i<N_WHEEL_CARDS; i++) {
786  theWheelEnergyFpgas.at(i)->setVerbose();
787  }
788 
789  // Electron Final Stage
792 
793  // Jet Final Stage
795 
796  // Energy Final Stage
798 }
799 
801  // EM Leaf Card
802  for (int i=0; i<N_EM_LEAF_CARDS; i++) {
803  theEmLeafCards.at(i)->setTerse();
804  }
805 
806  // Jet Leaf cards
807  for (int i=0; i<N_JET_LEAF_CARDS; i++) {
808  theJetLeafCards.at(i)->setTerse();
809  }
810 
811  // Jet Finders
812  for (int i=0; i<N_JET_LEAF_CARDS*3; i++) {
813  theJetFinders.at(i)->setTerse();
814  }
815 
816  // Wheel Cards
817  for (int i=0; i<N_WHEEL_CARDS; i++) {
818  theWheelJetFpgas.at(i)->setTerse();
819  }
820 
821  for (int i=0; i<N_WHEEL_CARDS; i++) {
822  theWheelEnergyFpgas.at(i)->setTerse();
823  }
824 
825  // Electron Final Stage
828 
829  // Jet Final Stage
831 
832  // Energy Final Stage
834 }
835 
836 /* PRIVATE METHODS */
837 
838 // instantiate hardware/algorithms
840 
841  // The first half of the jet leaf cards are at negative eta,
842  // followed by positive eta
843  // Jet Leaf cards
844  if (jetLeafMask==0) {
845  for (int jlc=0; jlc<N_JET_LEAF_CARDS; jlc++) {
846  theJetLeafCards.at(jlc) = new L1GctJetLeafCard(jlc,jlc % 3, jfType);
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  }
851  } else {
852  // Setup for hardware testing with reduced number of leaf cards
853  unsigned mask = jetLeafMask;
854  for (int jlc=0; jlc<N_JET_LEAF_CARDS; jlc++) {
855  if ((mask&1) == 0) {
856  theJetLeafCards.at(jlc) = new L1GctJetLeafCard(jlc,jlc % 3, jfType);
857  } else {
859  }
860  theJetFinders.at( 3*jlc ) = theJetLeafCards.at(jlc)->getJetFinderA();
861  theJetFinders.at(3*jlc+1) = theJetLeafCards.at(jlc)->getJetFinderB();
862  theJetFinders.at(3*jlc+2) = theJetLeafCards.at(jlc)->getJetFinderC();
863  mask = mask >> 1;
864  }
865  }
866 
867  //Link jet leaf cards together
868  vector<L1GctJetLeafCard*> neighbours(2);
869  for (int jlc=0 ; jlc<N_JET_LEAF_CARDS/2; jlc++) {
870  // Define local constant for ease of typing
871  static const int NL = N_JET_LEAF_CARDS/2;
872  int nlc = (jlc+1)%NL;
873  int mlc = (jlc+(NL-1))%NL;
874  neighbours.at(0) = theJetLeafCards.at(mlc);
875  neighbours.at(1) = theJetLeafCards.at(nlc);
876  theJetLeafCards.at(jlc)->setNeighbourLeafCards(neighbours);
877  neighbours.at(0) = theJetLeafCards.at(NL+mlc);
878  neighbours.at(1) = theJetLeafCards.at(NL+nlc);
879  theJetLeafCards.at(NL+jlc)->setNeighbourLeafCards(neighbours);
880  }
881 
882  // EM leaf cards
883  // Card 0 is positive eta, card 1 is negative eta
884  for (int i=0; i<N_EM_LEAF_CARDS; i++) {
885  theEmLeafCards.at(i) = new L1GctEmLeafCard(i);
886  theIsoElectronSorters.at( 2*i ) = theEmLeafCards.at(i)->getIsoElectronSorterU1();
887  theIsoElectronSorters.at(2*i+1) = theEmLeafCards.at(i)->getIsoElectronSorterU2();
888  theNonIsoElectronSorters.at( 2*i ) = theEmLeafCards.at(i)->getNonIsoElectronSorterU1();
889  theNonIsoElectronSorters.at(2*i+1) = theEmLeafCards.at(i)->getNonIsoElectronSorterU2();
890  }
891 
892  // Wheel Fpgas
893  vector<L1GctJetLeafCard*> wheelJetLeafCards(3);
894  vector<L1GctJetLeafCard*> wheelEnergyLeafCards(3);
895 
896  // The first wheel card is at negative eta,
897  // the second one is at positive eta
898  for (int i=0; i<N_WHEEL_CARDS; i++) {
899  for (int j=0; j<3; j++) {
900  wheelJetLeafCards.at(j)=theJetLeafCards.at(i*3+j);
901  wheelEnergyLeafCards.at(j)=theJetLeafCards.at(i*3+j);
902  }
903  theWheelJetFpgas.at(i) = new L1GctWheelJetFpga (i,wheelJetLeafCards);
904  theWheelEnergyFpgas.at(i) = new L1GctWheelEnergyFpga(i,wheelEnergyLeafCards);
905  }
906 
907  // Jet Final Stage
909 
910  // Electron Final Sort
913 
914  // Global Energy Algos
916 
917 }
918 
926 unsigned L1GlobalCaloTrigger::sorterNo(const L1CaloEmCand& em) const {
927  unsigned crate = em.rctCrate();
928  unsigned result = ( ((crate%9) < 4) ? 1 : 0 );
929  if (crate>=9) result += 2;
930  if (crate>=18) result = 0;
931  return result;
932 }
933 
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 > getHtMissColl() const
return output missing Ht magnitude
L1GctHFRingEtSumsCollection getHFRingEtSumsCollection() const
int i
Definition: DBlmapReader.cc:9
void bxReset(const int bx)
Partial reset for a new bunch crossing.
bool setupOk() const
check we have done all the setup
void fillEmCands(const std::vector< L1CaloEmCand > &rgn)
set electrons from the RCT at the input to be processed
L1GctJetCandCollection getTauJets() const
tau jet outputs to GT
std::vector< L1GctJetLeafCard * > theJetLeafCards
pointers to the Jet Leaf cards
bool setupOk() const
check setup
void reset()
clear internal buffers
void setupTauAlgo(const bool useImprovedAlgo, const bool ignoreVetoBitsForIsolation)
setup the tau algorithm parameters
void sortInputData()
Sort the input data by bunch crossing number.
L1GctHFBitCountsCollection getHFBitCountsCollection() const
std::vector< L1GctEtMiss > L1GctEtMissCollection
Represents a GCT Wheel Jet FPGA.
JetVector getCentralJets() const
get the central jets output data
std::vector< L1CaloEmCand > m_allInputEmCands
static const int N_WHEEL_CARDS
Number of Wheel Cards.
unsigned rctCrate() const
get RCT crate ID
Definition: L1CaloRegion.h:165
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 setJetFinderParams(const L1GctJetFinderParams *const jfpars)
unsigned sorterNo(const L1CaloEmCand &em) const
unsigned getCenJetEtSeedGct() const
unsigned getTauJetEtSeedGct() const
L1GctGlobalEnergyAlgos * theEnergyFinalStage
energy final stage algos
std::vector< L1GctEtHad > L1GctEtHadCollection
std::vector< etMissPhiType > getEtMissPhiColl() const
return output missing Et value
const L1GctChannelMask * m_inputChannelMask
Input channel mask.
virtual void process()
process the data, fill output buffers
void setIsoEm(const L1CaloEmCand &em)
set an isolated EM candidate to be processed
std::vector< L1GctInternHtMiss > L1GctInternHtMissCollection
bool m_bxRangeAuto
Multiple bunch crossing operation.
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:18
Persistable copy of missing Et measured at Level-1.
Definition: L1GctEtMiss.h:18
L1GctJetCandCollection getForwardJets() const
forward jet outputs to GT
void setJetFinderParams(const L1GctJetFinderParams *const jfpars)
JetVector getForwardJets() const
get the forward jets output data
~L1GlobalCaloTrigger()
dismantle the GCT
L1GctEmCandCollection getNonIsoElectrons() const
non-iso electron outputs to GT
L1GctElectronFinalSort * theNonIsoEmFinalStage
non-iso electron final stage sorter
JetVector getTauJets() const
get the tau jets output data
lutPtrVector m_jetEtCalLuts
Jet Et calibration LUT.
L1GctHtMissCollection getHtMissCollection() const
Htmiss output to GT.
virtual void process()
process the data, fill output buffers
L1GctGlobalHfSumAlgos * getHfSumProcessor() const
provide access to hf sum processor
L1GctEtTotalCollection getEtSumCollection() const
Total Et output to GT.
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)
tuple result
Definition: mps_fire.py:84
bool emCrateMask(unsigned crate) const
get EM masks for an RCT crate
bool regionMask(unsigned ieta, unsigned iphi) const
get region masks
std::vector< L1GctHFBitCounts > L1GctHFBitCountsCollection
std::vector< L1GctJetCand > L1GctJetCandCollection
Represents the final stage of L1 jet processing.
CompareBx< L1CaloRegion > rgnBxComparator
void setVerbose()
control output messages
std::vector< etHadType > getEtHadColl() const
return std::vector&lt; output calibrated jet Et
virtual void fetchInput()
get input data from sources
L1GctElectronFinalSort * theIsoEmFinalStage
iso electron final stage sorter
void setHtMissScale(const L1CaloEtScale *const scale)
setup scale for missing Ht
L1 GCT HF ring Et sums.
std::vector< L1GctEmCand > getOutputCands() const
return output data
L1GctInternHtMissCollection getInternalHtMiss() const
Persistable copy of total Et measured at Level-1.
Definition: L1GctEtTotal.h:18
unsigned rctCrate() const
get RCT crate
Definition: L1CaloEmCand.h:53
bool setupOk() const
check setup
static const int N_JET_LEAF_CARDS
Number of Leaf Cards configured for jet processing.
void fillRegions(const std::vector< L1CaloRegion > &rgn)
std::vector< L1GctElectronSorter * > theIsoElectronSorters
pointers to the electron sorters
int j
Definition: DBlmapReader.cc:9
std::vector< etTotalType > getEtSumColl() const
return output total scalar Et
Emulates the GCT global energy algorithms.
L1GctGlobalHfSumAlgos * getHfSumProcessor() const
provide access to hf sum processor
L1GctEtHadCollection getEtHadCollection() const
Total hadronic Et output to GT.
T min(T a, T b)
Definition: MathUtil.h:58
void setupHfSumLuts(const L1CaloEtScale *const scale)
setup Hf sum LUTs
void setBxRange(const int firstBx, const int lastBx)
L1GctJetCandCollection getCentralJets() const
central jet outputs to GT
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
L1GctInternJetDataCollection getInternalJets() const
all jets from jetfinders in raw format
CompareBx< L1CaloEmCand > emcBxComparator
void setBxRange(const int firstBx, const int numberOfBx)
define the bunch crossing range to process
Persistable copy of total Ht measured at Level-1.
Definition: L1GctEtHad.h:18
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)
L1GctEmCandCollection getIsoElectrons() const
std::vector< L1GctHtMiss > L1GctHtMissCollection
virtual void process()
process the data, fill output buffers
void setJetEtCalibrationLuts(const lutPtrVector &jfluts)
setup the Jet Calibration Luts
unsigned getCenForJetEtaBoundary() const
void setBxRangeAutomatic()
process all crossings present in the input (and only those crossings)
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
static const int N_EM_LEAF_CARDS
Number of Leaf Cards configured for EM processing.
unsigned gctEta() const
get GCT eta index
Definition: L1CaloRegion.h:180
std::vector< L1GctInternJetData > L1GctInternJetDataCollection
unsigned gctPhi() const
get GCT phi index
Definition: L1CaloRegion.h:183
std::vector< etMissPhiType > getHtMissPhiColl() const
return output missing Ht value
std::vector< L1GctElectronSorter * > theNonIsoElectronSorters
std::vector< L1CaloRegion > m_allInputRegions
void build(L1GctJetLeafCard::jetFinderType jfType, unsigned jetLeafMask)
instantiate the hardware &amp; algo objects and wire up the system
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:22
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.
void setNextBx(const int bx)
partially clear buffers
void setNextBx(const int bxnum)
clear input data buffers and process a new bunch crossing
std::vector< etMissType > getEtMissColl() const
return output missing Et magnitude
virtual void fetchInput()
get input data from sources
L1GctJetFinalStage * theJetFinalStage
jet final stage algo
virtual void fetchInput()
get input data from sources
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
L1GctEtMissCollection getEtMissCollection() const
Etmiss output to GT.
void process()
process an event
const L1GctJetFinderParams * m_jetFinderParams
Jetfinder parameters.
Emulates a leaf card programmed for electron sorting.
void setVerbose()
control output messages
std::vector< L1GctEmCand > L1GctEmCandCollection
L1GctInternEtSumCollection getInternalEtSums() const
Et sums and components in internal format.