11 static const int dPhiNLBMap_4bit_256Max[16] = {0, 1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 25, 31, 46, 68, 136};
14 static const int dPhiNLBMap_5bit_256Max[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
15 16, 17, 19, 20, 21, 23, 25, 28, 31, 34, 39, 46, 55, 68, 91, 136};
19 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
20 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
21 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
22 66, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 83, 84, 86, 87, 89, 91, 92, 94,
23 96, 98, 100, 102, 105, 107, 110, 112, 115, 118, 121, 124, 127, 131, 135, 138, 143, 147, 152, 157, 162, 168,
24 174, 181, 188, 196, 204, 214, 224, 235, 247, 261, 276, 294, 313, 336, 361, 391, 427, 470};
27 emtf_assert((bits == 4 &&
max == 256) || (bits == 5 &&
max == 256) || (bits == 7 &&
max == 512));
38 for (
int edge = 0; edge < (1 << bits) - 1; edge++) {
47 for (
int edge = 0; edge < (1 << bits) - 1; edge++) {
56 else if (
max == 512) {
59 for (
int edge = 0; edge < (1 << bits) - 1; edge++) {
69 return (sign_ * dPhi_);
73 emtf_assert((bits == 4 &&
max == 256) || (bits == 5 &&
max == 256) || (bits == 7 &&
max == 512));
75 int dPhiBin_ = (1 << bits) - 1;
83 for (
int edge = 0; edge < (1 << bits) - 1; edge++) {
91 for (
int edge = 0; edge < (1 << bits) - 1; edge++) {
100 else if (
max == 512) {
102 for (
int edge = 0; edge < (1 << bits) - 1; edge++) {
116 emtf_assert((bits == 4 &&
max == 256) || (bits == 5 &&
max == 256) || (bits == 7 &&
max == 512));
118 int dPhi_ = (1 << bits) - 1;
130 else if (
max == 512) {
147 int sign_ = -1 *
endcap * dPhiSign;
163 clct_ = (sign_ > 0 ? 1 : 2);
166 clct_ = (sign_ > 0 ? 2 : 1);
169 clct_ = (sign_ > 0 ? 0 : 3);
172 clct_ = (sign_ > 0 ? 3 : 0);
175 clct_ = (sign_ > 0 ? 0 : 3);
178 clct_ = (sign_ > 0 ? 3 : 0);
181 clct_ = (sign_ > 0 ? 0 : 3);
184 clct_ = (sign_ > 0 ? 3 : 0);
187 clct_ = (sign_ > 0 ? 0 : 3);
200 else if (bits == 3) {
206 clct_ = (sign_ > 0 ? 3 : 5);
209 clct_ = (sign_ > 0 ? 5 : 3);
212 clct_ = (sign_ > 0 ? 2 : 6);
215 clct_ = (sign_ > 0 ? 6 : 2);
218 clct_ = (sign_ > 0 ? 1 : 7);
221 clct_ = (sign_ > 0 ? 7 : 1);
224 clct_ = (sign_ > 0 ? 1 : 7);
227 clct_ = (sign_ > 0 ? 7 : 1);
230 clct_ = (sign_ > 0 ? 1 : 7);
257 int sign_ = -1 *
endcap * dPhiSign;
265 clct_ = (sign_ > 0 ? 8 : 9);
268 clct_ = (sign_ > 0 ? 4 : 5);
276 }
else if (bits == 3) {
282 clct_ = (sign_ > 0 ? 8 : 9);
285 clct_ = (sign_ > 0 ? 9 : 8);
288 clct_ = (sign_ > 0 ? 6 : 7);
291 clct_ = (sign_ > 0 ? 7 : 6);
294 clct_ = (sign_ > 0 ? 4 : 5);
297 clct_ = (sign_ > 0 ? 5 : 4);
320 if (
abs(dTheta) <= 1)
322 else if (
abs(dTheta) <= 2)
324 else if (dTheta <= -3)
331 else if (bits == 3) {
334 else if (dTheta == -3)
336 else if (dTheta == -2)
338 else if (dTheta == -1)
340 else if (dTheta == 0)
342 else if (dTheta == +1)
344 else if (dTheta == +2)
376 }
else if (bits == 3) {
412 emtf_assert(
theta >= 5 &&
theta < 128 && (st1_ring2 == 0 || st1_ring2 == 1) && (bits == 4 || bits == 5));
418 if (st1_ring2 == 0) {
424 }
else if (st1_ring2 == 1) {
426 if (theta < 46 || theta > 87) {
434 else if (bits == 5) {
435 if (st1_ring2 == 0) {
437 }
else if (st1_ring2 == 1) {
442 emtf_assert(theta_ >= 0 && ((bits == 4 && theta_ <= 13) || (bits == 5 && theta_ <
pow(2, bits))));
459 }
else if (bits == 5) {
517 else if (rpc_2b == 1)
519 else if (rpc_2b == 2)
525 int theta,
int st1_ring2,
int endcap,
int sPhiAB,
int clctA,
int clctB,
int clctC,
int clctD)
const {
538 int nRPC = (clctA == 0) + (clctB == 0) + (clctC == 0) + (clctD == 0);
539 int rpc_word, rpc_clct, mode15_8b;
542 if (nRPC >= 2 && clctA == 0 && clctB == 0)
544 else if (nRPC >= 2 && clctA == 0 && clctC == 0)
546 else if (nRPC >= 2 && clctA == 0 && clctD == 0)
548 else if (nRPC == 1 && clctA == 0)
550 else if (nRPC >= 2 && clctD == 0 && clctB == 0)
552 else if (nRPC >= 2 && clctD == 0 && clctC == 0)
554 else if (nRPC >= 2 && clctB == 0 && clctC == 0)
556 else if (nRPC == 1 && clctD == 0)
558 else if (nRPC == 1 && clctB == 0)
560 else if (nRPC == 1 && clctC == 0)
564 rpc_clct = rpc_word + clctA_2b;
565 mode15_8b = (
theta * 32) + rpc_clct + 64;
567 if (
theta >= 4 && clctD == 0)
569 else if (
theta >= 4 && clctC == 0)
575 rpc_clct = rpc_word * 4 + clctA_2b;
576 mode15_8b = ((
theta % 4) * 16) + rpc_clct;
613 int rpc_clct, rpc_word, clctA_2b, nRPC = -1;
616 rpc_clct = (mode15_8b % 32);
617 theta = (mode15_8b - 64 - rpc_clct) / 32;
623 clctA_2b = (rpc_clct % 4);
624 rpc_word = rpc_clct - clctA_2b;
684 rpc_clct = (mode15_8b % 16);
685 theta = (mode15_8b - rpc_clct) / 16;
686 clctA_2b = (rpc_clct % 4);
687 rpc_word = (rpc_clct - clctA_2b) / 4;
731 const bool BIT_COMP)
const {
734 if ((
mode % 8) / 4 > 0)
736 else if ((
mode % 4) / 2 > 0)
738 else if ((
mode % 2) > 0)
744 int nBits = (
mode == 15 ? 4 : 5);
768 const bool BIT_COMP)
const {
778 if ((
mode % 8) / 4 > 0)
779 dPhSign = (dPh12 >= 0 ? +1 : -1);
780 else if ((
mode % 4) / 2 > 0)
781 dPhSign = (dPh13 >= 0 ? +1 : -1);
782 else if ((
mode % 2) > 0)
783 dPhSign = (dPh14 >= 0 ? +1 : -1);
784 }
else if ((
mode % 8) / 4 > 0) {
785 if ((
mode % 4) / 2 > 0)
786 dPhSign = (dPh23 >= 0 ? +1 : -1);
787 else if ((
mode % 2) > 0)
788 dPhSign = (dPh24 >= 0 ? +1 : -1);
789 }
else if ((
mode % 4) / 2 > 0) {
791 dPhSign = (dPh34 >= 0 ? +1 : -1);
835 dPh13 = dPh12 + dPh23;
836 dPh14 = dPh13 + dPh34;
837 dPh24 = dPh23 + dPh34;
840 dPh13 = dPh12 + dPh23;
843 dPh14 = dPh12 + dPh24;
846 dPh14 = dPh13 + dPh34;
849 dPh24 = dPh23 + dPh34;
859 calcDeltaPhiSums(dPhSum4, dPhSum4A, dPhSum3, dPhSum3A, outStPh, dPh12, dPh13, dPh14, dPh23, dPh24, dPh34);
874 const bool BIT_COMP)
const {
883 int nBits = (
mode == 15 ? 2 : 3);
906 const bool BIT_COMP)
const {
919 if ((
mode % 8) / 4 > 0)
921 if ((
mode % 4) / 2 > 0)
936 const bool BIT_COMP)
const {
940 if (
mode == 15 && !st1_ring2) {
949 int nRPC = (RPC1 == 1) + (RPC2 == 1) + (RPC3 == 1) + (RPC4 == 1);
954 if (RPC1 == 1 && RPC2 == 1) {
957 }
else if (RPC1 == 1 && RPC3 == 1) {
959 }
else if (RPC4 == 1 && RPC2 == 1) {
961 }
else if (RPC3 == 1 && RPC4 == 1 && !st1_ring2) {
964 }
else if (
mode == 14) {
968 }
else if (RPC3 == 1) {
971 }
else if (
mode == 13) {
975 }
else if (RPC4 == 1) {
978 }
else if (
mode == 11) {
982 }
else if (RPC4 == 1) {
985 }
else if (
mode == 7) {
989 }
else if (RPC4 == 1) {
1029 const int dPh34)
const {
1030 dPhSum4 = dPh12 + dPh13 + dPh14 + dPh23 + dPh24 + dPh34;
1031 dPhSum4A =
abs(dPh12) +
abs(dPh13) +
abs(dPh14) +
abs(dPh23) +
abs(dPh24) +
abs(dPh34);
1032 int devSt1 =
abs(dPh12) +
abs(dPh13) +
abs(dPh14);
1033 int devSt2 =
abs(dPh12) +
abs(dPh23) +
abs(dPh24);
1034 int devSt3 =
abs(dPh13) +
abs(dPh23) +
abs(dPh34);
1035 int devSt4 =
abs(dPh14) +
abs(dPh24) +
abs(dPh34);
1037 if (devSt4 > devSt3 && devSt4 > devSt2 && devSt4 > devSt1)
1039 else if (devSt3 > devSt4 && devSt3 > devSt2 && devSt3 > devSt1)
1041 else if (devSt2 > devSt4 && devSt2 > devSt3 && devSt2 > devSt1)
1043 else if (devSt1 > devSt4 && devSt1 > devSt3 && devSt1 > devSt2)
1049 dPhSum3 = dPh12 + dPh13 + dPh23;
1050 dPhSum3A =
abs(dPh12) +
abs(dPh13) +
abs(dPh23);
1051 }
else if (outStPh == 3) {
1052 dPhSum3 = dPh12 + dPh14 + dPh24;
1053 dPhSum3A =
abs(dPh12) +
abs(dPh14) +
abs(dPh24);
1054 }
else if (outStPh == 2) {
1055 dPhSum3 = dPh13 + dPh14 + dPh34;
1056 dPhSum3A =
abs(dPh13) +
abs(dPh14) +
abs(dPh34);
1058 dPhSum3 = dPh23 + dPh24 + dPh34;
1059 dPhSum3A =
abs(dPh23) +
abs(dPh24) +
abs(dPh34);