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 // Arrays that map the integer dPhi --> dPhi-units. 1/60th of a degree per unit; 255 units --> 4.25 degrees, 511 --> 8.52 degrees
10 
11 // 256 max units----
12 // For use in dPhi34 in mode 15. Derived manually from dPhiNLBMap_5bit_256Max for now; should generate algorithmically. - AWB 17.03.17
13 static const int dPhiNLBMap_4bit_256Max[16] = {0, 1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 25, 31, 46, 68, 136};
14 
15 // 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
16 static const int dPhiNLBMap_5bit_256Max[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
17  16, 17, 19, 20, 21, 23, 25, 28, 31, 34, 39, 46, 55, 68, 91, 136};
18 // 512 max units----
19 // For use in all dPhiAB (where "A" and "B" are the first two stations in the track) in all modes
20 static const int dPhiNLBMap_7bit_512Max[128] = {
21  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22  22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
23  44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
24  66, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 83, 84, 86, 87, 89, 91, 92, 94,
25  96, 98, 100, 102, 105, 107, 110, 112, 115, 118, 121, 124, 127, 131, 135, 138, 143, 147, 152, 157, 162, 168,
26  174, 181, 188, 196, 204, 214, 224, 235, 247, 261, 276, 294, 313, 336, 361, 391, 427, 470};
27 
29  if (not((bits == 4 && max == 256) || (bits == 5 && max == 256) || (bits == 7 && max == 512))) {
30  edm::LogError("L1T") << "bits = " << bits << ", max = " << max;
31  return 0;
32  }
33 
34  int dPhi_ = max;
35  int sign_ = 1;
36  if (dPhi < 0)
37  sign_ = -1;
38  dPhi = sign_ * dPhi;
39 
40  if (max == 256) {
41  if (bits == 4) {
42  dPhi_ = dPhiNLBMap_4bit_256Max[(1 << bits) - 1];
43  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
44  if (dPhiNLBMap_4bit_256Max[edge] <= dPhi && dPhiNLBMap_4bit_256Max[edge + 1] > dPhi) {
45  dPhi_ = dPhiNLBMap_4bit_256Max[edge];
46  break;
47  }
48  }
49  } // End conditional: if (bits == 4)
50  if (bits == 5) {
51  dPhi_ = dPhiNLBMap_5bit_256Max[(1 << bits) - 1];
52  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
53  if (dPhiNLBMap_5bit_256Max[edge] <= dPhi && dPhiNLBMap_5bit_256Max[edge + 1] > dPhi) {
54  dPhi_ = dPhiNLBMap_5bit_256Max[edge];
55  break;
56  }
57  }
58  } // End conditional: if (bits == 5)
59  } // End conditional: if (max == 256)
60 
61  else if (max == 512) {
62  if (bits == 7) {
63  dPhi_ = dPhiNLBMap_7bit_512Max[(1 << bits) - 1];
64  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
65  if (dPhiNLBMap_7bit_512Max[edge] <= dPhi && dPhiNLBMap_7bit_512Max[edge + 1] > dPhi) {
66  dPhi_ = dPhiNLBMap_7bit_512Max[edge];
67  break;
68  }
69  }
70  } // End conditional: if (bits == 7)
71  } // End conditional: else if (max == 512)
72 
73  if (not(abs(sign_) == 1 && dPhi_ >= 0 && dPhi_ < max)) {
74  edm::LogError("L1T") << "sign_ = " << sign_ << ", dPhi_ = " << dPhi_ << ", max = " << max;
75  return 0;
76  }
77  return (sign_ * dPhi_);
78 } // End function: nt PtAssignmentEngineAux2017::getNLBdPhi()
79 
81  if (not((bits == 4 && max == 256) || (bits == 5 && max == 256) || (bits == 7 && max == 512))) {
82  edm::LogError("L1T") << "bits = " << bits << ", max = " << max;
83  return 0;
84  }
85 
86  int dPhiBin_ = (1 << bits) - 1;
87  int sign_ = 1;
88  if (dPhi < 0)
89  sign_ = -1;
90  dPhi = sign_ * dPhi;
91 
92  if (max == 256) {
93  if (bits == 4) {
94  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
95  if (dPhiNLBMap_4bit_256Max[edge] <= dPhi && dPhiNLBMap_4bit_256Max[edge + 1] > dPhi) {
96  dPhiBin_ = edge;
97  break;
98  }
99  }
100  } // End conditional: if (bits == 4)
101  if (bits == 5) {
102  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
103  if (dPhiNLBMap_5bit_256Max[edge] <= dPhi && dPhiNLBMap_5bit_256Max[edge + 1] > dPhi) {
104  dPhiBin_ = edge;
105  break;
106  }
107  }
108  } // End conditional: if (bits == 5)
109  } // End conditional: if (max == 256)
110 
111  else if (max == 512) {
112  if (bits == 7) {
113  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
114  if (dPhiNLBMap_7bit_512Max[edge] <= dPhi && dPhiNLBMap_7bit_512Max[edge + 1] > dPhi) {
115  dPhiBin_ = edge;
116  break;
117  }
118  }
119  } // End conditional: if (bits == 7)
120  } // End conditional: else if (max == 512)
121 
122  if (not(dPhiBin_ >= 0 && dPhiBin_ < pow(2, bits))) {
123  edm::LogError("L1T") << "dPhiBin_ = " << dPhiBin_ << ", bits = " << bits;
124  return 0;
125  }
126  return (dPhiBin_);
127 } // End function: int PtAssignmentEngineAux2017::getNLBdPhiBin()
128 
130  if (not((bits == 4 && max == 256) || (bits == 5 && max == 256) || (bits == 7 && max == 512))) {
131  edm::LogError("L1T") << "bits = " << bits << ", max = " << max;
132  return 0;
133  }
134 
135  int dPhi_ = (1 << bits) - 1;
136 
137  if (dPhiBin > (1 << bits) - 1)
138  dPhiBin = (1 << bits) - 1;
139 
140  if (max == 256) {
141  if (bits == 4)
143  if (bits == 5)
145  } // End conditional: if (max == 256)
146 
147  else if (max == 512) {
148  if (bits == 7)
150  } // End conditional: else if (max == 512)
151 
152  if (not(dPhi_ >= 0 && dPhi_ < max)) {
153  edm::LogError("L1T") << "dPhi_ = " << dPhi_ << ", max = " << max;
154  return 0;
155  }
156  return (dPhi_);
157 } // End function: int PtAssignmentEngineAux2017::getdPhiFromBin()
158 
159 int PtAssignmentEngineAux2017::getCLCT(int clct, int endcap, int dPhiSign, int bits) const {
160  // std::cout << "Inside getCLCT: clct = " << clct << ", endcap = " << endcap
161  // << ", dPhiSign = " << dPhiSign << ", bits = " << bits << std::endl;
162 
163  if (not(clct >= 0 && clct <= 10 && abs(endcap) == 1 && abs(dPhiSign) == 1 && (bits == 2 || bits == 3))) {
164  edm::LogError("L1T") << "clct = " << clct << ", endcap = " << endcap << ", dPhiSign = " << dPhiSign
165  << ", bits = " << bits;
166  return 0;
167  }
168 
169  // Convention here: endcap == +/-1, dPhiSign = +/-1.
170  int clct_ = 0;
171  int sign_ = -1 * endcap * dPhiSign; // CLCT bend is with dPhi in ME-, opposite in ME+
172 
173  // CLCT pattern can be converted into |bend| x sign as follows:
174  // |bend| = (10 + (pattern % 2) - pattern) / 2
175  // * 10 --> 0, 9/8 --> 1, 7/6 --> 2, 5/4 --> 3, 3/2 --> 4, 0 indicates RPC hit
176  // sign = ((pattern % 2) == 1 ? -1 : 1) * (endcap == 1 ? -1 : 1)
177  // * In ME+, even CLCTs have negative sign, odd CLCTs have positive
178 
179  // For use in all 3- and 4-station modes (7, 11, 13, 14, 15)
180  // Bends [-4, -3, -2] --> 0, [-1, 0] --> 1, [+1] --> 2, [+2, +3, +4] --> 3
181  if (bits == 2) {
182  switch (clct) {
183  case 10:
184  clct_ = 1;
185  break;
186  case 9:
187  clct_ = (sign_ > 0 ? 1 : 2);
188  break;
189  case 8:
190  clct_ = (sign_ > 0 ? 2 : 1);
191  break;
192  case 7:
193  clct_ = (sign_ > 0 ? 0 : 3);
194  break;
195  case 6:
196  clct_ = (sign_ > 0 ? 3 : 0);
197  break;
198  case 5:
199  clct_ = (sign_ > 0 ? 0 : 3);
200  break;
201  case 4:
202  clct_ = (sign_ > 0 ? 3 : 0);
203  break;
204  case 3:
205  clct_ = (sign_ > 0 ? 0 : 3);
206  break;
207  case 2:
208  clct_ = (sign_ > 0 ? 3 : 0);
209  break;
210  case 1:
211  clct_ = (sign_ > 0 ? 0 : 3);
212  break;
213  case 0:
214  clct_ = 0;
215  break;
216  default:
217  clct_ = 1;
218  break;
219  }
220  } // End conditional: if (bits == 2)
221 
222  // For use in all 2-station modes (3, 5, 6, 9, 10, 12)
223  // Bends [isRPC] --> 0, [-4, -3] --> 1, [-2] --> 2, [-1] --> 3, [0] --> 4, [+1] --> 5, [+2] --> 6, [+3, +4] --> 7
224  else if (bits == 3) {
225  switch (clct) {
226  case 10:
227  clct_ = 4;
228  break;
229  case 9:
230  clct_ = (sign_ > 0 ? 3 : 5);
231  break;
232  case 8:
233  clct_ = (sign_ > 0 ? 5 : 3);
234  break;
235  case 7:
236  clct_ = (sign_ > 0 ? 2 : 6);
237  break;
238  case 6:
239  clct_ = (sign_ > 0 ? 6 : 2);
240  break;
241  case 5:
242  clct_ = (sign_ > 0 ? 1 : 7);
243  break;
244  case 4:
245  clct_ = (sign_ > 0 ? 7 : 1);
246  break;
247  case 3:
248  clct_ = (sign_ > 0 ? 1 : 7);
249  break;
250  case 2:
251  clct_ = (sign_ > 0 ? 7 : 1);
252  break;
253  case 1:
254  clct_ = (sign_ > 0 ? 1 : 7);
255  break;
256  case 0:
257  clct_ = 0;
258  break;
259  default:
260  clct_ = 4;
261  break;
262  }
263  } // End conditional: else if (bits == 3)
264 
265  // std::cout << " * Output clct_ = " << clct_ << std::endl;
266 
267  if (not(clct_ >= 0 && clct_ < pow(2, bits))) {
268  edm::LogError("L1T") << "clct_ = " << clct_ << ", bits = " << bits;
269  return 0;
270  }
271  return clct_;
272 } // End function: int PtAssignmentEngineAux2017::getCLCT()
273 
274 int PtAssignmentEngineAux2017::unpackCLCT(int clct, int endcap, int dPhiSign, int bits) const {
275  // std::cout << "Inside unpackCLCT: clct = " << clct << ", endcap = " << endcap
276  // << ", dPhiSign = " << dPhiSign << ", bits = " << bits << std::endl;
277 
278  if (not(bits == 2 || bits == 3)) {
279  edm::LogError("L1T") << "bits = " << bits;
280  return 0;
281  }
282  if (not(clct >= 0 && clct < pow(2, bits))) {
283  edm::LogError("L1T") << "bits = " << bits << ", clct = " << clct;
284  return 0;
285  }
286  if (not(abs(dPhiSign) == 1)) {
287  edm::LogError("L1T") << "dPhiSign = " << dPhiSign;
288  return 0;
289  }
290 
291  // Convention here: endcap == +/-1, dPhiSign = +/-1.
292  int clct_ = -1;
293  int sign_ = -1 * endcap * dPhiSign; // CLCT bend is with dPhi in ME-, opposite in ME+
294 
295  if (bits == 2) {
296  switch (clct) {
297  case 1:
298  clct_ = 10;
299  break;
300  case 2:
301  clct_ = (sign_ > 0 ? 8 : 9);
302  break;
303  case 3:
304  clct_ = (sign_ > 0 ? 4 : 5);
305  break;
306  case 0:
307  clct_ = 0;
308  break;
309  default:
310  break;
311  }
312  } else if (bits == 3) {
313  switch (clct) {
314  case 4:
315  clct_ = 10;
316  break;
317  case 5:
318  clct_ = (sign_ > 0 ? 8 : 9);
319  break;
320  case 3:
321  clct_ = (sign_ > 0 ? 9 : 8);
322  break;
323  case 6:
324  clct_ = (sign_ > 0 ? 6 : 7);
325  break;
326  case 2:
327  clct_ = (sign_ > 0 ? 7 : 6);
328  break;
329  case 7:
330  clct_ = (sign_ > 0 ? 4 : 5);
331  break;
332  case 1:
333  clct_ = (sign_ > 0 ? 5 : 4);
334  break;
335  case 0:
336  clct_ = 0;
337  break;
338  default:
339  break;
340  }
341  }
342 
343  // std::cout << " * Output clct_ = " << clct_ << std::endl;
344 
345  if (not(clct_ >= 0 && clct_ <= 10)) {
346  edm::LogError("L1T") << "clct_ = " << clct_;
347  return 0;
348  }
349  return clct_;
350 } // End function: int PtAssignmentEngineAux2017::unpackCLCT()
351 
352 int PtAssignmentEngineAux2017::getdTheta(int dTheta, int bits) const {
353  if (not(bits == 2 || bits == 3)) {
354  edm::LogError("L1T") << "bits = " << bits;
355  return 0;
356  }
357 
358  int dTheta_ = -99;
359 
360  // For use in mode 15
361  if (bits == 2) {
362  if (abs(dTheta) <= 1)
363  dTheta_ = 2;
364  else if (abs(dTheta) <= 2)
365  dTheta_ = 1;
366  else if (dTheta <= -3)
367  dTheta_ = 0;
368  else
369  dTheta_ = 3;
370  } // End conditional: if (bits == 2)
371 
372  // For use in all 2- and 3-station modes (all modes except 15)
373  else if (bits == 3) {
374  if (dTheta <= -4)
375  dTheta_ = 0;
376  else if (dTheta == -3)
377  dTheta_ = 1;
378  else if (dTheta == -2)
379  dTheta_ = 2;
380  else if (dTheta == -1)
381  dTheta_ = 3;
382  else if (dTheta == 0)
383  dTheta_ = 4;
384  else if (dTheta == +1)
385  dTheta_ = 5;
386  else if (dTheta == +2)
387  dTheta_ = 6;
388  else
389  dTheta_ = 7;
390  } // End conditional: if (bits == 3)
391 
392  if (not(dTheta_ >= 0 && dTheta_ < pow(2, bits))) {
393  edm::LogError("L1T") << "dTheta_ = " << dTheta_ << ", bits = " << bits;
394  return 0;
395  }
396  return (dTheta_);
397 } // End function: int PtAssignmentEngineAux2017::getdTheta()
398 
399 int PtAssignmentEngineAux2017::unpackdTheta(int dTheta, int bits) const {
400  if (not(bits == 2 || bits == 3)) {
401  edm::LogError("L1T") << "bits = " << bits;
402  return 0;
403  }
404  int dTheta_ = -99;
405 
406  if (bits == 2) { // For use in mode 15
407  switch (dTheta) {
408  case 2:
409  dTheta_ = 0;
410  break;
411  case 1:
412  dTheta_ = -2;
413  break;
414  case 0:
415  dTheta_ = -3;
416  break;
417  case 3:
418  dTheta_ = 3;
419  break;
420  default:
421  break;
422  }
423  } else if (bits == 3) { // For use in all 2- and 3-station modes (all modes except 15)
424  switch (dTheta) {
425  case 0:
426  dTheta_ = -4;
427  break;
428  case 1:
429  dTheta_ = -3;
430  break;
431  case 2:
432  dTheta_ = -2;
433  break;
434  case 3:
435  dTheta_ = -1;
436  break;
437  case 4:
438  dTheta_ = 0;
439  break;
440  case 5:
441  dTheta_ = 1;
442  break;
443  case 6:
444  dTheta_ = 2;
445  break;
446  case 7:
447  dTheta_ = 3;
448  break;
449  default:
450  break;
451  }
452  }
453 
454  if (not(dTheta_ >= -4 && dTheta_ <= 3)) {
455  edm::LogError("L1T") << "dTheta_ = " << dTheta_;
456  return 0;
457  }
458  return (dTheta_);
459 } // End function: int PtAssignmentEngineAux2017::unpackdTheta(int dTheta, int bits)
460 
461 int PtAssignmentEngineAux2017::getTheta(int theta, int st1_ring2, int bits) const {
462  if (not(theta >= 5 && theta < 128 && (st1_ring2 == 0 || st1_ring2 == 1) && (bits == 4 || bits == 5))) {
463  edm::LogError("L1T") << "theta = " << theta << ", st1_ring2 = " << st1_ring2 << ", bits = " << bits;
464  return 0;
465  }
466 
467  int theta_ = -99;
468 
469  // For use in mode 15
470  if (bits == 4) {
471  if (st1_ring2 == 0) {
472  // Should rarely fail ... should change to using ME1 for track theta - AWB 05.06.17
473  if (theta > 52) {
474  // std::cout << "\n\n*** Bizzare case of mode 15 track with ME1/1 LCT and track theta = " << theta << std::endl;
475  }
476  theta_ = (std::min(std::max(theta, 5), 52) - 5) / 6;
477  } else if (st1_ring2 == 1) {
478  // Should rarely fail ... should change to using ME1 for track theta - AWB 05.06.17
479  if (theta < 46 || theta > 87) {
480  // std::cout << "\n\n*** Bizzare case of mode 15 track with ME1/2 LCT and track theta = " << theta << std::endl;
481  }
482  theta_ = ((std::min(std::max(theta, 46), 87) - 46) / 7) + 8;
483  }
484  } // End conditional: if (bits == 4)
485 
486  // For use in all 2- and 3-station modes (all modes except 15)
487  else if (bits == 5) {
488  if (st1_ring2 == 0) {
489  theta_ = (std::max(theta, 1) - 1) / 4;
490  } else if (st1_ring2 == 1) {
491  theta_ = ((std::min(theta, 104) - 1) / 4) + 6;
492  }
493  } // End conditional: else if (bits == 5)
494 
495  if (not(theta_ >= 0 && ((bits == 4 && theta_ <= 13) || (bits == 5 && theta_ < pow(2, bits))))) {
496  edm::LogError("L1T") << "theta_ = " << theta_ << ", bits = " << bits;
497  return 0;
498  }
499  return (theta_);
500 } // End function: int PtAssignmentEngineAux2017::getTheta()
501 
502 void PtAssignmentEngineAux2017::unpackTheta(int& theta, int& st1_ring2, int bits) const {
503  if (not(bits == 4 || bits == 5)) {
504  edm::LogError("L1T") << "bits = " << bits;
505  return;
506  }
507  if (not(theta >= 0 && theta < pow(2, bits))) {
508  edm::LogError("L1T") << "theta = " << theta << ", bits = " << bits;
509  return;
510  }
511 
512  // For use in mode 15
513  if (bits == 4) {
514  if (theta < 8) {
515  st1_ring2 = 0;
516  theta = (theta * 6) + 5;
517  } else {
518  st1_ring2 = 1;
519  theta = ((theta - 8) * 7) + 46;
520  }
521  } else if (bits == 5) {
522  if (theta < 15) {
523  st1_ring2 = 0;
524  theta = (theta * 4) + 1;
525  } else {
526  st1_ring2 = 1;
527  theta = ((theta - 6) * 4) + 1;
528  }
529  }
530 
531  if (not(theta >= 5 && theta <= 104)) {
532  edm::LogError("L1T") << "theta = " << theta;
533  return;
534  }
535 
536 } // End function: void PtAssignmentEngineAux2017::unpackTheta()
537 
539  if (not(bits == 4 || bits == 5)) {
540  edm::LogError("L1T") << "bits = " << bits;
541  return 0;
542  }
543  if (not(theta >= 0 && theta < pow(2, bits))) {
544  edm::LogError("L1T") << "theta = " << theta << ", bits = " << bits;
545  return 0;
546  }
547 
548  // For use in mode 15
549  if (bits == 4) {
550  if (theta < 6)
551  return 0;
552  else
553  return 1;
554  } else {
555  if (theta < 15)
556  return 0;
557  else
558  return 1;
559  }
560 
561 } // End function: void PtAssignmentEngineAux2017::unpackSt1Ring2()
562 
563 int PtAssignmentEngineAux2017::get2bRPC(int clctA, int clctB, int clctC) const {
564  int rpc_2b = -99;
565 
566  if (clctA == 0)
567  rpc_2b = 0;
568  else if (clctC == 0)
569  rpc_2b = 1;
570  else if (clctB == 0)
571  rpc_2b = 2;
572  else
573  rpc_2b = 3;
574 
575  if (not(rpc_2b >= 0 && rpc_2b < 4)) {
576  edm::LogError("L1T") << "rpc_2b = " << rpc_2b;
577  return 0;
578  }
579  return (rpc_2b);
580 } // End function: int PtAssignmentEngineAux2017::get2bRPC()
581 
582 void PtAssignmentEngineAux2017::unpack2bRPC(int rpc_2b, int& rpcA, int& rpcB, int& rpcC) const {
583  if (not(rpc_2b >= 0 && rpc_2b < 4)) {
584  edm::LogError("L1T") << "rpc_2b = " << rpc_2b;
585  return;
586  }
587 
588  rpcA = 0;
589  rpcB = 0;
590  rpcC = 0;
591 
592  if (rpc_2b == 0)
593  rpcA = 1;
594  else if (rpc_2b == 1)
595  rpcC = 1;
596  else if (rpc_2b == 2)
597  rpcB = 1;
598 
599 } // End function: int PtAssignmentEngineAux2017::unpack2bRPC()
600 
602  int theta, int st1_ring2, int endcap, int sPhiAB, int clctA, int clctB, int clctC, int clctD) const {
603  // std::cout << "Inside get8bMode15, theta = " << theta << ", st1_ring2 = " << st1_ring2 << ", endcap = " << endcap << ", sPhiAB = " << sPhiAB
604  // << ", clctA = " << clctA << ", clctB = " << clctB << ", clctC = " << clctC << ", clctD = " << clctD << std::endl;
605 
606  if (st1_ring2)
607  theta = (std::min(std::max(theta, 46), 87) - 46) / 7;
608  else
609  theta = (std::min(std::max(theta, 5), 52) - 5) / 6;
610  if (not(theta >= 0 && theta < 10)) {
611  edm::LogError("L1T") << "theta = " << theta;
612  return 0;
613  }
614 
615  int clctA_2b = getCLCT(clctA, endcap, sPhiAB, 2);
616 
617  int nRPC = (clctA == 0) + (clctB == 0) + (clctC == 0) + (clctD == 0);
618  int rpc_word, rpc_clct, mode15_8b;
619 
620  if (st1_ring2) {
621  if (nRPC >= 2 && clctA == 0 && clctB == 0)
622  rpc_word = 0;
623  else if (nRPC >= 2 && clctA == 0 && clctC == 0)
624  rpc_word = 1;
625  else if (nRPC >= 2 && clctA == 0 && clctD == 0)
626  rpc_word = 2;
627  else if (nRPC == 1 && clctA == 0)
628  rpc_word = 3;
629  else if (nRPC >= 2 && clctD == 0 && clctB == 0)
630  rpc_word = 4;
631  else if (nRPC >= 2 && clctD == 0 && clctC == 0)
632  rpc_word = 8;
633  else if (nRPC >= 2 && clctB == 0 && clctC == 0)
634  rpc_word = 12;
635  else if (nRPC == 1 && clctD == 0)
636  rpc_word = 16;
637  else if (nRPC == 1 && clctB == 0)
638  rpc_word = 20;
639  else if (nRPC == 1 && clctC == 0)
640  rpc_word = 24;
641  else
642  rpc_word = 28;
643  rpc_clct = rpc_word + clctA_2b;
644  mode15_8b = (theta * 32) + rpc_clct + 64;
645  } else {
646  if (theta >= 4 && clctD == 0)
647  rpc_word = 0;
648  else if (theta >= 4 && clctC == 0)
649  rpc_word = 1;
650  else if (theta >= 4)
651  rpc_word = 2;
652  else
653  rpc_word = 3;
654  rpc_clct = rpc_word * 4 + clctA_2b;
655  mode15_8b = ((theta % 4) * 16) + rpc_clct;
656  }
657 
658  // std::cout << " * Output mode15_8b = " << mode15_8b << std::endl;
659 
660  if (not(mode15_8b >= 0 && mode15_8b < pow(2, 8))) {
661  edm::LogError("L1T") << "mode15_8b = " << mode15_8b;
662  return 0;
663  }
664  return (mode15_8b);
665 
666 } // End function: int PtAssignmentEngineAux2017::get8bMode15()
667 
669  int& theta,
670  int& st1_ring2,
671  int endcap,
672  int sPhiAB,
673  int& clctA,
674  int& rpcA,
675  int& rpcB,
676  int& rpcC,
677  int& rpcD) const {
678  // std::cout << "Inside unpack8bMode15, mode15_8b = " << mode15_8b << ", theta = " << theta
679  // << ", st1_ring2 = " << st1_ring2 << ", endcap = " << endcap << ", sPhiAB = " << sPhiAB << ", clctA = " << clctA
680  // << ", rpcA = " << rpcA << ", rpcB = " << rpcB << ", rpcC = " << rpcC << ", rpcD = " << rpcD << std::endl;
681 
682  if (not(mode15_8b >= 0 && mode15_8b < pow(2, 8))) {
683  edm::LogError("L1T") << "mode15_8b = " << mode15_8b;
684  return;
685  }
686  if (not(abs(endcap) == 1 && abs(sPhiAB) == 1)) {
687  edm::LogError("L1T") << "endcap = " << endcap << ", sPhiAB = " << sPhiAB;
688  return;
689  }
690 
691  rpcA = 0;
692  rpcB = 0;
693  rpcC = 0;
694  rpcD = 0;
695 
696  if (mode15_8b >= 64)
697  st1_ring2 = 1;
698  else
699  st1_ring2 = 0;
700 
701  int rpc_clct, rpc_word, clctA_2b, nRPC = -1;
702 
703  if (st1_ring2) {
704  rpc_clct = (mode15_8b % 32);
705  theta = (mode15_8b - 64 - rpc_clct) / 32;
706  theta += 8;
707 
708  if (rpc_clct < 4)
709  clctA_2b = 0;
710  else
711  clctA_2b = (rpc_clct % 4);
712  rpc_word = rpc_clct - clctA_2b;
713 
714  // if (clctA_2b != 0) clctA = unpackCLCT(clctA_2b, endcap, sPhiAB, 2);
715  clctA = clctA_2b;
716 
717  switch (rpc_word) {
718  case 0:
719  nRPC = 2;
720  rpcA = 1;
721  rpcB = 1;
722  break;
723  case 1:
724  nRPC = 2;
725  rpcA = 1;
726  rpcC = 1;
727  break;
728  case 2:
729  nRPC = 2;
730  rpcA = 1;
731  rpcD = 1;
732  break;
733  case 3:
734  nRPC = 1;
735  rpcA = 1;
736  break;
737  case 4:
738  nRPC = 2;
739  rpcD = 1;
740  rpcB = 1;
741  break;
742  case 8:
743  nRPC = 2;
744  rpcD = 1;
745  rpcC = 1;
746  break;
747  case 12:
748  nRPC = 2;
749  rpcB = 1;
750  rpcC = 1;
751  break;
752  case 16:
753  nRPC = 1;
754  rpcD = 1;
755  break;
756  case 20:
757  nRPC = 1;
758  rpcB = 1;
759  break;
760  case 24:
761  nRPC = 1;
762  rpcC = 1;
763  break;
764  case 28:
765  nRPC = 0;
766  break;
767  default:
768  break;
769  }
770  } // End conditional: if (st1_ring2)
771  else {
772  rpc_clct = (mode15_8b % 16);
773  theta = (mode15_8b - rpc_clct) / 16;
774  clctA_2b = (rpc_clct % 4);
775  rpc_word = (rpc_clct - clctA_2b) / 4;
776 
777  // if (clctA_2b != 0) clctA = unpackCLCT(clctA_2b, endcap, sPhiAB, 2);
778  clctA = clctA_2b;
779 
780  switch (rpc_word) {
781  case 0:
782  nRPC = 1;
783  theta += 4;
784  rpcD = 1;
785  break;
786  case 1:
787  nRPC = 1;
788  theta += 4;
789  rpcC = 1;
790  break;
791  case 2:
792  nRPC = 0;
793  theta += 4;
794  break;
795  case 3:
796  nRPC = 0;
797  break;
798  default:
799  break;
800  }
801  }
802 
803  // std::cout << " * Output theta = " << theta << ", st1_ring2 = " << st1_ring2 << ", clctA = " << clctA
804  // << ", rpcA = " << rpcA << ", rpcB = " << rpcB << ", rpcC = " << rpcC << ", rpcD = " << rpcD << std::endl;
805 
806  if (not(nRPC >= 0)) {
807  edm::LogError("L1T") << "nRPC = " << nRPC;
808  return;
809  }
810 
811 } // 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:30