52 mask = !((u > 2 *
v) && (v < n));
54 mask = ((u >=
n) && (v >= n) && ((u +
v) > (3 * n - 2)));
60 mask = !((u +
v) < n);
62 mask = ((u >=
n) && (u > v) && ((2 * u -
v) > 2 * n));
68 mask = !((u < n) && (v > u) && (v > (2 * u - 1)));
70 mask = ((u > 2 *
v) && (v < n));
76 mask = !((v >= u) && ((2 * v - u) > (2 * n - 2)));
84 mask = !((u >=
n) && (v >= n) && ((u +
v) > (3 * n - 2)));
86 mask = ((u < n) && (v > u) && (v > (2 * u - 1)));
92 mask = !((u >=
n) && (u > v) && ((2 * u -
v) > 2 * n));
94 mask = ((v >= u) && ((2 * v - u) > (2 * n - 2)));
102 edm::LogVerbatim(
"HGCalGeom") <<
"Corners: " << ncor <<
":" << fcor <<
" N " << n <<
" u " << u <<
" v " << v
112 int n3 = (n + 1) / 3;
122 good = ((v -
u2) < n);
126 good = ((v + u) < (3 * n - 1));
130 int v2 = (v + 1) / 2;
131 good = ((u - v2) < n);
135 int u2 = (u + 1) / 2;
140 good = ((v + u) >= n);
154 good = (v < (3 * n2));
158 good = (u < (3 * n2));
162 good = ((u -
v) <= n2);
174 good = ((v - u) < n2);
183 good = (v < (5 * n4));
187 good = (u < (5 * n4));
191 good = ((u -
v) <= n4);
195 good = (v >= (3 * n4));
199 good = (u >= (3 * n4));
203 good = ((v - u) < n4);
241 good = ((u +
v) < (2 * n));
245 good = ((2 * u -
v) < n);
249 good = ((2 * v - u) >= n);
253 good = ((u +
v) >= (2 * n));
257 good = ((2 * u -
v) > n);
261 good = ((2 * v - u) < n);
270 good = ((v + u) < n);
280 good = ((v -
u2) >= n);
284 good = ((v + u) >= (3 * n - 1));
288 int v2 = ((v + 1) / 2);
289 good = ((u - v2) >= n);
293 int u2 = ((u + 1) / 2);
303 good = ((u +
v) < (4 * n3));
307 good = ((2 * u -
v) < n2);
311 int u2 = ((u + 1) / 2);
312 good = ((v -
u2) >= (3 * n4));
316 good = ((u +
v) >= (5 * n2));
320 good = ((2 * u -
v) > (3 * n2));
324 int u2 = ((n == 8) ? ((u + 1) / 2) : (u / 2));
325 good = ((v -
u2) < n4);
334 good = ((2 * v - u) <= (3 * n2));
338 good = ((u +
v) < (5 * n2));
342 good = ((2 * u -
v) >= (3 * n2));
346 good = ((2 * v - u) >= n3);
350 good = ((u +
v) > (4 * n3));
354 good = ((2 * u -
v) >= n2);
363 good = (v <= (3 * n4));
367 good = (u < (3 * n4));
371 good = ((v - u) >= n4);
375 good = (v >= (5 * n4));
379 good = (u >= (5 * n4));
383 good = ((u -
v) >= n4);
391 edm::LogVerbatim(
"HGCalGeom") <<
"u|v " << u <<
":" << v <<
" N " << n <<
" type " << type <<
" rot " << rotn
409 newrotn = rot1[rotn];
418 newrotn = rot2[rotn];
426 newrotn = rot3[rotn];
430 edm::LogVerbatim(
"HGCalGeom") <<
"zside " << zside <<
" type " << type <<
" rotn " << rotn <<
":" << newrotn;
447 static constexpr
int corners = 6;
448 static constexpr
int base = 10;
449 double rin2 = rin * rin;
450 double rout2 = rout * rout;
463 double xc[corners], yc[corners];
464 for (
int k = 0;
k < corners; ++
k) {
465 xc[
k] = xpos + dx0[
k];
466 yc[
k] = ypos + dy0[
k];
467 double rpos2 = (xc[
k] * xc[
k] + yc[
k] * yc[
k]);
468 if (rpos2 <= rout2 && rpos2 >= rin2) {
470 iok = iok * base + 1;
476 edm::LogVerbatim(
"HGCalGeom") <<
"I/p " << xpos <<
":" << ypos <<
":" << delX <<
":" << delY <<
":" << rin <<
":"
477 << rout <<
":" << wType <<
":" << mode <<
" Corners " << ncor <<
" iok " << iok;
479 static constexpr
int ipat5[corners] = {101111, 110111, 111011, 111101, 111110, 11111};
480 static constexpr
int ipat4[corners] = {100111, 110011, 111001, 111100, 11110, 1111};
481 static constexpr
int ipat3[corners] = {100011, 110001, 111000, 11100, 1110, 111};
482 static constexpr
int ipat2[corners] = {11, 100001, 110000, 11000, 1100, 110};
594 rotn =
static_cast<int>(
std::find(ipat5, ipat5 + 6, iok) - ipat5);
597 rotn =
static_cast<int>(
std::find(ipat4, ipat4 + 6, iok) - ipat4);
599 double rpos12 = ((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
601 if (rpos12 <= rout2 && rpos12 >= rin2) {
602 rpos22 = ((xpos + dx2[rotn]) * (xpos + dx2[rotn]) + (ypos + dy2[rotn]) * (ypos + dy2[rotn]));
603 if (rpos22 <= rout2 && rpos22 >= rin2)
610 rpos12 = ((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
611 if (rpos12 <= rout2 && rpos12 >= rin2) {
612 rpos22 = ((xpos + dx4[rotn]) * (xpos + dx4[rotn]) + (ypos + dy4[rotn]) * (ypos + dy4[rotn]));
613 if (rpos22 <= rout2 && rpos22 >= rin2)
621 rotn =
static_cast<int>(
std::find(ipat3, ipat3 + 6, iok) - ipat3);
623 double rpos12 = ((xpos + dx7[rotn]) * (xpos + dx7[rotn]) + (ypos + dy7[rotn]) * (ypos + dy7[rotn]));
625 if (rpos12 <= rout2 && rpos12 >= rin2) {
626 rpos22 = ((xpos + dx8[rotn]) * (xpos + dx8[rotn]) + (ypos + dy8[rotn]) * (ypos + dy8[rotn]));
627 if (rpos22 <= rout2 && rpos22 >= rin2)
634 rpos12 = ((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
635 if (rpos12 <= rout2 && rpos12 >= rin2) {
636 rpos22 = ((xpos + dx5[rotn]) * (xpos + dx5[rotn]) + (ypos + dy5[rotn]) * (ypos + dy5[rotn]));
637 if (rpos22 <= rout2 && rpos22 >= rin2)
645 rpos12 = ((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
646 if (rpos12 <= rout2 && rpos12 >= rin2) {
647 rpos22 = ((xpos + dx6[rotn]) * (xpos + dx6[rotn]) + (ypos + dy6[rotn]) * (ypos + dy6[rotn]));
648 if (rpos22 <= rout2 && rpos22 >= rin2)
656 rotn =
static_cast<int>(
std::find(ipat2, ipat2 + 6, iok) - ipat2);
658 double rpos12 = ((xpos + dx7[rotn]) * (xpos + dx7[rotn]) + (ypos + dy7[rotn]) * (ypos + dy7[rotn]));
660 if (rpos12 <= rout2 && rpos12 >= rin2) {
661 rpos22 = ((xpos + dx9[rotn]) * (xpos + dx9[rotn]) + (ypos + dy9[rotn]) * (ypos + dy9[rotn]));
662 if (rpos22 <= rout2 && rpos22 >= rin2)
675 edm::LogVerbatim(
"HGCalGeom") <<
"I/p " << xpos <<
":" << ypos <<
":" << delX <<
":" << delY <<
":" << rin <<
":"
676 << rout <<
":" << wType <<
":" << mode <<
" o/p " << iok <<
":" << ncor <<
":" <<
type
682 double xpos,
double ypos,
double delX,
double delY,
double rin,
double rout,
int part,
int rotn,
bool debug) {
687 double rin2 = rin * rin;
688 double rout2 = rout * rout;
692 static constexpr
int base = 10;
693 static constexpr
int base2 = 100;
746 static constexpr
int nc0[corners] = {450, 150, 201, 312, 423, 534};
748 for (
int k1 = 0; k1 < 3; ++k1) {
750 double xc1 = xpos + dx0[
k];
751 double yc1 = ypos + dy0[
k];
752 rpos2 = (xc1 * xc1 + yc1 * yc1);
753 if ((rpos2 > rout2) || (rpos2 < rin2)) {
763 static constexpr
int nc10[corners] = {450, 150, 201, 312, 423, 534};
764 static constexpr
int nc11[corners] = {700, 902, 1104, 106, 308, 510};
766 for (
int k1 = 0; k1 < 3; ++k1) {
768 double xc1 = xpos + dx0[
k];
769 double yc1 = ypos + dy0[
k];
770 rpos2 = (xc1 * xc1 + yc1 * yc1);
771 if ((rpos2 > rout2) || (rpos2 < rin2)) {
779 for (
int k1 = 0; k1 < 2; ++k1) {
781 double xc1 = xpos + dx2[
k];
782 double yc1 = ypos + dy2[
k];
783 rpos2 = (xc1 * xc1 + yc1 * yc1);
784 if ((rpos2 > rout2) || (rpos2 < rin2)) {
794 static constexpr
int nc20[corners] = {450, 150, 201, 312, 423, 534};
795 static constexpr
int nc21[corners] = {30, 14, 25, 30, 41, 52};
797 for (
int k1 = 0; k1 < 3; ++k1) {
799 double xc1 = xpos + dx0[
k];
800 double yc1 = ypos + dy0[
k];
801 rpos2 = (xc1 * xc1 + yc1 * yc1);
802 if ((rpos2 > rout2) || (rpos2 < rin2)) {
810 for (
int k1 = 0; k1 < 2; ++k1) {
812 double xc1 = xpos + dx1[
k];
813 double yc1 = ypos + dy1[
k];
814 rpos2 = (xc1 * xc1 + yc1 * yc1);
815 if ((rpos2 > rout2) || (rpos2 < rin2)) {
825 static constexpr
int nc3[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
827 for (
int k1 = 0; k1 < 4; ++k1) {
829 double xc1 = xpos + dx0[
k];
830 double yc1 = ypos + dy0[
k];
831 rpos2 = (xc1 * xc1 + yc1 * yc1);
832 if ((rpos2 > rout2) || (rpos2 < rin2)) {
842 static constexpr
int nc40[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
843 static constexpr
int nc41[corners] = {500, 702, 904, 1106, 108, 310};
845 for (
int k1 = 0; k1 < 4; ++k1) {
847 double xc1 = xpos + dx0[
k];
848 double yc1 = ypos + dy0[
k];
849 rpos2 = (xc1 * xc1 + yc1 * yc1);
850 if ((rpos2 > rout2) || (rpos2 < rin2)) {
858 for (
int k1 = 0; k1 < 2; ++k1) {
860 double xc1 = xpos + dx2[
k];
861 double yc1 = ypos + dy2[
k];
862 rpos2 = (xc1 * xc1 + yc1 * yc1);
863 if ((rpos2 > rout2) || (rpos2 < rin2)) {
873 static constexpr
int nc50[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
874 static constexpr
int nc51[corners] = {20, 13, 24, 35, 40, 51};
876 for (
int k1 = 0; k1 < 4; ++k1) {
878 double xc1 = xpos + dx0[
k];
879 double yc1 = ypos + dy0[
k];
880 rpos2 = (xc1 * xc1 + yc1 * yc1);
881 if ((rpos2 > rout2) || (rpos2 < rin2)) {
889 for (
int k1 = 0; k1 < 2; ++k1) {
891 double xc1 = xpos + dx1[
k];
892 double yc1 = ypos + dy1[
k];
893 rpos2 = (xc1 * xc1 + yc1 * yc1);
894 if ((rpos2 > rout2) || (rpos2 < rin2)) {
904 static constexpr
int nc6[corners] = {23450, 13450, 24501, 35012, 40123, 51234};
906 for (
int k1 = 0; k1 < 5; ++k1) {
908 double xc1 = xpos + dx0[
k];
909 double yc1 = ypos + dy0[
k];
910 rpos2 = (xc1 * xc1 + yc1 * yc1);
911 if ((rpos2 > rout2) || (rpos2 < rin2)) {
920 static constexpr
int nc60[corners] = {450, 150, 201, 312, 423, 534};
921 static constexpr
int nc61[corners] = {601, 803, 1005, 7, 209, 411};
923 for (
int k1 = 0; k1 < 3; ++k1) {
925 double xc1 = xpos + dx0[
k];
926 double yc1 = ypos + dy0[
k];
927 rpos2 = (xc1 * xc1 + yc1 * yc1);
928 if ((rpos2 > rout2) || (rpos2 < rin2)) {
936 for (
int k1 = 0; k1 < 2; ++k1) {
938 double xc1 = xpos + dx2[
k];
939 double yc1 = ypos + dy2[
k];
940 rpos2 = (xc1 * xc1 + yc1 * yc1);
941 if ((rpos2 > rout2) || (rpos2 < rin2)) {
951 static constexpr
int nc70[corners] = {45, 50, 1, 12, 23, 34};
952 static constexpr
int nc71[corners] = {611, 801, 1003, 5, 207, 409};
954 for (
int k1 = 0; k1 < 2; ++k1) {
956 double xc1 = xpos + dx0[
k];
957 double yc1 = ypos + dy0[
k];
958 rpos2 = (xc1 * xc1 + yc1 * yc1);
959 if ((rpos2 > rout2) || (rpos2 < rin2)) {
967 for (
int k1 = 0; k1 < 2; ++k1) {
969 double xc1 = xpos + dx2[
k];
970 double yc1 = ypos + dy2[
k];
971 rpos2 = (xc1 * xc1 + yc1 * yc1);
972 if ((rpos2 > rout2) || (rpos2 < rin2)) {
982 for (
int k = 0;
k < corners; ++
k) {
983 double xc1 = xpos + dx0[
k];
984 double yc1 = ypos + dy0[
k];
985 rpos2 = (xc1 * xc1 + yc1 * yc1);
986 if ((rpos2 > rout2) || (rpos2 < rin2)) {
997 <<
":" << xpos <<
":" << ypos <<
":" << delX <<
":" << delY <<
":" << rin <<
":"
998 << rout <<
":" << part <<
":" << rotn <<
" Results " << ok <<
":" << ncf <<
" R "
999 << rin2 <<
":" << rout2 <<
":" << rpos2;
1004 int part,
int ori,
int zside,
double delX,
double delY,
double xpos,
double ypos) {
1005 std::vector<std::pair<double, double> >
xy;
1008 edm::LogVerbatim(
"HGCalGeom") <<
"Part " << part <<
" zSide " << zside <<
" Orient " << ori <<
":" << orient;
1023 int np[7] = {0, 1, 2, 3, 4, 5, 0};
1024 for (
int k = 0;
k < 7; ++
k)
1025 xy.push_back(std::make_pair((xpos + dx[np[
k]]), (ypos + dy[np[k]])));
1027 int np[6][6] = {{0, 2, 3, 4, 5, 0},
1032 {5, 1, 2, 3, 4, 5}};
1033 for (
int k = 0;
k < 6; ++
k) {
1034 xy.push_back(std::make_pair((xpos + dx[np[orient][
k]]), (ypos + dy[np[orient][k]])));
1036 edm::LogVerbatim(
"HGCalGeom") << k <<
":" << np[orient][
k] <<
":" << dx[np[orient][
k]] <<
":"
1037 << dy[np[orient][
k]];
1042 {0, 3, 4, 5, 0}, {1, 4, 5, 0, 1}, {2, 5, 0, 1, 2}, {3, 0, 1, 2, 3}, {4, 1, 2, 3, 4}, {5, 2, 3, 4, 5}};
1043 for (
int k = 0;
k < 5; ++
k) {
1044 xy.push_back(std::make_pair((xpos + dx[np[orient][
k]]), (ypos + dy[np[orient][k]])));
1046 edm::LogVerbatim(
"HGCalGeom") << k <<
":" << np[orient][
k] <<
":" << dx[np[orient][
k]] <<
":"
1047 << dy[np[orient][
k]];
1051 int np[6][4] = {{0, 4, 5, 0}, {1, 5, 0, 1}, {2, 0, 1, 2}, {3, 1, 2, 3}, {4, 2, 3, 4}, {5, 3, 4, 5}};
1052 for (
int k = 0;
k < 4; ++
k) {
1053 xy.push_back(std::make_pair((xpos + dx[np[orient][
k]]), (ypos + dy[np[orient][k]])));
1055 edm::LogVerbatim(
"HGCalGeom") << k <<
":" << np[orient][
k] <<
":" << dx[np[orient][
k]] <<
":"
1056 << dy[np[orient][
k]];
1060 int np[6][7] = {{6, 8, 3, 4, 5, 0, 6},
1061 {7, 9, 4, 5, 0, 1, 7},
1062 {8, 10, 5, 0, 1, 2, 8},
1063 {9, 11, 0, 1, 2, 3, 9},
1064 {10, 6, 1, 2, 3, 4, 10},
1065 {11, 7, 2, 3, 4, 5, 11}};
1066 for (
int k = 0;
k < 7; ++
k) {
1067 xy.push_back(std::make_pair((xpos + dx[np[orient][
k]]), (ypos + dy[np[orient][k]])));
1069 edm::LogVerbatim(
"HGCalGeom") << k <<
":" << np[orient][
k] <<
":" << dx[np[orient][
k]] <<
":"
1070 << dy[np[orient][
k]];
1074 int np[6][6] = {{6, 9, 4, 5, 0, 6},
1075 {7, 10, 5, 0, 1, 7},
1076 {8, 11, 0, 1, 2, 8},
1078 {10, 7, 2, 3, 4, 10},
1079 {11, 8, 3, 4, 5, 11}};
1080 for (
int k = 0;
k < 6; ++
k) {
1081 xy.push_back(std::make_pair((xpos + dx[np[orient][
k]]), (ypos + dy[np[orient][k]])));
1083 edm::LogVerbatim(
"HGCalGeom") << k <<
":" << np[orient][
k] <<
":" << dx[np[orient][
k]] <<
":"
1084 << dy[np[orient][
k]];
1088 int np[6][7] = {{12, 18, 3, 4, 5, 0, 12},
1089 {13, 19, 4, 5, 0, 1, 13},
1090 {14, 20, 5, 0, 1, 2, 14},
1091 {15, 21, 0, 1, 2, 3, 15},
1092 {16, 22, 1, 2, 3, 4, 16},
1093 {17, 23, 2, 3, 4, 5, 17}};
1094 for (
int k = 0;
k < 7; ++
k) {
1095 xy.push_back(std::make_pair((xpos + dx[np[orient][
k]]), (ypos + dy[np[orient][k]])));
1097 edm::LogVerbatim(
"HGCalGeom") << k <<
":" << np[orient][
k] <<
":" << dx[np[orient][
k]] <<
":"
1098 << dy[np[orient][
k]];
1102 int np[6][6] = {{12, 19, 4, 5, 0, 12},
1103 {13, 20, 5, 0, 1, 13},
1104 {14, 21, 0, 1, 2, 14},
1105 {15, 22, 1, 2, 3, 15},
1106 {16, 23, 2, 3, 4, 16},
1107 {17, 18, 3, 4, 5, 17}};
1108 for (
int k = 0;
k < 6; ++
k) {
1109 xy.push_back(std::make_pair((xpos + dx[np[orient][
k]]), (ypos + dy[np[orient][k]])));
1111 edm::LogVerbatim(
"HGCalGeom") << k <<
":" << np[orient][
k] <<
":" << dx[np[orient][
k]] <<
":"
1112 << dy[np[orient][
k]];
1116 int np[6][6] = {{22, 15, 4, 5, 0, 22},
1117 {23, 16, 5, 0, 1, 23},
1118 {18, 17, 0, 1, 2, 18},
1119 {19, 12, 1, 2, 3, 19},
1120 {20, 13, 2, 3, 4, 20},
1121 {21, 14, 3, 4, 5, 21}};
1122 for (
int k = 0;
k < 6; ++
k) {
1123 xy.push_back(std::make_pair((xpos + dx[np[orient][
k]]), (ypos + dy[np[orient][k]])));
1125 edm::LogVerbatim(
"HGCalGeom") << k <<
":" << np[orient][
k] <<
":" << dx[np[orient][
k]] <<
":"
1126 << dy[np[orient][
k]];
1130 int np[6][5] = {{21, 15, 4, 5, 21},
1135 {20, 14, 3, 4, 20}};
1136 for (
int k = 0;
k < 5; ++
k) {
1137 xy.push_back(std::make_pair((xpos + dx[np[orient][
k]]), (ypos + dy[np[orient][k]])));
1139 edm::LogVerbatim(
"HGCalGeom") << k <<
":" << np[orient][
k] <<
":" << dx[np[orient][
k]] <<
":"
1140 << dy[np[orient][
k]];
1145 edm::LogVerbatim(
"HGCalGeom") <<
"I/p: " << part <<
":" << ori <<
":" << zside <<
":" << delX <<
":" << delY <<
":"
1146 << xpos <<
":" << ypos <<
" O/p having " << xy.size() <<
" points:";
1147 std::ostringstream st1;
1148 for (
unsigned int i = 0;
i < xy.size(); ++
i)
Log< level::Info, true > LogVerbatim
static constexpr int32_t WaferSizeMax
static std::vector< std::pair< double, double > > waferXY(int part, int orient, int zside, double delX, double delY, double xpos, double ypos)
static bool goodCell(int u, int v, int N, int type, int rotn)
static constexpr double c50
static bool goodTypeMode(double xpos, double ypos, double delX, double delY, double rin, double rout, int part, int rotn, bool debug)
static constexpr double c88
static int getRotation(int zside, int type, int rotn)
static constexpr double c27
static constexpr double c10
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
U second(std::pair< T, U > const &p)
static constexpr int32_t WaferCornerMax
static constexpr double c00
Basic2DVector< T > xy() const
auto const good
min quality of good
static std::pair< int, int > getTypeMode(const double &xpos, const double &ypos, const double &delX, const double &delY, const double &rin, const double &rout, const int &waferType, const int &mode, bool deug=false)
static constexpr double c77
static constexpr double c61
static constexpr int k_OffsetRotation
static constexpr double c75
static constexpr double c22
static bool maskCell(int u, int v, int N, int ncor, int fcor, int corners)