CMS 3D CMS Logo

L1RCTRegion.cc
Go to the documentation of this file.
2 
3 #include <vector>
4 using std::vector;
5 
6 #include <iostream>
7 using std::cerr;
8 using std::cout;
9 using std::endl;
10 
12  : totalRegionEt(36), totalRegionHE_FG(36), etIn9Bits(16), muonBit(16),
13  activityBit(16) {}
14 
16 
17 // So the whole point of the following two functions is that they provide
18 // an interface to the "real" 4x4 region 7 bit energies and h/e||fg bits
19 // that are used in electron finding.
20 // Now, you actually *can* give them arguments ranging from -1 to 4
21 // representing the outer neighbors.
22 // This is actually quite helpful and allows you to write the electronfinding
23 // algorithm in the same form no matter what tower you're centered on.
24 //
25 // As a reminder i is row and j is column, just like matrices.
26 // row -1 is the northern neighbors and column -1 is the western neighbors
27 unsigned short L1RCTRegion::getEtIn7Bits(int i, int j) const {
28  // i & j run 0-3
29  return totalRegionEt.at(6 * (i + 1) + j + 1);
30 }
31 
32 void L1RCTRegion::setEtIn7Bits(int i, int j, unsigned short energy) {
33  // i & j should be 0-3
34  if (energy <= 127)
35  totalRegionEt.at(6 * (i + 1) + j + 1) = energy;
36  else
37  totalRegionEt.at(6 * (i + 1) + j + 1) = 127;
38 }
39 
40 unsigned short L1RCTRegion::getHE_FGBit(int i, int j) const {
41  return totalRegionHE_FG.at(6 * (i + 1) + j + 1);
42 }
43 
44 void L1RCTRegion::setHE_FGBit(int i, int j, unsigned short HE_FG) {
45  totalRegionHE_FG.at(6 * (i + 1) + j + 1) = HE_FG;
46 }
47 
48 // The rest of the data stored in a region only works if i and j are
49 // in the 0-3 range. The arrays truly are 4x4 and will signal an error
50 // if misused thanks to the vector function .at
51 unsigned short L1RCTRegion::getEtIn9Bits(int i, int j) const {
52  return etIn9Bits.at(4 * i + j);
53 }
54 
55 void L1RCTRegion::setEtIn9Bits(int i, int j, unsigned short energy) {
56  if (energy <= 511)
57  etIn9Bits.at(4 * i + j) = energy;
58  else
59  etIn9Bits.at(4 * i + j) = 511;
60 }
61 
62 unsigned short L1RCTRegion::getMuonBit(int i, int j) const {
63  return muonBit.at(4 * i + j);
64 }
65 
66 void L1RCTRegion::setMuonBit(int i, int j, unsigned short muon) {
67  muonBit.at(4 * i + j) = muon;
68 }
69 
70 void L1RCTRegion::setActivityBit(int i, int j, unsigned short activity) {
71  activityBit.at(4 * i + j) = activity;
72 }
73 
74 unsigned short L1RCTRegion::getActivityBit(int i, int j) const {
75  return activityBit.at(4 * i + j);
76 }
77 
78 // The following list of give and set functions are the core
79 // of the work for neighbor sharing swept under the rug.
80 // Basically, the way it works is that "give" methods return
81 // what would be the appropriate neighbor information so that you can
82 // use the set methods on the other region in order to set the neighbor
83 // information. For example, r0:crate 0 card 0 region 0 is the northern
84 // neighbor of r1:crate 0 card 1 region 0. Then to set the northern
85 // neighbor information you call r1.setNorthEt(r0.getNorthEt())
86 // That's why it's give insted of get. It doesn't return the region's
87 // northern neighbor information, it returns what would be its southern
88 // neighbor's northern neighbor information.
89 vector<unsigned short> L1RCTRegion::giveNorthEt() const {
90  std::vector<unsigned short> north(4);
91  for (int i = 0; i < 4; i++)
92  north.at(i) = getEtIn7Bits(3, i);
93  return north;
94 }
95 void L1RCTRegion::setNorthEt(const std::vector<unsigned short> &north) {
96  for (int i = 0; i < 4; i++)
97  totalRegionEt.at(i + 1) = north.at(i);
98 }
99 vector<unsigned short> L1RCTRegion::giveNorthHE_FG() const {
100  std::vector<unsigned short> north(4);
101  for (int i = 0; i < 4; i++)
102  north.at(i) = getHE_FGBit(3, i);
103  return north;
104 }
105 void L1RCTRegion::setNorthHE_FG(const std::vector<unsigned short> &north) {
106  for (int i = 0; i < 4; i++)
107  totalRegionHE_FG.at(i + 1) = north.at(i);
108 }
109 
110 vector<unsigned short> L1RCTRegion::giveSouthEt() const {
111  std::vector<unsigned short> south(4);
112  for (int i = 0; i < 4; i++)
113  south.at(i) = getEtIn7Bits(0, i);
114  return south;
115 }
116 void L1RCTRegion::setSouthEt(const std::vector<unsigned short> &south) {
117  for (int i = 0; i < 4; i++)
118  totalRegionEt.at(31 + i) = south.at(i);
119 }
120 
121 vector<unsigned short> L1RCTRegion::giveSouthHE_FG() const {
122  std::vector<unsigned short> south(4);
123  for (int i = 0; i < 4; i++)
124  south.at(i) = getHE_FGBit(0, i);
125  return south;
126 }
127 void L1RCTRegion::setSouthHE_FG(const std::vector<unsigned short> &south) {
128  for (int i = 0; i < 4; i++)
129  totalRegionHE_FG.at(31 + i) = south.at(i);
130 }
131 
132 vector<unsigned short> L1RCTRegion::giveWestEt() const {
133  std::vector<unsigned short> west(4);
134  for (int i = 0; i < 4; i++)
135  west.at(i) = getEtIn7Bits(i, 3);
136  return west;
137 }
138 void L1RCTRegion::setWestEt(const std::vector<unsigned short> &west) {
139  for (int i = 0; i < 4; i++)
140  totalRegionEt.at(6 * (i + 1)) = west.at(i);
141 }
142 
143 vector<unsigned short> L1RCTRegion::giveWestHE_FG() const {
144  std::vector<unsigned short> west(4);
145  for (int i = 0; i < 4; i++)
146  west.at(i) = getHE_FGBit(i, 3);
147  return west;
148 }
149 void L1RCTRegion::setWestHE_FG(const std::vector<unsigned short> &west) {
150  for (int i = 0; i < 4; i++)
151  totalRegionHE_FG.at(6 * (i + 1)) = west.at(i);
152 }
153 
154 vector<unsigned short> L1RCTRegion::giveEastEt() const {
155  std::vector<unsigned short> east(4);
156  for (int i = 0; i < 4; i++)
157  east.at(i) = getEtIn7Bits(i, 0);
158  return east;
159 }
160 void L1RCTRegion::setEastEt(const std::vector<unsigned short> &east) {
161  for (int i = 0; i < 4; i++)
162  totalRegionEt.at(6 * (i + 1) + 5) = east.at(i);
163 }
164 
165 vector<unsigned short> L1RCTRegion::giveEastHE_FG() const {
166  std::vector<unsigned short> east(4);
167  for (int i = 0; i < 4; i++)
168  east.at(i) = getHE_FGBit(i, 0);
169  return east;
170 }
171 void L1RCTRegion::setEastHE_FG(const std::vector<unsigned short> &east) {
172  for (int i = 0; i < 4; i++)
173  totalRegionHE_FG.at(6 * (i + 1) + 5) = east.at(i);
174 }
175 
176 unsigned short L1RCTRegion::giveNEEt() const {
177  unsigned short et = getEtIn7Bits(3, 0);
178  if (et > 7)
179  return 7;
180  else
181  return et;
182 }
183 unsigned short L1RCTRegion::giveNEHE_FG() const { return getHE_FGBit(3, 0); }
184 void L1RCTRegion::setNEEt(unsigned short ne) { totalRegionEt.at(5) = ne; }
185 void L1RCTRegion::setNEHE_FG(unsigned short ne) { totalRegionHE_FG.at(5) = ne; }
186 
187 unsigned short L1RCTRegion::giveNWEt() const {
188  unsigned short et = getEtIn7Bits(3, 3);
189  if (et > 7)
190  return 7;
191  else
192  return et;
193 }
194 unsigned short L1RCTRegion::giveNWHE_FG() const { return getHE_FGBit(3, 3); }
195 void L1RCTRegion::setNWEt(unsigned short nw) { totalRegionEt.at(0) = nw; }
196 void L1RCTRegion::setNWHE_FG(unsigned short nw) { totalRegionHE_FG.at(0) = nw; }
197 
198 unsigned short L1RCTRegion::giveSWEt() const {
199  unsigned short et = getEtIn7Bits(0, 3);
200  if (et > 7)
201  return 7;
202  else
203  return et;
204 }
205 unsigned short L1RCTRegion::giveSWHE_FG() const { return getHE_FGBit(0, 3); }
206 void L1RCTRegion::setSWEt(unsigned short sw) { totalRegionEt.at(30) = sw; }
207 void L1RCTRegion::setSWHE_FG(unsigned short sw) {
208  totalRegionHE_FG.at(30) = sw;
209 }
210 
211 unsigned short L1RCTRegion::giveSEEt() const {
212  unsigned short et = getEtIn7Bits(0, 0);
213  if (et > 7)
214  return 7;
215  else
216  return et;
217 }
218 unsigned short L1RCTRegion::giveSEHE_FG() const { return getHE_FGBit(0, 0); }
219 void L1RCTRegion::setSEEt(unsigned short se) { totalRegionEt.at(35) = se; }
220 void L1RCTRegion::setSEHE_FG(unsigned short se) {
221  totalRegionHE_FG.at(35) = se;
222 }
223 
225 
226  std::cout << " 7 Bit Energies ";
227  for (int i = 0; i < 4; i++) {
228  std::cout << std::endl;
229  for (int j = 0; j < 4; j++) {
230  std::cout << " " << getEtIn7Bits(i, j) << " ";
231  }
232  }
233 
234  std::cout << std::endl << std::endl;
235  std::cout << " 9 Bit Energies ";
236  for (int i = 0; i < 4; i++) {
237  std::cout << std::endl;
238  for (int j = 0; j < 4; j++) {
239  std::cout << " " << getEtIn9Bits(i, j) << " ";
240  }
241  }
242 
243  std::cout << std::endl << std::endl;
244  std::cout << " HE || FG bit ";
245  for (int i = 0; i < 4; i++) {
246  std::cout << std::endl;
247  for (int j = 0; j < 4; j++) {
248  std::cout << " " << getHE_FGBit(i, j) << " ";
249  }
250  }
251 
252  std::cout << std::endl << std::endl;
253  std::cout << " Muon Bit ";
254  for (int i = 0; i < 4; i++) {
255  std::cout << std::endl;
256  for (int j = 0; j < 4; j++) {
257  std::cout << " " << getMuonBit(i, j) << " ";
258  }
259  }
260  std::cout << std::endl;
261 }
262 
264  std::cout << "North" << std::endl;
265  for (int i = 0; i < 4; i++)
266  std::cout << totalRegionEt.at(i + 1) << std::endl;
267 
268  std::cout << "West" << std::endl;
269  for (int i = 0; i < 4; i++)
270  std::cout << totalRegionEt.at(6 * (i + 1)) << std::endl;
271 
272  std::cout << "East" << std::endl;
273  for (int i = 0; i < 4; i++)
274  std::cout << totalRegionEt.at(6 * (i + 1) + 5) << std::endl;
275 
276  std::cout << "South" << std::endl;
277  for (int i = 0; i < 4; i++)
278  std::cout << totalRegionEt.at(31 + i) << std::endl;
279 
280  std::cout << "NE " << totalRegionEt.at(5) << std::endl;
281  std::cout << "SE " << totalRegionEt.at(35) << std::endl;
282  std::cout << "NW " << totalRegionEt.at(0) << std::endl;
283  std::cout << "SW " << totalRegionEt.at(30) << std::endl;
284 }
void setNEEt(unsigned short ne)
Definition: L1RCTRegion.cc:184
std::vector< unsigned short > giveSouthHE_FG() const
Definition: L1RCTRegion.cc:121
void setSWHE_FG(unsigned short sw)
Definition: L1RCTRegion.cc:207
std::vector< unsigned short > activityBit
Definition: L1RCTRegion.h:72
std::vector< unsigned short > giveWestEt() const
Definition: L1RCTRegion.cc:132
void setNEHE_FG(unsigned short ne)
Definition: L1RCTRegion.cc:185
void setNorthHE_FG(const std::vector< unsigned short > &north)
Definition: L1RCTRegion.cc:105
std::vector< unsigned short > totalRegionEt
Definition: L1RCTRegion.h:66
unsigned short getEtIn7Bits(int i, int j) const
Definition: L1RCTRegion.cc:27
void setHE_FGBit(int i, int j, unsigned short HE_FG)
Definition: L1RCTRegion.cc:44
std::vector< unsigned short > giveEastHE_FG() const
Definition: L1RCTRegion.cc:165
void setNWHE_FG(unsigned short nw)
Definition: L1RCTRegion.cc:196
std::vector< unsigned short > giveWestHE_FG() const
Definition: L1RCTRegion.cc:143
unsigned short getEtIn9Bits(int i, int j) const
Definition: L1RCTRegion.cc:51
void setWestHE_FG(const std::vector< unsigned short > &west)
Definition: L1RCTRegion.cc:149
unsigned short getMuonBit(int i, int j) const
Definition: L1RCTRegion.cc:62
void setSEEt(unsigned short se)
Definition: L1RCTRegion.cc:219
unsigned short giveNEHE_FG() const
Definition: L1RCTRegion.cc:183
unsigned short getActivityBit(int i, int j) const
Definition: L1RCTRegion.cc:74
unsigned short getHE_FGBit(int i, int j) const
Definition: L1RCTRegion.cc:40
unsigned short giveSEHE_FG() const
Definition: L1RCTRegion.cc:218
unsigned short giveSWEt() const
Definition: L1RCTRegion.cc:198
unsigned short giveSEEt() const
Definition: L1RCTRegion.cc:211
void setSWEt(unsigned short sw)
Definition: L1RCTRegion.cc:206
void setSouthHE_FG(const std::vector< unsigned short > &south)
Definition: L1RCTRegion.cc:127
void setNorthEt(const std::vector< unsigned short > &north)
Definition: L1RCTRegion.cc:95
std::vector< unsigned short > giveNorthEt() const
Definition: L1RCTRegion.cc:89
void setSEHE_FG(unsigned short se)
Definition: L1RCTRegion.cc:220
void setWestEt(const std::vector< unsigned short > &west)
Definition: L1RCTRegion.cc:138
void print()
Definition: L1RCTRegion.cc:224
void setEtIn9Bits(int i, int j, unsigned short energy)
Definition: L1RCTRegion.cc:55
et
define resolution functions of each parameter
std::vector< unsigned short > etIn9Bits
Definition: L1RCTRegion.h:69
void setEastHE_FG(const std::vector< unsigned short > &east)
Definition: L1RCTRegion.cc:171
std::vector< unsigned short > muonBit
Definition: L1RCTRegion.h:71
void setEastEt(const std::vector< unsigned short > &east)
Definition: L1RCTRegion.cc:160
unsigned short giveNWHE_FG() const
Definition: L1RCTRegion.cc:194
void setNWEt(unsigned short nw)
Definition: L1RCTRegion.cc:195
std::vector< unsigned short > giveEastEt() const
Definition: L1RCTRegion.cc:154
void setSouthEt(const std::vector< unsigned short > &south)
Definition: L1RCTRegion.cc:116
unsigned short giveSWHE_FG() const
Definition: L1RCTRegion.cc:205
void setEtIn7Bits(int i, int j, unsigned short energy)
Definition: L1RCTRegion.cc:32
void setActivityBit(int i, int j, unsigned short activity)
Definition: L1RCTRegion.cc:70
std::vector< unsigned short > totalRegionHE_FG
Definition: L1RCTRegion.h:67
void setMuonBit(int i, int j, unsigned short muon)
Definition: L1RCTRegion.cc:66
unsigned short giveNEEt() const
Definition: L1RCTRegion.cc:176
void printEdges()
Definition: L1RCTRegion.cc:263
std::vector< unsigned short > giveNorthHE_FG() const
Definition: L1RCTRegion.cc:99
unsigned short giveNWEt() const
Definition: L1RCTRegion.cc:187
std::vector< unsigned short > giveSouthEt() const
Definition: L1RCTRegion.cc:110