CMS 3D CMS Logo

Stage1Layer2CentralityAlgorithm.cc
Go to the documentation of this file.
1 
13 
15  : params_(params)
16 {}
17 
18 
19 void l1t::Stage1Layer2CentralityAlgorithm::processEvent(const std::vector<l1t::CaloRegion> & regions,
20  const std::vector<l1t::CaloEmCand> & EMCands,
21  const std::vector<l1t::Tau> * taus,
22  l1t::CaloSpare * spare) {
23 
24  // This is no really two algorithms, the first is the HI centrality algorithm
25  // while the second is an alternative MB trigger.
26 
27  // Begin Centrality Trigger //
28  int etaMask = params_->centralityRegionMask();
29  int sumET = 0;
30  int regionET=0;
31 
32  for(std::vector<CaloRegion>::const_iterator region = regions.begin(); region != regions.end(); region++) {
33 
34  int etaVal = region->hwEta();
35  if (etaVal > 3 && etaVal < 18) continue; // never consider central regions, independent of mask
36  if((etaMask & (1<<etaVal))>>etaVal) continue;
37 
38  regionET=region->hwPt();
39  sumET +=regionET;
40  }
41 
42  // The LUT format is pretty funky.
43  int LUT_under[8];
44  int LUT_nominal[8];
45  int LUT_over[8];
46  for(int i = 0; i < 8; ++i)
47  {
48  LUT_nominal[i] = params_->centralityLUT()->data(i);
49  }
50  LUT_under[0] = LUT_nominal[0];
51  LUT_over[0] = LUT_nominal[0];
52  for(int i = 8; i < 22; ++i)
53  {
54  int j=i-8;
55  if(j%2 == 0){
56  LUT_under[j/2+1] = params_->centralityLUT()->data(i);
57  } else {
58  LUT_over[j/2+1] = params_->centralityLUT()->data(i);
59  }
60  }
61 
62  int regularResult = 0;
63  int underlapResult = 0;
64  int overlapResult = 0;
65 
66  for(int i = 0; i < 8; ++i)
67  {
68  if(sumET > LUT_nominal[i])
69  regularResult = i;
70  if(sumET > LUT_under[i])
71  underlapResult = i;
72  if(sumET >= LUT_over[i]) // logical expression in firmware is constructed slightly differently, but this is equivalent
73  overlapResult = i;
74  }
75 
76  int alternateResult = 0;
77  if(underlapResult > regularResult) {
78  alternateResult = underlapResult;
79  } else if(overlapResult < regularResult) {
80  alternateResult = overlapResult;
81  } else {
82  alternateResult = regularResult;
83  }
84 
85  //paranoia
86  if(regularResult > 0x7) regularResult = 0x7;
87  if(alternateResult > 0x7) alternateResult = 0x7;
88 
89  spare->SetRing(0, regularResult);
90  spare->SetRing(1, alternateResult);
91  // End Centrality Trigger //
92 
93  // Begin MB Trigger //
94  std::vector<int> thresholds = params_->minimumBiasThresholds();
95  int numOverThresh[4] = {0};
96  for(std::vector<CaloRegion>::const_iterator region = regions.begin(); region != regions.end(); region++) {
97  if(region->hwEta() < 4) {
98  if(region->hwPt() >= thresholds.at(0))
99  numOverThresh[0]++;
100  if(region->hwPt() >= thresholds.at(2))
101  numOverThresh[2]++;
102  }
103  if(region->hwEta() > 17) {
104  if(region->hwPt() >= thresholds.at(1))
105  numOverThresh[1]++;
106  if(region->hwPt() >= thresholds.at(3))
107  numOverThresh[3]++;
108  }
109  }
110 
111  int bits[6];
112  bits[0] = ((numOverThresh[0] > 0) && (numOverThresh[1] > 0));
113  bits[1] = ((numOverThresh[0] > 0) || (numOverThresh[1] > 0));
114  bits[2] = ((numOverThresh[2] > 0) && (numOverThresh[3] > 0));
115  bits[3] = ((numOverThresh[2] > 0) || (numOverThresh[3] > 0));
116  bits[4] = ((numOverThresh[0] > 1) && (numOverThresh[1] > 1));
117  bits[5] = ((numOverThresh[2] > 1) && (numOverThresh[3] > 1));
118 
119  spare->SetRing(2, (bits[2]<<2) + (bits[1]<<1) + bits[0]);
120  spare->SetRing(3, (bits[5]<<2) + (bits[4]<<1) + bits[3]);
121  // End MB Trigger //
122 
123 }
int centralityRegionMask() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
void SetRing(unsigned index, int value)
Definition: CaloSpare.cc:42
Stage1Layer2CentralityAlgorithm(CaloParamsHelper const *params)
std::vector< int > minimumBiasThresholds() const
void processEvent(const std::vector< l1t::CaloRegion > &regions, const std::vector< l1t::CaloEmCand > &EMCands, const std::vector< l1t::Tau > *taus, l1t::CaloSpare *spare) override
int data(unsigned int address) const
Definition: LUT.h:46