CMS 3D CMS Logo

L1RCTORCAMap.cc
Go to the documentation of this file.
2 
3 #include <vector>
4 using std::vector;
5 
7  rawEMET = std::vector<unsigned short>(56 * 72);
8  rawHDET = std::vector<unsigned short>(56 * 72);
9  rawEMFG = std::vector<unsigned short>(56 * 72);
10  rawHDFG = std::vector<unsigned short>(56 * 72);
11  rawHFET = std::vector<unsigned short>(8 * 18);
12  combEM = std::vector<unsigned short>(56 * 72);
13  combHD = std::vector<unsigned short>(56 * 72);
14 
15  barrelData = std::vector<std::vector<std::vector<unsigned short>>>(
16  18, std::vector<std::vector<unsigned short>>(7, std::vector<unsigned short>(64)));
17  hfData = std::vector<std::vector<unsigned short>>(18, std::vector<unsigned short>(8));
18 }
19 vector<std::vector<std::vector<unsigned short>>> L1RCTORCAMap::giveBarrel() { return barrelData; }
20 
21 vector<std::vector<unsigned short>> L1RCTORCAMap::giveHF() { return hfData; }
23  std::vector<unsigned short> crate(16);
24  for (int i = 0; i < 9; i++) {
25  for (int j = 0; j < 16; j++) {
26  crate.at(j) = rawHFET.at(16 * i + j);
27  }
28  hfData.at(i) = crate;
29  }
30 }
31 
33  std::vector<int> indices;
34  for (int phi = 0; phi < 72; phi++) {
35  for (int eta = 0; eta < 56; eta++) {
36  indices = orcamap(eta, phi);
37  (barrelData.at(indices.at(0))).at(indices.at(1)).at(indices.at(2)) = combEM.at(phi * 56 + eta);
38  (barrelData.at(indices.at(0))).at(indices.at(1)).at(indices.at(2) + 32) = combHD.at(phi * 56 + eta);
39  }
40  }
41 }
42 
43 void L1RCTORCAMap::readData(const std::vector<unsigned> &emet,
44  const std::vector<unsigned> &hdet,
45  const std::vector<bool> &emfg,
46  const std::vector<bool> &hdfg,
47  const std::vector<unsigned> &hfet) {
48  for (int i = 0; i < 4032; i++) {
49  rawEMET.at(i) = emet.at(i);
50  rawHDET.at(i) = hdet.at(i);
51  rawEMFG.at(i) = emfg.at(i);
52  rawHDFG.at(i) = hdfg.at(i);
53  }
54  for (int i = 0; i < 144; i++)
55  rawHFET.at(i) = hfet.at(i);
56 
59 
61  makeHFData();
62 }
63 
64 unsigned short L1RCTORCAMap::combine(unsigned short et, unsigned short fg) {
65  unsigned short newfg = fg << 8;
66  return newfg + et;
67 }
68 
69 vector<unsigned short> L1RCTORCAMap::combVec(const std::vector<unsigned short> &et,
70  const std::vector<unsigned short> &fg) {
71  std::vector<unsigned short> comb(56 * 72);
72  for (int i = 0; i < (int)et.size(); i++)
73  comb.at(i) = combine(et.at(i), fg.at(i));
74  return comb;
75 }
76 
77 vector<int> L1RCTORCAMap::orcamap(int eta, int phi) {
78  int crateNum(20);
79  std::vector<int> cardTower(2, 0);
80  std::vector<int> returnVec(3, 0);
81  int modEta = eta % 28;
82  int modPhi = phi % 8;
83  if (phi < 8)
84  crateNum = 0;
85  else if (phi < 16)
86  crateNum = 1;
87  else if (phi < 24)
88  crateNum = 2;
89  else if (phi < 32)
90  crateNum = 3;
91  else if (phi < 40)
92  crateNum = 4;
93  else if (phi < 48)
94  crateNum = 5;
95  else if (phi < 56)
96  crateNum = 6;
97  else if (phi < 64)
98  crateNum = 7;
99  else if (phi < 72)
100  crateNum = 8;
101 
102  if (eta < 28)
103  cardTower = lowEtaMap(modEta, modPhi);
104  else {
105  cardTower = highEtaMap(modEta, modPhi);
106  crateNum = crateNum + 9;
107  }
108 
109  returnVec.at(0) = crateNum;
110  for (int i = 0; i < 2; i++) {
111  returnVec.at(i + 1) = cardTower.at(i);
112  }
113  return returnVec;
114 }
115 
116 vector<int> L1RCTORCAMap::lowEtaMap(int eta, int phi) {
117  int cardnum = 0;
118  int towernum = 0;
119  std::vector<int> returnVec(2);
120  if (eta < 4) {
121  cardnum = 6;
122  if (phi < 4)
123  towernum = (3 - eta) * 4 + phi;
124  else
125  towernum = eta * 4 + phi + 12;
126  } else if (eta < 12) {
127  if (phi < 4) {
128  cardnum = 4;
129  if (eta < 8)
130  towernum = (7 - eta) * 4 + phi + 16;
131  else
132  towernum = (11 - eta) * 4 + phi;
133  } else {
134  cardnum = 5;
135  if (eta < 8)
136  towernum = (7 - eta) * 4 + (phi - 4) + 16;
137  else
138  towernum = (11 - eta) * 4 + (phi - 4);
139  }
140  } else if (eta < 20) {
141  if (phi < 4) {
142  cardnum = 2;
143  if (eta < 16)
144  towernum = (15 - eta) * 4 + phi + 16;
145  else
146  towernum = (19 - eta) * 4 + phi;
147  } else {
148  cardnum = 3;
149  if (eta < 16)
150  towernum = (15 - eta) * 4 + (phi - 4) + 16;
151  else
152  towernum = (19 - eta) * 4 + (phi - 4);
153  }
154  } else if (eta < 28) {
155  if (phi < 4) {
156  cardnum = 0;
157  if (eta < 24)
158  towernum = (23 - eta) * 4 + phi + 16;
159  else
160  towernum = (27 - eta) * 4 + phi;
161  } else {
162  cardnum = 1;
163  if (eta < 24)
164  towernum = (23 - eta) * 4 + (phi - 4) + 16;
165  else
166  towernum = (27 - eta) * 4 + (phi - 4);
167  }
168  }
169 
170  returnVec.at(0) = cardnum;
171  returnVec.at(1) = towernum;
172  return returnVec;
173 }
174 
175 vector<int> L1RCTORCAMap::highEtaMap(int eta, int phi) {
176  int cardnum;
177  int towernum;
178  std::vector<int> returnVec(2);
179  if (eta < 8) {
180  if (phi < 4) {
181  cardnum = 0;
182  towernum = eta * 4 + phi;
183  } else {
184  cardnum = 1;
185  towernum = eta * 4 + (phi - 4);
186  }
187  } else if (eta < 16) {
188  if (phi < 4) {
189  cardnum = 2;
190  towernum = (eta - 8) * 4 + phi;
191  } else {
192  cardnum = 3;
193  towernum = (eta - 8) * 4 + (phi - 4);
194  }
195  } else if (eta < 24) {
196  if (phi < 4) {
197  cardnum = 4;
198  towernum = (eta - 16) * 4 + phi;
199  } else {
200  cardnum = 5;
201  towernum = (eta - 16) * 4 + (phi - 4);
202  }
203  } else {
204  cardnum = 6;
205  if (phi < 4)
206  towernum = (27 - eta) * 4 + phi;
207  else
208  towernum = (27 - eta) * 4 + phi + 12;
209  }
210 
211  returnVec.at(0) = cardnum;
212  returnVec.at(1) = towernum;
213  return returnVec;
214 }
std::vector< std::vector< std::vector< unsigned short > > > barrelData
Definition: L1RCTORCAMap.h:28
std::vector< std::vector< unsigned short > > giveHF()
Definition: L1RCTORCAMap.cc:21
std::vector< unsigned short > combHD
Definition: L1RCTORCAMap.h:45
std::vector< int > highEtaMap(int eta, int phi)
unsigned short combine(unsigned short et, unsigned short fg)
Definition: L1RCTORCAMap.cc:64
void makeBarrelData()
Definition: L1RCTORCAMap.cc:32
std::vector< unsigned short > rawHDFG
Definition: L1RCTORCAMap.h:42
std::vector< std::vector< unsigned short > > hfData
Definition: L1RCTORCAMap.h:29
std::vector< int > orcamap(int eta, int phi)
Definition: L1RCTORCAMap.cc:77
std::vector< unsigned short > combEM
Definition: L1RCTORCAMap.h:44
std::vector< int > lowEtaMap(int eta, int phi)
std::vector< unsigned short > rawEMFG
Definition: L1RCTORCAMap.h:40
std::vector< unsigned short > combVec(const std::vector< unsigned short > &et, const std::vector< unsigned short > &fg)
Definition: L1RCTORCAMap.cc:69
std::vector< unsigned short > rawHFET
Definition: L1RCTORCAMap.h:43
std::vector< unsigned short > rawEMET
Definition: L1RCTORCAMap.h:39
std::vector< unsigned short > rawHDET
Definition: L1RCTORCAMap.h:41
std::vector< std::vector< std::vector< unsigned short > > > giveBarrel()
Definition: L1RCTORCAMap.cc:19
void makeHFData()
Definition: L1RCTORCAMap.cc:22
void readData(const std::vector< unsigned > &emet, const std::vector< unsigned > &hdet, const std::vector< bool > &emfg, const std::vector< bool > &hdfg, const std::vector< unsigned > &hfet)
Definition: L1RCTORCAMap.cc:43