CMS 3D CMS Logo

PtAssignmentEngineAux2017.cc
Go to the documentation of this file.
3 #include <iostream>
4 #include <cassert>
5 #include <cmath>
6 
7 // From here down, exact copy of code used for training BDT: EMTFPtAssign2017/src/PtLUTVarCalc.cc
8 
9 
10 // Arrays that map the integer dPhi --> dPhi-units. 1/60th of a degree per unit; 255 units --> 4.25 degrees, 511 --> 8.52 degrees
11 
12 // 256 max units----
13 // For use in dPhi34 in mode 15. Derived manually from dPhiNLBMap_5bit_256Max for now; should generate algorithmically. - AWB 17.03.17
14 static const int dPhiNLBMap_4bit_256Max[16] = {0, 1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 25, 31, 46, 68, 136};
15 
16 // For use in dPhi23, dPhi24, and dPhi34 in 3- and 4-station modes (7, 11, 13, 14, 15), except for dPhi23 in mode 7 and dPhi34 in mode 15
17 static const int dPhiNLBMap_5bit_256Max[32] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
18  16, 17, 19, 20, 21, 23, 25, 28, 31, 34, 39, 46, 55, 68, 91, 136};
19 // 512 max units----
20 // For use in all dPhiAB (where "A" and "B" are the first two stations in the track) in all modes
21 static const int dPhiNLBMap_7bit_512Max[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
22  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
23  32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
24  48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
25  64, 65, 66, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81,
26  83, 84, 86, 87, 89, 91, 92, 94, 96, 98, 100, 102, 105, 107, 110, 112,
27  115, 118, 121, 124, 127, 131, 135, 138, 143, 147, 152, 157, 162, 168, 174, 181,
28  188, 196, 204, 214, 224, 235, 247, 261, 276, 294, 313, 336, 361, 391, 427, 470};
29 
30 
31 int PtAssignmentEngineAux2017::getNLBdPhi(int dPhi, int bits, int max) const {
32  if (not( (bits == 4 && max == 256) ||
33  (bits == 5 && max == 256) ||
34  (bits == 7 && max == 512) ))
35  { edm::LogError("L1T") << "bits = " << bits << ", max = " << max; return 0; }
36 
37  int dPhi_ = max;
38  int sign_ = 1;
39  if (dPhi < 0)
40  sign_ = -1;
41  dPhi = sign_ * dPhi;
42 
43  if (max == 256) {
44  if (bits == 4) {
45  dPhi_ = dPhiNLBMap_4bit_256Max[(1 << bits) - 1];
46  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
47  if (dPhiNLBMap_4bit_256Max[edge] <= dPhi &&
48  dPhiNLBMap_4bit_256Max[edge+1] > dPhi) {
49  dPhi_ = dPhiNLBMap_4bit_256Max[edge];
50  break;
51  }
52  }
53  } // End conditional: if (bits == 4)
54  if (bits == 5) {
55  dPhi_ = dPhiNLBMap_5bit_256Max[(1 << bits) - 1];
56  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
57  if (dPhiNLBMap_5bit_256Max[edge] <= dPhi &&
58  dPhiNLBMap_5bit_256Max[edge+1] > dPhi) {
59  dPhi_ = dPhiNLBMap_5bit_256Max[edge];
60  break;
61  }
62  }
63  } // End conditional: if (bits == 5)
64  } // End conditional: if (max == 256)
65 
66  else if (max == 512) {
67  if (bits == 7) {
68  dPhi_ = dPhiNLBMap_7bit_512Max[(1 << bits) - 1];
69  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
70  if (dPhiNLBMap_7bit_512Max[edge] <= dPhi &&
71  dPhiNLBMap_7bit_512Max[edge+1] > dPhi) {
72  dPhi_ = dPhiNLBMap_7bit_512Max[edge];
73  break;
74  }
75  }
76  } // End conditional: if (bits == 7)
77  } // End conditional: else if (max == 512)
78 
79  if (not( abs(sign_) == 1 && dPhi_ >= 0 && dPhi_ < max))
80  { edm::LogError("L1T") << "sign_ = " << sign_ << ", dPhi_ = " << dPhi_ << ", max = " << max; return 0; }
81  return (sign_ * dPhi_);
82 } // End function: nt PtAssignmentEngineAux2017::getNLBdPhi()
83 
84 
85 int PtAssignmentEngineAux2017::getNLBdPhiBin(int dPhi, int bits, int max) const {
86  if (not( (bits == 4 && max == 256) ||
87  (bits == 5 && max == 256) ||
88  (bits == 7 && max == 512) ))
89  { edm::LogError("L1T") << "bits = " << bits << ", max = " << max; return 0; }
90 
91  int dPhiBin_ = (1 << bits) - 1;
92  int sign_ = 1;
93  if (dPhi < 0)
94  sign_ = -1;
95  dPhi = sign_ * dPhi;
96 
97  if (max == 256) {
98  if (bits == 4) {
99  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
100  if (dPhiNLBMap_4bit_256Max[edge] <= dPhi &&
101  dPhiNLBMap_4bit_256Max[edge+1] > dPhi) {
102  dPhiBin_ = edge;
103  break;
104  }
105  }
106  } // End conditional: if (bits == 4)
107  if (bits == 5) {
108  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
109  if (dPhiNLBMap_5bit_256Max[edge] <= dPhi &&
110  dPhiNLBMap_5bit_256Max[edge+1] > dPhi) {
111  dPhiBin_ = edge;
112  break;
113  }
114  }
115  } // End conditional: if (bits == 5)
116  } // End conditional: if (max == 256)
117 
118  else if (max == 512) {
119  if (bits == 7) {
120  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
121  if (dPhiNLBMap_7bit_512Max[edge] <= dPhi &&
122  dPhiNLBMap_7bit_512Max[edge+1] > dPhi) {
123  dPhiBin_ = edge;
124  break;
125  }
126  }
127  } // End conditional: if (bits == 7)
128  } // End conditional: else if (max == 512)
129 
130  if (not(dPhiBin_ >= 0 && dPhiBin_ < pow(2, bits)))
131  { edm::LogError("L1T") << "dPhiBin_ = " << dPhiBin_ << ", bits = " << bits; return 0; }
132  return (dPhiBin_);
133 } // End function: int PtAssignmentEngineAux2017::getNLBdPhiBin()
134 
135 
137  if (not( (bits == 4 && max == 256) ||
138  (bits == 5 && max == 256) ||
139  (bits == 7 && max == 512) ))
140  { edm::LogError("L1T") << "bits = " << bits << ", max = " << max; return 0; }
141 
142  int dPhi_ = (1 << bits) - 1;
143 
144  if (dPhiBin > (1 << bits) - 1)
145  dPhiBin = (1 << bits) - 1;
146 
147  if (max == 256) {
148  if (bits == 4)
150  if (bits == 5)
152  } // End conditional: if (max == 256)
153 
154  else if (max == 512) {
155  if (bits == 7)
157  } // End conditional: else if (max == 512)
158 
159  if (not(dPhi_ >= 0 && dPhi_ < max))
160  { edm::LogError("L1T") << "dPhi_ = " << dPhi_ << ", max = " << max; return 0; }
161  return (dPhi_);
162 } // End function: int PtAssignmentEngineAux2017::getdPhiFromBin()
163 
164 
165 int PtAssignmentEngineAux2017::getCLCT(int clct, int endcap, int dPhiSign, int bits) const {
166 
167  // std::cout << "Inside getCLCT: clct = " << clct << ", endcap = " << endcap
168  // << ", dPhiSign = " << dPhiSign << ", bits = " << bits << std::endl;
169 
170  if (not( clct >= 0 && clct <= 10 && abs(endcap) == 1 &&
171  abs(dPhiSign) == 1 && (bits == 2 || bits == 3) ))
172  { edm::LogError("L1T") << "clct = " << clct << ", endcap = " << endcap
173  << ", dPhiSign = " << dPhiSign << ", bits = " << bits; return 0; }
174 
175  // Convention here: endcap == +/-1, dPhiSign = +/-1.
176  int clct_ = 0;
177  int sign_ = -1 * endcap * dPhiSign; // CLCT bend is with dPhi in ME-, opposite in ME+
178 
179  // CLCT pattern can be converted into |bend| x sign as follows:
180  // |bend| = (10 + (pattern % 2) - pattern) / 2
181  // * 10 --> 0, 9/8 --> 1, 7/6 --> 2, 5/4 --> 3, 3/2 --> 4, 0 indicates RPC hit
182  // sign = ((pattern % 2) == 1 ? -1 : 1) * (endcap == 1 ? -1 : 1)
183  // * In ME+, even CLCTs have negative sign, odd CLCTs have positive
184 
185  // For use in all 3- and 4-station modes (7, 11, 13, 14, 15)
186  // Bends [-4, -3, -2] --> 0, [-1, 0] --> 1, [+1] --> 2, [+2, +3, +4] --> 3
187  if (bits == 2) {
188  switch (clct) {
189  case 10: clct_ = 1; break;
190  case 9: clct_ = (sign_ > 0 ? 1 : 2); break;
191  case 8: clct_ = (sign_ > 0 ? 2 : 1); break;
192  case 7: clct_ = (sign_ > 0 ? 0 : 3); break;
193  case 6: clct_ = (sign_ > 0 ? 3 : 0); break;
194  case 5: clct_ = (sign_ > 0 ? 0 : 3); break;
195  case 4: clct_ = (sign_ > 0 ? 3 : 0); break;
196  case 3: clct_ = (sign_ > 0 ? 0 : 3); break;
197  case 2: clct_ = (sign_ > 0 ? 3 : 0); break;
198  case 1: clct_ = (sign_ > 0 ? 0 : 3); break;
199  case 0: clct_ = 0; break;
200  default: clct_ = 1; break;
201  }
202  } // End conditional: if (bits == 2)
203 
204  // For use in all 2-station modes (3, 5, 6, 9, 10, 12)
205  // Bends [isRPC] --> 0, [-4, -3] --> 1, [-2] --> 2, [-1] --> 3, [0] --> 4, [+1] --> 5, [+2] --> 6, [+3, +4] --> 7
206  else if (bits == 3) {
207  switch (clct) {
208  case 10: clct_ = 4; break;
209  case 9: clct_ = (sign_ > 0 ? 3 : 5); break;
210  case 8: clct_ = (sign_ > 0 ? 5 : 3); break;
211  case 7: clct_ = (sign_ > 0 ? 2 : 6); break;
212  case 6: clct_ = (sign_ > 0 ? 6 : 2); break;
213  case 5: clct_ = (sign_ > 0 ? 1 : 7); break;
214  case 4: clct_ = (sign_ > 0 ? 7 : 1); break;
215  case 3: clct_ = (sign_ > 0 ? 1 : 7); break;
216  case 2: clct_ = (sign_ > 0 ? 7 : 1); break;
217  case 1: clct_ = (sign_ > 0 ? 1 : 7); break;
218  case 0: clct_ = 0; break;
219  default: clct_ = 4; break;
220  }
221  } // End conditional: else if (bits == 3)
222 
223  // std::cout << " * Output clct_ = " << clct_ << std::endl;
224 
225  if (not(clct_ >= 0 && clct_ < pow(2, bits)))
226  { edm::LogError("L1T") << "clct_ = " << clct_ << ", bits = " << bits; return 0; }
227  return clct_;
228 } // End function: int PtAssignmentEngineAux2017::getCLCT()
229 
230 
231 int PtAssignmentEngineAux2017::unpackCLCT(int clct, int endcap, int dPhiSign, int bits) const {
232 
233  // std::cout << "Inside unpackCLCT: clct = " << clct << ", endcap = " << endcap
234  // << ", dPhiSign = " << dPhiSign << ", bits = " << bits << std::endl;
235 
236  if (not(bits == 2 || bits == 3))
237  { edm::LogError("L1T") << "bits = " << bits; return 0; }
238  if (not(clct >= 0 && clct < pow(2, bits)))
239  { edm::LogError("L1T") << "bits = " << bits << ", clct = " << clct; return 0; }
240  if (not(abs(dPhiSign) == 1))
241  { edm::LogError("L1T") << "dPhiSign = " << dPhiSign; return 0; }
242 
243  // Convention here: endcap == +/-1, dPhiSign = +/-1.
244  int clct_ = -1;
245  int sign_ = -1 * endcap * dPhiSign; // CLCT bend is with dPhi in ME-, opposite in ME+
246 
247  if (bits == 2) {
248  switch (clct) {
249  case 1: clct_ = 10; break;
250  case 2: clct_ = (sign_ > 0 ? 8 : 9); break;
251  case 3: clct_ = (sign_ > 0 ? 4 : 5); break;
252  case 0: clct_ = 0; break;
253  default: break;
254  }
255  } else if (bits == 3) {
256  switch (clct) {
257  case 4: clct_ = 10; break;
258  case 5: clct_ = (sign_ > 0 ? 8 : 9); break;
259  case 3: clct_ = (sign_ > 0 ? 9 : 8); break;
260  case 6: clct_ = (sign_ > 0 ? 6 : 7); break;
261  case 2: clct_ = (sign_ > 0 ? 7 : 6); break;
262  case 7: clct_ = (sign_ > 0 ? 4 : 5); break;
263  case 1: clct_ = (sign_ > 0 ? 5 : 4); break;
264  case 0: clct_ = 0; break;
265  default: break;
266  }
267  }
268 
269  // std::cout << " * Output clct_ = " << clct_ << std::endl;
270 
271  if (not(clct_ >= 0 && clct_ <= 10))
272  { edm::LogError("L1T") << "clct_ = " << clct_; return 0; }
273  return clct_;
274 } // End function: int PtAssignmentEngineAux2017::unpackCLCT()
275 
276 
277 int PtAssignmentEngineAux2017::getdTheta(int dTheta, int bits) const {
278  if (not( bits == 2 || bits == 3 ))
279  { edm::LogError("L1T") << "bits = " << bits; return 0; }
280 
281  int dTheta_ = -99;
282 
283  // For use in mode 15
284  if (bits == 2) {
285  if (abs(dTheta) <= 1)
286  dTheta_ = 2;
287  else if (abs(dTheta) <= 2)
288  dTheta_ = 1;
289  else if (dTheta <= -3)
290  dTheta_ = 0;
291  else
292  dTheta_ = 3;
293  } // End conditional: if (bits == 2)
294 
295  // For use in all 2- and 3-station modes (all modes except 15)
296  else if (bits == 3) {
297  if (dTheta <= -4)
298  dTheta_ = 0;
299  else if (dTheta == -3)
300  dTheta_ = 1;
301  else if (dTheta == -2)
302  dTheta_ = 2;
303  else if (dTheta == -1)
304  dTheta_ = 3;
305  else if (dTheta == 0)
306  dTheta_ = 4;
307  else if (dTheta == +1)
308  dTheta_ = 5;
309  else if (dTheta == +2)
310  dTheta_ = 6;
311  else
312  dTheta_ = 7;
313  } // End conditional: if (bits == 3)
314 
315  if (not(dTheta_ >= 0 && dTheta_ < pow(2, bits)))
316  { edm::LogError("L1T") << "dTheta_ = " << dTheta_ << ", bits = " << bits; return 0; }
317  return (dTheta_);
318 } // End function: int PtAssignmentEngineAux2017::getdTheta()
319 
320 
321 int PtAssignmentEngineAux2017::unpackdTheta(int dTheta, int bits) const {
322  if (not( bits == 2 || bits == 3 ))
323  { edm::LogError("L1T") << "bits = " << bits; return 0; }
324  int dTheta_ = -99;
325 
326  if (bits == 2) { // For use in mode 15
327  switch (dTheta) {
328  case 2: dTheta_ = 0; break;
329  case 1: dTheta_ = -2; break;
330  case 0: dTheta_ = -3; break;
331  case 3: dTheta_ = 3; break;
332  default: break;
333  }
334  } else if (bits == 3) { // For use in all 2- and 3-station modes (all modes except 15)
335  switch (dTheta) {
336  case 0: dTheta_ = -4; break;
337  case 1: dTheta_ = -3; break;
338  case 2: dTheta_ = -2; break;
339  case 3: dTheta_ = -1; break;
340  case 4: dTheta_ = 0; break;
341  case 5: dTheta_ = 1; break;
342  case 6: dTheta_ = 2; break;
343  case 7: dTheta_ = 3; break;
344  default: break;
345  }
346  }
347 
348  if (not(dTheta_ >= -4 && dTheta_ <= 3))
349  { edm::LogError("L1T") << "dTheta_ = " << dTheta_; return 0; }
350  return (dTheta_);
351 } // End function: int PtAssignmentEngineAux2017::unpackdTheta(int dTheta, int bits)
352 
353 
354 int PtAssignmentEngineAux2017::getTheta(int theta, int st1_ring2, int bits) const {
355  if (not( theta >= 5 && theta < 128 &&
356  (st1_ring2 == 0 || st1_ring2 == 1) &&
357  (bits == 4 || bits == 5) ))
358  { edm::LogError("L1T") << "theta = " << theta << ", st1_ring2 = " << st1_ring2
359  << ", bits = " << bits; return 0; }
360 
361  int theta_ = -99;
362 
363  // For use in mode 15
364  if (bits == 4) {
365  if (st1_ring2 == 0) {
366  // Should rarely fail ... should change to using ME1 for track theta - AWB 05.06.17
367  if (theta > 52) {
368  // std::cout << "\n\n*** Bizzare case of mode 15 track with ME1/1 LCT and track theta = " << theta << std::endl;
369  }
370  theta_ = (std::min( std::max(theta, 5), 52) - 5) / 6;
371  }
372  else if (st1_ring2 == 1) {
373  // Should rarely fail ... should change to using ME1 for track theta - AWB 05.06.17
374  if (theta < 46 || theta > 87) {
375  // std::cout << "\n\n*** Bizzare case of mode 15 track with ME1/2 LCT and track theta = " << theta << std::endl;
376  }
377  theta_ = ((std::min( std::max(theta, 46), 87) - 46) / 7) + 8;
378  }
379  } // End conditional: if (bits == 4)
380 
381  // For use in all 2- and 3-station modes (all modes except 15)
382  else if (bits == 5) {
383  if (st1_ring2 == 0) {
384  theta_ = (std::max(theta, 1) - 1) / 4;
385  }
386  else if (st1_ring2 == 1) {
387  theta_ = ((std::min(theta, 104) - 1) / 4) + 6;
388  }
389  } // End conditional: else if (bits == 5)
390 
391  if (not(theta_ >= 0 && ((bits == 4 && theta_ <= 13) || (bits == 5 && theta_ < pow(2, bits))) ))
392  { edm::LogError("L1T") << "theta_ = " << theta_ << ", bits = " << bits; return 0; }
393  return (theta_);
394 } // End function: int PtAssignmentEngineAux2017::getTheta()
395 
396 
397 void PtAssignmentEngineAux2017::unpackTheta(int& theta, int& st1_ring2, int bits) const {
398  if (not(bits == 4 || bits == 5))
399  { edm::LogError("L1T") << "bits = " << bits; return; }
400  if (not(theta >= 0 && theta < pow(2, bits)))
401  { edm::LogError("L1T") << "theta = " << theta << ", bits = " << bits; return; }
402 
403  // For use in mode 15
404  if (bits == 4) {
405  if (theta < 8) {
406  st1_ring2 = 0;
407  theta = (theta * 6) + 5;
408  } else {
409  st1_ring2 = 1;
410  theta = ((theta - 8) * 7) + 46;
411  }
412  } else if (bits == 5) {
413  if (theta < 15) {
414  st1_ring2 = 0;
415  theta = (theta * 4) + 1;
416  } else {
417  st1_ring2 = 1;
418  theta = ((theta - 6) * 4) + 1;
419  }
420  }
421 
422  if (not(theta >= 5 && theta <= 104))
423  { edm::LogError("L1T") << "theta = " << theta; return; }
424 
425 } // End function: void PtAssignmentEngineAux2017::unpackTheta()
426 
427 
429  if (not(bits == 4 || bits == 5))
430  { edm::LogError("L1T") << "bits = " << bits; return 0; }
431  if (not(theta >= 0 && theta < pow(2, bits)))
432  { edm::LogError("L1T") << "theta = " << theta << ", bits = " << bits; return 0; }
433 
434  // For use in mode 15
435  if (bits == 4) {
436  if (theta < 6) return 0;
437  else return 1;
438  } else {
439  if (theta < 15) return 0;
440  else return 1;
441  }
442 
443 } // End function: void PtAssignmentEngineAux2017::unpackSt1Ring2()
444 
445 
446 int PtAssignmentEngineAux2017::get2bRPC(int clctA, int clctB, int clctC) const {
447 
448  int rpc_2b = -99;
449 
450  if (clctA == 0) rpc_2b = 0;
451  else if (clctC == 0) rpc_2b = 1;
452  else if (clctB == 0) rpc_2b = 2;
453  else rpc_2b = 3;
454 
455  if (not(rpc_2b >= 0 && rpc_2b < 4))
456  { edm::LogError("L1T") << "rpc_2b = " << rpc_2b; return 0; }
457  return (rpc_2b);
458 } // End function: int PtAssignmentEngineAux2017::get2bRPC()
459 
460 
461 void PtAssignmentEngineAux2017::unpack2bRPC(int rpc_2b, int& rpcA, int& rpcB, int& rpcC) const {
462 
463  if (not(rpc_2b >= 0 && rpc_2b < 4))
464  { edm::LogError("L1T") << "rpc_2b = " << rpc_2b; return; }
465 
466  rpcA = 0; rpcB = 0; rpcC = 0;
467 
468  if (rpc_2b == 0) rpcA = 1;
469  else if (rpc_2b == 1) rpcC = 1;
470  else if (rpc_2b == 2) rpcB = 1;
471 
472 } // End function: int PtAssignmentEngineAux2017::unpack2bRPC()
473 
474 
475 int PtAssignmentEngineAux2017::get8bMode15(int theta, int st1_ring2, int endcap, int sPhiAB,
476  int clctA, int clctB, int clctC, int clctD) const {
477 
478  // std::cout << "Inside get8bMode15, theta = " << theta << ", st1_ring2 = " << st1_ring2 << ", endcap = " << endcap << ", sPhiAB = " << sPhiAB
479  // << ", clctA = " << clctA << ", clctB = " << clctB << ", clctC = " << clctC << ", clctD = " << clctD << std::endl;
480 
481  if (st1_ring2) theta = (std::min( std::max(theta, 46), 87) - 46) / 7;
482  else theta = (std::min( std::max(theta, 5), 52) - 5) / 6;
483  if (not(theta >= 0 && theta < 10))
484  { edm::LogError("L1T") << "theta = " << theta; return 0; }
485 
486  int clctA_2b = getCLCT(clctA, endcap, sPhiAB, 2);
487 
488  int nRPC = (clctA == 0) + (clctB == 0) + (clctC == 0) + (clctD == 0);
489  int rpc_word, rpc_clct, mode15_8b;
490 
491  if (st1_ring2) {
492  if (nRPC >= 2 && clctA == 0 && clctB == 0) rpc_word = 0;
493  else if (nRPC >= 2 && clctA == 0 && clctC == 0) rpc_word = 1;
494  else if (nRPC >= 2 && clctA == 0 && clctD == 0) rpc_word = 2;
495  else if (nRPC == 1 && clctA == 0 ) rpc_word = 3;
496  else if (nRPC >= 2 && clctD == 0 && clctB == 0) rpc_word = 4;
497  else if (nRPC >= 2 && clctD == 0 && clctC == 0) rpc_word = 8;
498  else if (nRPC >= 2 && clctB == 0 && clctC == 0) rpc_word = 12;
499  else if (nRPC == 1 && clctD == 0 ) rpc_word = 16;
500  else if (nRPC == 1 && clctB == 0 ) rpc_word = 20;
501  else if (nRPC == 1 && clctC == 0 ) rpc_word = 24;
502  else rpc_word = 28;
503  rpc_clct = rpc_word + clctA_2b;
504  mode15_8b = (theta*32) + rpc_clct + 64;
505  } else {
506  if (theta >= 4 && clctD == 0) rpc_word = 0;
507  else if (theta >= 4 && clctC == 0) rpc_word = 1;
508  else if (theta >= 4 ) rpc_word = 2;
509  else rpc_word = 3;
510  rpc_clct = rpc_word*4 + clctA_2b;
511  mode15_8b = ((theta % 4)*16) + rpc_clct;
512  }
513 
514  // std::cout << " * Output mode15_8b = " << mode15_8b << std::endl;
515 
516  if (not(mode15_8b >= 0 && mode15_8b < pow(2, 8)))
517  { edm::LogError("L1T") << "mode15_8b = " << mode15_8b; return 0; }
518  return (mode15_8b);
519 
520 } // End function: int PtAssignmentEngineAux2017::get8bMode15()
521 
522 
523 void PtAssignmentEngineAux2017::unpack8bMode15( int mode15_8b, int& theta, int& st1_ring2, int endcap, int sPhiAB,
524  int& clctA, int& rpcA, int& rpcB, int& rpcC, int& rpcD) const {
525 
526  // std::cout << "Inside unpack8bMode15, mode15_8b = " << mode15_8b << ", theta = " << theta
527  // << ", st1_ring2 = " << st1_ring2 << ", endcap = " << endcap << ", sPhiAB = " << sPhiAB << ", clctA = " << clctA
528  // << ", rpcA = " << rpcA << ", rpcB = " << rpcB << ", rpcC = " << rpcC << ", rpcD = " << rpcD << std::endl;
529 
530  if (not(mode15_8b >= 0 && mode15_8b < pow(2, 8)))
531  { edm::LogError("L1T") << "mode15_8b = " << mode15_8b; return; }
532  if (not(abs(endcap) == 1 && abs(sPhiAB) == 1))
533  { edm::LogError("L1T") << "endcap = " << endcap << ", sPhiAB = " << sPhiAB; return; }
534 
535  rpcA = 0; rpcB = 0; rpcC = 0; rpcD = 0;
536 
537  if (mode15_8b >= 64) st1_ring2 = 1;
538  else st1_ring2 = 0;
539 
540  int rpc_clct, rpc_word, clctA_2b, nRPC = -1;
541 
542  if (st1_ring2) {
543 
544  rpc_clct = (mode15_8b % 32);
545  theta = (mode15_8b - 64 - rpc_clct) / 32;
546  theta += 8;
547 
548  if (rpc_clct < 4) clctA_2b = 0;
549  else clctA_2b = (rpc_clct % 4);
550  rpc_word = rpc_clct - clctA_2b;
551 
552  // if (clctA_2b != 0) clctA = unpackCLCT(clctA_2b, endcap, sPhiAB, 2);
553  clctA = clctA_2b;
554 
555  switch (rpc_word) {
556  case 0: nRPC = 2; rpcA = 1; rpcB = 1; break;
557  case 1: nRPC = 2; rpcA = 1; rpcC = 1; break;
558  case 2: nRPC = 2; rpcA = 1; rpcD = 1; break;
559  case 3: nRPC = 1; rpcA = 1; break;
560  case 4: nRPC = 2; rpcD = 1; rpcB = 1; break;
561  case 8: nRPC = 2; rpcD = 1; rpcC = 1; break;
562  case 12: nRPC = 2; rpcB = 1; rpcC = 1; break;
563  case 16: nRPC = 1; rpcD = 1; break;
564  case 20: nRPC = 1; rpcB = 1; break;
565  case 24: nRPC = 1; rpcC = 1; break;
566  case 28: nRPC = 0; break;
567  default: break;
568  }
569  } // End conditional: if (st1_ring2)
570  else {
571 
572  rpc_clct = (mode15_8b % 16);
573  theta = (mode15_8b - rpc_clct) / 16;
574  clctA_2b = (rpc_clct % 4);
575  rpc_word = (rpc_clct - clctA_2b) / 4;
576 
577  // if (clctA_2b != 0) clctA = unpackCLCT(clctA_2b, endcap, sPhiAB, 2);
578  clctA = clctA_2b;
579 
580  switch(rpc_word) {
581  case 0: nRPC = 1; theta += 4; rpcD = 1; break;
582  case 1: nRPC = 1; theta += 4; rpcC = 1; break;
583  case 2: nRPC = 0; theta += 4; break;
584  case 3: nRPC = 0; break;
585  default: break;
586  }
587  }
588 
589  // std::cout << " * Output theta = " << theta << ", st1_ring2 = " << st1_ring2 << ", clctA = " << clctA
590  // << ", rpcA = " << rpcA << ", rpcB = " << rpcB << ", rpcC = " << rpcC << ", rpcD = " << rpcD << std::endl;
591 
592  if (not(nRPC >= 0))
593  { edm::LogError("L1T") << "nRPC = " << nRPC; return; }
594 
595 } // End function: void PtAssignmentEngineAux2017::unpack8bMode15()
int getTheta(int theta, int ring2, int bits=5) const
static const int dPhiNLBMap_7bit_512Max[128]
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
static const int dPhiNLBMap_5bit_256Max[32]
Geom::Theta< T > theta() const
static const int dPhiNLBMap_4bit_256Max[16]
void unpack8bMode15(int mode15_8b, int &theta, int &st1_ring2, int endcap, int sPhiAB, int &clctA, int &rpcA, int &rpcB, int &rpcC, int &rpcD) const
int get2bRPC(int clctA, int clctB, int clctC) const
void unpack2bRPC(int rpc_2b, int &rpcA, int &rpcB, int &rpcC) const
int getNLBdPhi(int dPhi, int bits=7, int max=512) const
int unpackdTheta(int dTheta, int bits) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int getCLCT(int clct, int endcap, int dPhiSign, int bits=3) const
T min(T a, T b)
Definition: MathUtil.h:58
void unpackTheta(int &theta, int &st1_ring2, int bits) const
int getdPhiFromBin(int dPhiBin, int bits=7, int max=512) const
int getdTheta(int dTheta, int bits=3) const
int get8bMode15(int theta, int st1_ring2, int endcap, int sPhiAB, int clctA, int clctB, int clctC, int clctD) const
int unpackSt1Ring2(int theta, int bits) const
int unpackCLCT(int clct, int endcap, int dPhiSign, int bits) const
int getNLBdPhiBin(int dPhi, int bits=7, int max=512) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40