CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
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)
 
 L1RCTElectronIsolationCard ()
 

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::L1RCTElectronIsolationCard ( int  crateNumber,
int  cardNumber,
const L1RCTLookupTables rctLookupTables 
)

Definition at line 8 of file L1RCTElectronIsolationCard.cc.

References regions.

10  :
12  rctLookupTables_(rctLookupTables),
14 {
15  regions.push_back(L1RCTRegion());
16  regions.push_back(L1RCTRegion());
17 }
std::vector< L1RCTRegion > regions
const L1RCTLookupTables * rctLookupTables_
std::vector< unsigned short > nonIsoElectrons
std::vector< unsigned short > isoElectrons
L1RCTElectronIsolationCard::~L1RCTElectronIsolationCard ( )

Definition at line 19 of file L1RCTElectronIsolationCard.cc.

References regions.

20 {
21  regions.clear();
22 }
std::vector< L1RCTRegion > regions
L1RCTElectronIsolationCard::L1RCTElectronIsolationCard ( )
private

Member Function Documentation

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

Definition at line 44 of file L1RCTElectronIsolationCard.cc.

References calcMaxSum(), objects.IsoTrackAnalyzer::candidates, cardNo, cardNumber(), dtNoiseDBValidation_cfg::cerr, crateNumber(), alignCSCRings::e, L1RCTParameters::eicIsolationThreshold(), L1RCTRegion::getEtIn7Bits(), L1RCTRegion::getHE_FGBit(), i, j, gen::n, Vispa.Plugins.EdmBrowser.EdmDataAccessor::ne(), rctLookupTables_, L1RCTLookupTables::rctParameters(), alignCSCRings::s, and w.

Referenced by fillElectronCandidates().

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

Referenced by calcElectronCandidates().

337  {
338  unsigned short cardinals[4] = {northEt,southEt,eastEt,westEt};
339  unsigned short max = 0;
340  for(int i = 0; i<4;i++){
341  unsigned short test = primaryEt+cardinals[i];
342  if(test > max)
343  max = test;
344  }
345  return max;
346 }
int i
Definition: DBlmapReader.cc:9
int L1RCTElectronIsolationCard::cardNumber ( )
inline

Definition at line 29 of file L1RCTElectronIsolationCard.h.

References cardNo.

Referenced by calcElectronCandidates().

29 {return cardNo;}
int L1RCTElectronIsolationCard::crateNumber ( )
inline

Definition at line 28 of file L1RCTElectronIsolationCard.h.

References crtNo.

Referenced by calcElectronCandidates().

28 {return crtNo;}
void L1RCTElectronIsolationCard::fillElectronCandidates ( )

Definition at line 25 of file L1RCTElectronIsolationCard.cc.

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

25  {
26  std::vector<unsigned short> region0Electrons = calcElectronCandidates(regions.at(0),0);
27  std::vector<unsigned short> region1Electrons = calcElectronCandidates(regions.at(1),1);
28  isoElectrons.at(0) = region0Electrons.at(0);
29  isoElectrons.at(1) = region1Electrons.at(0);
30  nonIsoElectrons.at(0) = region0Electrons.at(1);
31  nonIsoElectrons.at(1) = region1Electrons.at(1);
32 
33 
34 }
std::vector< L1RCTRegion > regions
std::vector< unsigned short > nonIsoElectrons
std::vector< unsigned short > isoElectrons
std::vector< unsigned short > calcElectronCandidates(const L1RCTRegion &region, int regionNum)
unsigned short L1RCTElectronIsolationCard::getIsoElectrons ( int  i)
inline

Definition at line 37 of file L1RCTElectronIsolationCard.h.

References isoElectrons.

37  {
38  return isoElectrons.at(i);
39  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned short > isoElectrons
unsigned short L1RCTElectronIsolationCard::getNonIsoElectrons ( int  i)
inline

Definition at line 41 of file L1RCTElectronIsolationCard.h.

References nonIsoElectrons.

41  {
42  return nonIsoElectrons.at(i);
43  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned short > nonIsoElectrons
void L1RCTElectronIsolationCard::print ( void  )

Definition at line 348 of file L1RCTElectronIsolationCard.cc.

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

348  {
349  std::cout << "Electron isolation card " << cardNo << std::endl;
350  std::cout << "Region 0 Information" << std::endl;
351  regions.at(0).print();
352 
353  std::cout << "IsoElectron Candidate " << isoElectrons.at(0) << std::endl;
354  std::cout << "NonIsoElectron Candidate " << nonIsoElectrons.at(0) << std::endl << std::endl;
355 
356  std::cout << "Region 1 Information" << std::endl;
357  regions.at(1).print();
358 
359  std::cout << "IsoElectron Candidate " << isoElectrons.at(1) << std::endl;
360  std::cout << "NonIsoElectron Candidate " << nonIsoElectrons.at(1) << std::endl;
361 }
std::vector< L1RCTRegion > regions
std::vector< unsigned short > nonIsoElectrons
std::vector< unsigned short > isoElectrons
tuple cout
Definition: gather_cfg.py:121
void L1RCTElectronIsolationCard::printEdges ( )
inline

Definition at line 45 of file L1RCTElectronIsolationCard.h.

References regions.

45  {
46  regions.at(0).printEdges();
47  regions.at(1).printEdges();
48  }
std::vector< L1RCTRegion > regions
void L1RCTElectronIsolationCard::setRegion ( int  i,
const L1RCTRegion region 
)
inline

Definition at line 32 of file L1RCTElectronIsolationCard.h.

References HLT_50nsGRun_cff::region, and regions.

32  {
33  regions.at(i) = region;
34  }
int i
Definition: DBlmapReader.cc:9
std::vector< L1RCTRegion > regions

Member Data Documentation

unsigned short L1RCTElectronIsolationCard::cardNo
private

Definition at line 57 of file L1RCTElectronIsolationCard.h.

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

unsigned short L1RCTElectronIsolationCard::crtNo
private

Definition at line 56 of file L1RCTElectronIsolationCard.h.

Referenced by crateNumber().

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

Definition at line 63 of file L1RCTElectronIsolationCard.h.

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

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

Definition at line 64 of file L1RCTElectronIsolationCard.h.

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

const L1RCTLookupTables* L1RCTElectronIsolationCard::rctLookupTables_
private

Definition at line 59 of file L1RCTElectronIsolationCard.h.

Referenced by calcElectronCandidates().

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