CMS 3D CMS Logo

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