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
121 good = ((
v -
u2) <
n);
125 good = ((
v + u) < (3 *
n - 1));
129 int v2 = (
v + 1) / 2;
130 good = ((u - v2) <
n);
134 int u2 = (u + 1) / 2;
139 good = ((
v + u) >=
n);
153 good = (
v < (3 * n2));
157 good = (u < (3 * n2));
161 good = ((u -
v) <= n2);
173 good = ((
v - u) < n2);
182 good = (
v < (5 * n4));
186 good = (u < (5 * n4));
190 good = ((u -
v) <= n4);
194 good = (
v >= (3 * n4));
198 good = (u >= (3 * n4));
202 good = ((
v - u) < n4);
240 good = ((u +
v) < (2 *
n));
244 good = ((2 * u -
v) <
n);
248 good = ((2 *
v - u) >=
n);
252 good = ((u +
v) >= (2 *
n));
256 good = ((2 * u -
v) >
n);
260 good = ((2 *
v - u) <
n);
269 good = ((
v + u) <
n);
279 good = ((
v -
u2) >=
n);
283 good = ((
v + u) >= (3 *
n - 1));
287 int v2 = ((
v + 1) / 2);
288 good = ((u - v2) >=
n);
292 int u2 = ((u + 1) / 2);
302 int n3 = (
n + 1) / 3;
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);
333 edm::LogVerbatim(
"HGCalGeom") <<
"u|v " << u <<
":" <<
v <<
" N " <<
n <<
" type " <<
type <<
" rot " << rotn
351 newrotn = rot1[rotn];
360 newrotn = rot2[rotn];
368 newrotn = rot3[rotn];
389 static constexpr
int corners = 6;
390 static constexpr
int base = 10;
391 double rin2 = rin * rin;
392 double rout2 = rout * rout;
393 double dx0[corners] = {
401 double xc[corners], yc[corners];
402 for (
int k = 0;
k < corners; ++
k) {
403 xc[
k] = xpos + dx0[
k];
404 yc[
k] = ypos + dy0[
k];
405 double rpos2 = (xc[
k] * xc[
k] + yc[
k] * yc[
k]);
406 if (rpos2 <= rout2 && rpos2 >= rin2) {
408 iok = iok *
base + 1;
414 edm::LogVerbatim(
"HGCalGeom") <<
"I/p " << xpos <<
":" << ypos <<
":" << delX <<
":" << delY <<
":" << rin <<
":"
415 << rout <<
":" << wType <<
":" <<
mode <<
" Corners " << ncor <<
" iok " << iok;
417 static constexpr
int ipat5[corners] = {101111, 110111, 111011, 111101, 111110, 11111};
418 static constexpr
int ipat4[corners] = {100111, 110011, 111001, 111100, 11110, 1111};
419 static constexpr
int ipat3[corners] = {100011, 110001, 111000, 11100, 1110, 111};
426 double dy1[corners] = {
434 double dy2[corners] = {
436 double dx3[corners] = {
462 double dy5[corners] = {
479 rotn = static_cast<int>(
std::find(ipat5, ipat5 + 6, iok) - ipat5);
482 rotn = static_cast<int>(
std::find(ipat4, ipat4 + 6, iok) - ipat4);
484 double rpos12 = ((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
486 if (rpos12 <= rout2 && rpos12 >= rin2) {
487 rpos22 = ((xpos + dx2[rotn]) * (xpos + dx2[rotn]) + (ypos + dy2[rotn]) * (ypos + dy2[rotn]));
488 if (rpos22 <= rout2 && rpos22 >= rin2)
495 rpos12 = ((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
496 if (rpos12 <= rout2 && rpos12 >= rin2) {
497 rpos22 = ((xpos + dx4[rotn]) * (xpos + dx4[rotn]) + (ypos + dy4[rotn]) * (ypos + dy4[rotn]));
498 if (rpos22 <= rout2 && rpos22 >= rin2)
506 rotn = static_cast<int>(
std::find(ipat3, ipat3 + 6, iok) - ipat3);
508 double rpos12 = ((xpos + dx1[rotn]) * (xpos + dx1[rotn]) + (ypos + dy1[rotn]) * (ypos + dy1[rotn]));
510 if (rpos12 <= rout2 && rpos12 >= rin2) {
511 rpos22 = ((xpos + dx5[rotn]) * (xpos + dx5[rotn]) + (ypos + dy5[rotn]) * (ypos + dy5[rotn]));
512 if (rpos22 <= rout2 && rpos22 >= rin2)
519 rpos12 = ((xpos + dx3[rotn]) * (xpos + dx3[rotn]) + (ypos + dy3[rotn]) * (ypos + dy3[rotn]));
520 if (rpos12 <= rout2 && rpos12 >= rin2) {
521 rpos22 = ((xpos + dx6[rotn]) * (xpos + dx6[rotn]) + (ypos + dy6[rotn]) * (ypos + dy6[rotn]));
522 if (rpos22 <= rout2 && rpos22 >= rin2)
534 edm::LogVerbatim(
"HGCalGeom") <<
"I/p " << xpos <<
":" << ypos <<
":" << delX <<
":" << delY <<
":" << rin <<
":"
535 << rout <<
":" << wType <<
":" <<
mode <<
" o/p " << iok <<
":" << ncor <<
":" <<
type
541 double xpos,
double ypos,
double delX,
double delY,
double rin,
double rout,
int part,
int rotn,
bool debug) {
546 double rin2 = rin * rin;
547 double rout2 = rout * rout;
550 static constexpr
int base = 10;
551 static constexpr
int base2 = 100;
552 double dx0[corners] = {
566 double dy1[corners] = {
596 static constexpr
int nc0[corners] = {450, 150, 201, 312, 423, 534};
598 for (
int k1 = 0; k1 < 3; ++k1) {
600 double xc1 = xpos + dx0[
k];
601 double yc1 = ypos + dy0[
k];
602 double rpos2 = (xc1 * xc1 + yc1 * yc1);
603 if ((rpos2 > rout2) || (rpos2 < rin2)) {
613 static constexpr
int nc10[corners] = {450, 150, 201, 312, 423, 534};
614 static constexpr
int nc11[corners] = {700, 902, 1104, 106, 308, 510};
616 for (
int k1 = 0; k1 < 3; ++k1) {
618 double xc1 = xpos + dx0[
k];
619 double yc1 = ypos + dy0[
k];
620 double rpos2 = (xc1 * xc1 + yc1 * yc1);
621 if ((rpos2 > rout2) || (rpos2 < rin2)) {
629 for (
int k1 = 0; k1 < 2; ++k1) {
631 double xc1 = xpos + dx2[
k];
632 double yc1 = ypos + dy2[
k];
633 double rpos2 = (xc1 * xc1 + yc1 * yc1);
634 if ((rpos2 > rout2) || (rpos2 < rin2)) {
644 static constexpr
int nc20[corners] = {450, 150, 201, 312, 423, 534};
645 static constexpr
int nc21[corners] = {30, 14, 25, 30, 41, 52};
647 for (
int k1 = 0; k1 < 3; ++k1) {
649 double xc1 = xpos + dx0[
k];
650 double yc1 = ypos + dy0[
k];
651 double rpos2 = (xc1 * xc1 + yc1 * yc1);
652 if ((rpos2 > rout2) || (rpos2 < rin2)) {
660 for (
int k1 = 0; k1 < 2; ++k1) {
662 double xc1 = xpos + dx1[
k];
663 double yc1 = ypos + dy1[
k];
664 double rpos2 = (xc1 * xc1 + yc1 * yc1);
665 if ((rpos2 > rout2) || (rpos2 < rin2)) {
675 static constexpr
int nc3[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
677 for (
int k1 = 0; k1 < 4; ++k1) {
679 double xc1 = xpos + dx0[
k];
680 double yc1 = ypos + dy0[
k];
681 double rpos2 = (xc1 * xc1 + yc1 * yc1);
682 if ((rpos2 > rout2) || (rpos2 < rin2)) {
692 static constexpr
int nc40[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
693 static constexpr
int nc41[corners] = {500, 702, 904, 1106, 108, 310};
695 for (
int k1 = 0; k1 < 4; ++k1) {
697 double xc1 = xpos + dx0[
k];
698 double yc1 = ypos + dy0[
k];
699 double rpos2 = (xc1 * xc1 + yc1 * yc1);
700 if ((rpos2 > rout2) || (rpos2 < rin2)) {
708 for (
int k1 = 0; k1 < 2; ++k1) {
710 double xc1 = xpos + dx2[
k];
711 double yc1 = ypos + dy2[
k];
712 double rpos2 = (xc1 * xc1 + yc1 * yc1);
713 if ((rpos2 > rout2) || (rpos2 < rin2)) {
723 static constexpr
int nc50[corners] = {3450, 1450, 2501, 3012, 4123, 5234};
724 static constexpr
int nc51[corners] = {20, 13, 24, 35, 40, 51};
726 for (
int k1 = 0; k1 < 4; ++k1) {
728 double xc1 = xpos + dx0[
k];
729 double yc1 = ypos + dy0[
k];
730 double rpos2 = (xc1 * xc1 + yc1 * yc1);
731 if ((rpos2 > rout2) || (rpos2 < rin2)) {
739 for (
int k1 = 0; k1 < 2; ++k1) {
741 double xc1 = xpos + dx1[
k];
742 double yc1 = ypos + dy1[
k];
743 double rpos2 = (xc1 * xc1 + yc1 * yc1);
744 if ((rpos2 > rout2) || (rpos2 < rin2)) {
754 static constexpr
int nc6[corners] = {23450, 13450, 24501, 35012, 40123, 51234};
756 for (
int k1 = 0; k1 < 5; ++k1) {
758 double xc1 = xpos + dx0[
k];
759 double yc1 = ypos + dy0[
k];
760 double rpos2 = (xc1 * xc1 + yc1 * yc1);
761 if ((rpos2 > rout2) || (rpos2 < rin2)) {
770 for (
int k = 0;
k < corners; ++
k) {
771 double xc1 = xpos + dx0[
k];
772 double yc1 = ypos + dy0[
k];
773 double rpos2 = (xc1 * xc1 + yc1 * yc1);
774 if ((rpos2 > rout2) || (rpos2 < rin2)) {
785 <<
":" << xpos <<
":" << ypos <<
":" << delX <<
":" << delY <<
":" << rin <<
":"
786 << rout <<
":" <<
part <<
":" << rotn <<
" Results " <<
ok <<
":" << ncf;
791 int part,
int ori,
int zside,
double delX,
double delY,
double xpos,
double ypos) {
792 std::vector<std::pair<double, double> >
xy;
810 int np[7] = {0, 1, 2, 3, 4, 5, 0};
811 for (
int k = 0;
k < 7; ++
k)
812 xy.push_back(std::make_pair((xpos +
dx[
np[
k]]), (ypos +
dy[
np[
k]])));
814 int np[6][6] = {{0, 2, 3, 4, 5, 0},
820 for (
int k = 0;
k < 6; ++
k) {
829 {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}};
830 for (
int k = 0;
k < 5; ++
k) {
838 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}};
839 for (
int k = 0;
k < 4; ++
k) {
847 int np[6][7] = {{6, 8, 3, 4, 5, 0, 6},
848 {7, 9, 4, 5, 0, 1, 7},
849 {8, 10, 5, 0, 1, 2, 8},
850 {9, 11, 0, 1, 2, 3, 9},
851 {10, 6, 1, 2, 3, 4, 10},
852 {11, 7, 2, 3, 4, 5, 11}};
853 for (
int k = 0;
k < 7; ++
k) {
861 int np[6][6] = {{6, 9, 4, 5, 0, 6},
865 {10, 7, 2, 3, 4, 10},
866 {11, 8, 3, 4, 5, 11}};
867 for (
int k = 0;
k < 6; ++
k) {
875 int np[6][7] = {{12, 18, 3, 4, 5, 0, 12},
876 {13, 19, 4, 5, 0, 1, 13},
877 {14, 20, 5, 0, 1, 2, 14},
878 {15, 21, 0, 1, 2, 3, 15},
879 {16, 22, 1, 2, 3, 4, 16},
880 {17, 23, 2, 3, 4, 5, 17}};
881 for (
int k = 0;
k < 7; ++
k) {
889 int np[6][6] = {{12, 19, 4, 5, 0, 12},
890 {13, 20, 5, 0, 1, 13},
891 {14, 21, 0, 1, 2, 14},
892 {15, 22, 1, 2, 3, 15},
893 {16, 23, 2, 3, 4, 16},
894 {17, 18, 3, 4, 5, 17}};
895 for (
int k = 0;
k < 6; ++
k) {
905 << xpos <<
":" << ypos <<
" O/p having " <<
xy.size() <<
" points:";
906 std::ostringstream st1;
907 for (
unsigned int i = 0;
i <
xy.size(); ++
i)