CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1RCTElectronIsolationCard Class Reference

#include <L1RCTElectronIsolationCard.h>

Public Member Functions

int cardNumber ()
 
int crateNumber ()
 
void fillElectronCandidates ()
 
unsigned short getIsoElectrons (int i)
 
unsigned short getNonIsoElectrons (int i)
 
 L1RCTElectronIsolationCard (int crateNumber, int cardNumber, const L1RCTLookupTables *rctLookupTables)
 
 L1RCTElectronIsolationCard ()=delete
 
void print ()
 
void printEdges ()
 
void setRegion (int i, const L1RCTRegion &region)
 
 ~L1RCTElectronIsolationCard ()
 

Private Member Functions

std::vector< unsigned short > calcElectronCandidates (const L1RCTRegion &region, int regionNum)
 
unsigned short calcMaxSum (unsigned short primaryEt, unsigned short northEt, unsigned short southEt, unsigned short eastEt, unsigned short westEt)
 

Private Attributes

unsigned short cardNo
 
unsigned short crtNo
 
L1RCTRegion empty
 
std::vector< unsigned short > isoElectrons
 
std::vector< unsigned short > nonIsoElectrons
 
const L1RCTLookupTablesrctLookupTables_
 
std::vector< L1RCTRegionregions
 

Detailed Description

Definition at line 19 of file L1RCTElectronIsolationCard.h.

Constructor & Destructor Documentation

◆ L1RCTElectronIsolationCard() [1/2]

L1RCTElectronIsolationCard::L1RCTElectronIsolationCard ( int  crateNumber,
int  cardNumber,
const L1RCTLookupTables rctLookupTables 
)

Definition at line 8 of file L1RCTElectronIsolationCard.cc.

References regions.

11  : crtNo(crateNumber),
13  rctLookupTables_(rctLookupTables),
14  isoElectrons(2),
15  nonIsoElectrons(2),
16  regions(2) {
17  regions.push_back(L1RCTRegion());
18  regions.push_back(L1RCTRegion());
19 }
std::vector< L1RCTRegion > regions
const L1RCTLookupTables * rctLookupTables_
std::vector< unsigned short > nonIsoElectrons
std::vector< unsigned short > isoElectrons

◆ L1RCTElectronIsolationCard() [2/2]

L1RCTElectronIsolationCard::L1RCTElectronIsolationCard ( )
delete

◆ ~L1RCTElectronIsolationCard()

L1RCTElectronIsolationCard::~L1RCTElectronIsolationCard ( )

Definition at line 21 of file L1RCTElectronIsolationCard.cc.

References regions.

21 { regions.clear(); }
std::vector< L1RCTRegion > regions

Member Function Documentation

◆ calcElectronCandidates()

std::vector< unsigned short > L1RCTElectronIsolationCard::calcElectronCandidates ( const L1RCTRegion region,
int  regionNum 
)
private

Definition at line 38 of file L1RCTElectronIsolationCard.cc.

References calcMaxSum(), HLT_2022v11_cff::candidates, cardNo, cardNumber(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, crateNumber(), MillePedeFileConverter_cfg::e, L1RCTParameters::eicIsolationThreshold(), mps_fire::i, dqmiolumiharvest::j, dqmiodumpmetadata::n, compareTotals::ne, rctLookupTables_, L1RCTLookupTables::rctParameters(), HLT_2022v11_cff::region, alignCSCRings::s, and w().

Referenced by fillElectronCandidates().

39  {
40  unsigned short nonIsoElectron = 0;
41  unsigned short isoElectron = 0;
42 
43  // i is row and j is column
44  for (int i = 0; i < 4; i++) {
45  for (int j = 0; j < 4; j++) {
46  unsigned short primaryEt = region.getEtIn7Bits(i, j);
47  unsigned short primaryHE_FG = region.getHE_FGBit(i, j);
48 
49  unsigned short northEt = region.getEtIn7Bits(i - 1, j);
50  unsigned short southEt = region.getEtIn7Bits(i + 1, j);
51  unsigned short westEt = region.getEtIn7Bits(i, j - 1);
52  unsigned short eastEt = region.getEtIn7Bits(i, j + 1);
53  unsigned short neEt = region.getEtIn7Bits(i - 1, j + 1);
54  unsigned short nwEt = region.getEtIn7Bits(i - 1, j - 1);
55  unsigned short seEt = region.getEtIn7Bits(i + 1, j + 1);
56  unsigned short swEt = region.getEtIn7Bits(i + 1, j - 1);
57 
58  unsigned short northHE_FG = region.getHE_FGBit(i - 1, j);
59  unsigned short southHE_FG = region.getHE_FGBit(i + 1, j);
60  unsigned short westHE_FG = region.getHE_FGBit(i, j - 1);
61  unsigned short eastHE_FG = region.getHE_FGBit(i, j + 1);
62  unsigned short neHE_FG = region.getHE_FGBit(i - 1, j + 1);
63  unsigned short nwHE_FG = region.getHE_FGBit(i - 1, j - 1);
64  unsigned short seHE_FG = region.getHE_FGBit(i + 1, j + 1);
65  unsigned short swHE_FG = region.getHE_FGBit(i + 1, j - 1);
66 
67  bool top = false;
68 
69  int nCrate = crateNumber();
70  int nCard = cardNumber();
71  int nRegion = regionNum;
72 
73  // top row of crate
74  if (nCard == 0 || nCard == 2 || nCard == 4 || (nCard == 6 && nRegion == 0)) {
75  top = true;
76  }
77  // bottom row of crate
78  else if (nCard == 1 || nCard == 3 || nCard == 5 || (nCard == 6 && nRegion == 1)) {
79  } // top already false
80  else {
81  std::cerr << "Error! EIC top assignment" << std::endl; // this shouldn't happen!
82  }
83 
84  // The following values are used for zeroing and determining whether or
85  // not a tower is a "candidate". The original primaryEt, northEt, neEt,
86  // etc. are used to calculate vetoes and must not be zeroed.
87 
88  unsigned short primaryTowerEt = primaryEt;
89  unsigned short northTowerEt = northEt;
90  unsigned short southTowerEt = southEt;
91  unsigned short eastTowerEt = eastEt;
92  unsigned short westTowerEt = westEt;
93 
94  // In order to ensure proper selection of candidate tower and neighbor,
95  // if two neighbor energies are equal, one is set to zero (in the
96  // appropriate regions, those for which tp_lf bit is set to 0 in
97  // Pam's JCCTest/EGWithShare.cc).
98 
99  if (primaryEt > 0) // this value should maybe be customizable?
100  {
101  if (nCard != 6) // all cards except 6
102  {
103  if (top && nCrate >= 9) // top row of regions in positive-eta crate
104  {
105  if (westTowerEt == eastTowerEt)
106  westTowerEt = 0;
107  if (southTowerEt == northTowerEt)
108  southTowerEt = 0;
109  if (southTowerEt == eastTowerEt)
110  southTowerEt = 0;
111  if (westTowerEt == northTowerEt)
112  westTowerEt = 0;
113  } else if ((!top) && nCrate < 9) // bottom row of regions in negative-eta crate
114  {
115  if (eastTowerEt == westTowerEt)
116  eastTowerEt = 0;
117  if (northTowerEt == southTowerEt)
118  northTowerEt = 0;
119  if (northTowerEt == westTowerEt)
120  northTowerEt = 0;
121  if (eastTowerEt == southTowerEt)
122  eastTowerEt = 0;
123  }
124  } else // card 6
125  {
126  // only +eta card 6 needs to have zeroing. Pam sez.
127  // -eta card 6 does what it's supposed to even w/o zeroing.
128  if (nRegion == 0 && nCrate >= 9) {
129  if (westTowerEt == eastTowerEt)
130  westTowerEt = 0;
131  if (southTowerEt == northTowerEt)
132  southTowerEt = 0;
133  if (southTowerEt == eastTowerEt)
134  southTowerEt = 0;
135  if (westTowerEt == northTowerEt)
136  westTowerEt = 0;
137  }
138  }
139  }
140 
141  // This section compares the energies in the primary tower with the
142  // surrounding towers to determine whether or not the primary tower
143  // should be considered a "candidate".
144 
145  bool candidate = false;
146 
147  // for case where primary tower et greater than all neighbors -> candidate
148  if (primaryEt > northEt && primaryEt > southEt && primaryEt > eastEt && primaryEt > westEt && !primaryHE_FG) {
149  candidate = true;
150  }
151 
152  // if primary et less than any neighbors (or HE_FG veto set) NOT a
153  // candidate!
154  else if (primaryEt < northEt || primaryEt < southEt || primaryEt < eastEt || primaryEt < westEt || primaryHE_FG) {
155  } // candidate already false
156 
157  else // Case of primary tower et being equal to any of its neighbors.
158  // This section determines which tower gets the candidate.
159  // See AboutTP.pdf document, figure on p. 4, for clarification.
160  // Zeroed values are used in this calculation.
161  {
162  if (primaryEt > 0) {
163  if (nCrate >= 9) // positive eta
164  {
165  if (top) // top row of regions in crate. tp_lf == 0
166  // priority order: east < south < north < west
167  {
168  if (westTowerEt == primaryTowerEt)
169  candidate = true;
170  else if (northTowerEt == primaryTowerEt)
171  candidate = false;
172  else if (southTowerEt == primaryTowerEt)
173  candidate = true;
174  else if (eastTowerEt == primaryTowerEt)
175  candidate = false;
176  }
177 
178  else // bottom row of regions in crate. tp_lf == 1
179  // priority order: west < north < south < east
180  {
181  if (eastTowerEt == primaryTowerEt)
182  candidate = true;
183  else if (southTowerEt == primaryTowerEt)
184  candidate = true;
185  else if (northTowerEt == primaryTowerEt)
186  candidate = false;
187  else if (westTowerEt == primaryTowerEt)
188  candidate = false;
189  if (nCard == 6) // card 6. tp_lf == 1
190  {
191  // priority order: east < north < south < west
192  if (westTowerEt == primaryTowerEt)
193  candidate = true;
194  else if (southTowerEt == primaryTowerEt)
195  candidate = true;
196  else if (northTowerEt == primaryTowerEt)
197  candidate = false;
198  else if (eastTowerEt == primaryTowerEt)
199  candidate = false;
200  }
201  }
202  } else // negative eta
203  {
204  if (top) // top row of regions in crate. tp_lf == 1
205  // priority order: east < south < north < west
206  {
207  if (westTowerEt == primaryTowerEt)
208  candidate = true;
209  else if (northTowerEt == primaryTowerEt)
210  candidate = true;
211  else if (southTowerEt == primaryTowerEt)
212  candidate = false;
213  else if (eastTowerEt == primaryTowerEt)
214  candidate = false;
215  if (nCard == 6) // card 6. tp_lf == 0
216  // east < south < north < west
217  {
218  if (westTowerEt == primaryTowerEt)
219  candidate = false;
220  else if (northTowerEt == primaryTowerEt)
221  candidate = false;
222  else if (southTowerEt == primaryTowerEt)
223  candidate = true;
224  else if (eastTowerEt == primaryTowerEt)
225  candidate = true;
226  }
227  } else // bottom row of regions. tp_lf == 0
228  // west < north < south < east
229  {
230  if (eastTowerEt == primaryTowerEt)
231  candidate = true;
232  else if (southTowerEt == primaryTowerEt)
233  candidate = false;
234  else if (northTowerEt == primaryTowerEt)
235  candidate = true;
236  else if (westTowerEt == primaryTowerEt)
237  candidate = false;
238 
239  if (nCard == 6) // card 6. tp_lf == 1
240  // west < north < south < east
241  {
242  if (eastTowerEt == primaryTowerEt)
243  candidate = true;
244  else if (southTowerEt == primaryTowerEt)
245  candidate = true;
246  else if (northTowerEt == primaryTowerEt)
247  candidate = false;
248  else if (westTowerEt == primaryTowerEt)
249  candidate = false;
250  }
251  }
252  }
253  }
254  } // end of if (primary == neighbors)
255 
256  if (candidate) {
257  // Either zeroed or non-zeroed set of values can be used here --
258  // neighbor tower only zeroed if another neighbor tower of same
259  // energy. Max sum calculated from primary and only one neighbor
260  // tower, and always one neighbor tower left over, so value of sum
261  // is not affected. Currently using non-zeroed.
262  unsigned short candidateEt = calcMaxSum(primaryEt, northEt, southEt, eastEt, westEt);
263 
264  // neighbor HE_FG veto true if neighbor has HE_FG set
265  bool neighborVeto =
266  (nwHE_FG || northHE_FG || neHE_FG || westHE_FG || eastHE_FG || swHE_FG || southHE_FG || seHE_FG);
267 
268  // threshold for five-tower corner quiet veto
269  // int quietThreshold = 3; // 3 - loose isolation 0 - very tight
270  // isolation int quietThreshold = 7; // ECALGREN int quietThreshold = 0;
271  // // HCALGREN
272  unsigned quietThreshold = rctLookupTables_->rctParameters()->eicIsolationThreshold();
273 
274  bool nw = false;
275  bool ne = false;
276  bool sw = false;
277  bool se = false;
278  bool n = false;
279  bool w = false;
280  bool s = false;
281  bool e = false;
282 
283  // individual neighbor vetoes set if neighbor is over threshold
284  if (nwEt >= quietThreshold)
285  nw = true;
286  if (neEt >= quietThreshold)
287  ne = true;
288  if (swEt >= quietThreshold)
289  sw = true;
290  if (seEt >= quietThreshold)
291  se = true;
292  if (northEt >= quietThreshold)
293  n = true;
294  if (southEt >= quietThreshold)
295  s = true;
296  if (westEt >= quietThreshold)
297  w = true;
298  if (eastEt >= quietThreshold)
299  e = true;
300 
301  // veto TRUE for each corner set if any individual tower in each set is
302  // over threshold
303  bool nwC = (sw || w || nw || n || ne);
304  bool neC = (nw || n || ne || e || se);
305  bool seC = (ne || e || se || s || sw);
306  bool swC = (se || s || sw || w || nw);
307 
308  // overall quiet veto TRUE only if NO corner sets are quiet
309  // (all are "loud") -> non-isolated
310  bool quietVeto = (nwC && neC && seC && swC);
311 
312  // only isolated if both vetoes are false
313  // Note: quietThreshold = 0 forces all candidates to be non-iso
314  if (!(quietVeto || neighborVeto)) {
315  if (candidateEt > isoElectron)
316  isoElectron = candidateEt;
317  }
318  // otherwise, non-isolated
319  else if (candidateEt > nonIsoElectron)
320  nonIsoElectron = candidateEt;
321  }
322  }
323  }
324 
325  std::vector<unsigned short> candidates;
326  unsigned short fullIsoElectron =
327  isoElectron * 16 + cardNo * 2; // leaves room for last bit -- region number, added in Crate.cc
328  candidates.push_back(fullIsoElectron);
329  unsigned short fullNonIsoElectron = nonIsoElectron * 16 + cardNo * 2; // leaves room for region info in last bit
330  candidates.push_back(fullNonIsoElectron);
331 
332  return candidates;
333 }
T w() const
const L1RCTLookupTables * rctLookupTables_
const L1RCTParameters * rctParameters() const
unsigned eicIsolationThreshold() const
unsigned short calcMaxSum(unsigned short primaryEt, unsigned short northEt, unsigned short southEt, unsigned short eastEt, unsigned short westEt)

◆ calcMaxSum()

unsigned short L1RCTElectronIsolationCard::calcMaxSum ( unsigned short  primaryEt,
unsigned short  northEt,
unsigned short  southEt,
unsigned short  eastEt,
unsigned short  westEt 
)
private

Definition at line 335 of file L1RCTElectronIsolationCard.cc.

References mps_fire::i, SiStripPI::max, and ctpps_dqm_sourceclient-live_cfg::test.

Referenced by calcElectronCandidates().

339  {
340  unsigned short cardinals[4] = {northEt, southEt, eastEt, westEt};
341  unsigned short max = 0;
342  for (int i = 0; i < 4; i++) {
343  unsigned short test = primaryEt + cardinals[i];
344  if (test > max)
345  max = test;
346  }
347  return max;
348 }

◆ cardNumber()

int L1RCTElectronIsolationCard::cardNumber ( )
inline

Definition at line 26 of file L1RCTElectronIsolationCard.h.

References cardNo.

Referenced by calcElectronCandidates().

26 { return cardNo; }

◆ crateNumber()

int L1RCTElectronIsolationCard::crateNumber ( )
inline

Definition at line 25 of file L1RCTElectronIsolationCard.h.

References crtNo.

Referenced by calcElectronCandidates().

25 { return crtNo; }

◆ fillElectronCandidates()

void L1RCTElectronIsolationCard::fillElectronCandidates ( )

Definition at line 23 of file L1RCTElectronIsolationCard.cc.

References calcElectronCandidates(), isoElectrons, nonIsoElectrons, and regions.

23  {
24  std::vector<unsigned short> region0Electrons = calcElectronCandidates(regions.at(0), 0);
25  std::vector<unsigned short> region1Electrons = calcElectronCandidates(regions.at(1), 1);
26  isoElectrons.at(0) = region0Electrons.at(0);
27  isoElectrons.at(1) = region1Electrons.at(0);
28  nonIsoElectrons.at(0) = region0Electrons.at(1);
29  nonIsoElectrons.at(1) = region1Electrons.at(1);
30 }
std::vector< L1RCTRegion > regions
std::vector< unsigned short > nonIsoElectrons
std::vector< unsigned short > isoElectrons
std::vector< unsigned short > calcElectronCandidates(const L1RCTRegion &region, int regionNum)

◆ getIsoElectrons()

unsigned short L1RCTElectronIsolationCard::getIsoElectrons ( int  i)
inline

Definition at line 32 of file L1RCTElectronIsolationCard.h.

References mps_fire::i, and isoElectrons.

32 { return isoElectrons.at(i); }
std::vector< unsigned short > isoElectrons

◆ getNonIsoElectrons()

unsigned short L1RCTElectronIsolationCard::getNonIsoElectrons ( int  i)
inline

Definition at line 34 of file L1RCTElectronIsolationCard.h.

References mps_fire::i, and nonIsoElectrons.

34 { return nonIsoElectrons.at(i); }
std::vector< unsigned short > nonIsoElectrons

◆ print()

void L1RCTElectronIsolationCard::print ( void  )

Definition at line 350 of file L1RCTElectronIsolationCard.cc.

References cardNo, gather_cfg::cout, isoElectrons, nonIsoElectrons, and regions.

350  {
351  std::cout << "Electron isolation card " << cardNo << std::endl;
352  std::cout << "Region 0 Information" << std::endl;
353  regions.at(0).print();
354 
355  std::cout << "IsoElectron Candidate " << isoElectrons.at(0) << std::endl;
356  std::cout << "NonIsoElectron Candidate " << nonIsoElectrons.at(0) << std::endl << std::endl;
357 
358  std::cout << "Region 1 Information" << std::endl;
359  regions.at(1).print();
360 
361  std::cout << "IsoElectron Candidate " << isoElectrons.at(1) << std::endl;
362  std::cout << "NonIsoElectron Candidate " << nonIsoElectrons.at(1) << std::endl;
363 }
std::vector< L1RCTRegion > regions
std::vector< unsigned short > nonIsoElectrons
std::vector< unsigned short > isoElectrons

◆ printEdges()

void L1RCTElectronIsolationCard::printEdges ( )
inline

Definition at line 36 of file L1RCTElectronIsolationCard.h.

References regions.

36  {
37  regions.at(0).printEdges();
38  regions.at(1).printEdges();
39  }
std::vector< L1RCTRegion > regions

◆ setRegion()

void L1RCTElectronIsolationCard::setRegion ( int  i,
const L1RCTRegion region 
)
inline

Definition at line 29 of file L1RCTElectronIsolationCard.h.

References mps_fire::i, HLT_2022v11_cff::region, and regions.

Member Data Documentation

◆ cardNo

unsigned short L1RCTElectronIsolationCard::cardNo
private

Definition at line 50 of file L1RCTElectronIsolationCard.h.

Referenced by calcElectronCandidates(), cardNumber(), and print().

◆ crtNo

unsigned short L1RCTElectronIsolationCard::crtNo
private

Definition at line 49 of file L1RCTElectronIsolationCard.h.

Referenced by crateNumber().

◆ empty

L1RCTRegion L1RCTElectronIsolationCard::empty
private

◆ isoElectrons

std::vector<unsigned short> L1RCTElectronIsolationCard::isoElectrons
private

Definition at line 56 of file L1RCTElectronIsolationCard.h.

Referenced by fillElectronCandidates(), getIsoElectrons(), and print().

◆ nonIsoElectrons

std::vector<unsigned short> L1RCTElectronIsolationCard::nonIsoElectrons
private

Definition at line 57 of file L1RCTElectronIsolationCard.h.

Referenced by fillElectronCandidates(), getNonIsoElectrons(), and print().

◆ rctLookupTables_

const L1RCTLookupTables* L1RCTElectronIsolationCard::rctLookupTables_
private

Definition at line 52 of file L1RCTElectronIsolationCard.h.

Referenced by calcElectronCandidates().

◆ regions

std::vector<L1RCTRegion> L1RCTElectronIsolationCard::regions
private