13 std::vector<double>
const& zFront1,
14 std::vector<double>
const& rFront1,
15 std::vector<double>
const& slope1,
16 std::vector<double>
const& zFront2,
17 std::vector<double>
const& rFront2,
18 std::vector<double>
const& slope2,
20 std::vector<double>&
zz,
21 std::vector<double>& rin,
22 std::vector<double>& rout) {
23 double dz1(0), dz2(0);
25 if (zf1 != zFront1.begin())
27 if (((zf1 + 1) != zFront1.end()) && (
std::abs(*(zf1 + 1) - zf) <
tol_)) {
32 if (zf2 != zFront2.begin())
35 if (zb1 != zFront1.begin())
37 if ((zb1 != zFront1.begin()) && (
std::abs(*zb1 - zb) <
tol_)) {
42 if (zb2 != zFront2.begin())
45 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:zf " << zf <<
" : " << *zf1 <<
" : " << *zf2 <<
" zb " << zb
46 <<
" : " << *zb1 <<
" : " << *zb2 <<
" Flag " <<
flag;
48 if ((zf1 == zb1) && (zf2 == zb2)) {
50 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:Try 1: " << zf <<
":" << zb <<
" dz " << dz1 <<
":" << dz2;
53 rin.emplace_back(
radius(zf + dz1, zFront1, rFront1, slope1));
54 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
56 rin.emplace_back(
radius(zb + dz2, zFront1, rFront1, slope1));
57 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
58 }
else if (zf1 == zb1) {
61 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:Try 2:" << zf <<
":" << *zb2 <<
" (" << z1 <<
") : " << zb;
64 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
65 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
66 if (
slope(*zb2, zFront2, slope2) <
tol_) {
67 zz.emplace_back(*zb2);
68 rin.emplace_back(
radius(*zb2, zFront1, rFront1, slope1));
69 rout.emplace_back(
radius(*zb2 -
tol_, zFront2, rFront2, slope2));
72 zz.emplace_back(*zb2);
73 rin.emplace_back(
radius(*zb2, zFront1, rFront1, slope1));
74 rout.emplace_back(
radius(*zb2, zFront2, rFront2, slope2));
77 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
78 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
79 }
else if (zf2 == zb2) {
81 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:Try 3: " << zf <<
":" << *zb1 <<
":" << zb;
84 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
85 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
86 if (
slope(*zb1, zFront1, slope1) <
tol_) {
87 zz.emplace_back(*zb1);
88 rin.emplace_back(
radius(*zb1 -
tol_, zFront1, rFront1, slope1));
89 rout.emplace_back(
radius(*zb1, zFront2, rFront2, slope2));
92 zz.emplace_back(*zb1);
93 rin.emplace_back(
radius(*zb1, zFront1, rFront1, slope1));
94 rout.emplace_back(
radius(*zb1, zFront2, rFront2, slope2));
97 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
98 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
103 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:Try 4: " << zf <<
":" << z1 <<
" : " <<
z2 <<
":" << zb;
106 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
107 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
109 rin.emplace_back(
radius(z1, zFront1, rFront1, slope1));
110 rout.emplace_back(
radius(z1, zFront2, rFront2, slope2));
112 rin.emplace_back(
radius(
z2, zFront1, rFront1, slope1));
113 rout.emplace_back(
radius(
z2, zFront2, rFront2, slope2));
115 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
116 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
118 double rmin = *(std::min_element(rout.begin(), rout.end()));
120 for (
auto&
rr : rout)
124 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius has " <<
zz.size() <<
" sections: " << rmin;
125 for (
unsigned int k = 0;
k <
zz.size(); ++
k)
131 std::vector<double>
const& zFront,
132 std::vector<double>
const& rFront,
133 std::vector<double>
const&
slope) {
135 if (itrz != zFront.begin())
137 unsigned int ik = static_cast<unsigned int>(itrz - zFront.begin());
138 if ((ik + 1) < zFront.size() &&
std::abs(
z - zFront[ik + 1]) <
tol_)
140 double r = rFront[ik] + (
z - zFront[ik]) *
slope[ik];
142 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalGeomTools: Z " <<
z <<
" k " << ik <<
" R " <<
r;
148 double z,
int layer0,
int layerf, std::vector<double>
const& zFront, std::vector<double>
const& rFront) {
149 double r = rFront[0];
153 for (
unsigned int k = 0;
k < rFront.size(); ++
k) {
154 int k1 = layerf - layer0 + (
int)(
k);
155 if (k1 < (
int)(zFront.size())) {
160 if (
z < zFront[k1] +
tol_)
165 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalGeomTools: Z " <<
z <<
":" << ik <<
" R " <<
r;
172 switch (waferPosition) {
191 edm::LogVerbatim(
"HGCalGeom") <<
"Shift for " << waferPosition <<
" is (" <<
dx <<
":" <<
dy <<
")";
193 return std::make_pair(
dx,
dy);
198 if (itrz != zFront.begin())
200 unsigned int ik = static_cast<unsigned int>(itrz - zFront.begin());
203 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::slope:z " <<
z <<
" k " << ik <<
" Slope " <<
slope[ik];
210 std::vector<double>
const& zF,
211 std::vector<double>
const& rF) {
213 for (
unsigned int k = 0;
k < rF.size(); ++
k) {
220 return std::make_pair(
z,
r);
224 double xpos,
double ypos,
double r,
double R,
double rMin,
double rMax,
bool oldBug) {
229 yc[1] = ypos + 0.5 *
R;
232 yc[2] = ypos - 0.5 *
R;
235 yc[2] = ypos - 0.5 *
R;
240 yc[4] = ypos - 0.5 *
R;
242 yc[5] = ypos + 0.5 *
R;
243 int32_t nCorner(0), firstCorner(-1), firstMiss(-1);
245 std::vector<uint32_t> corners;
248 double rpos =
sqrt(xc[
k] * xc[
k] + yc[
k] * yc[
k]);
249 if ((rpos <=
rMax) && (rpos >=
rMin)) {
251 corners.emplace_back(
k);
261 if ((nCorner > 1) && (firstCorner == 0) && (firstMiss < nCorner)) {
270 edm::LogVerbatim(
"HGCalGeom") <<
"Corner[" <<
k <<
"] x " << xc[
k] <<
" y " << yc[
k] <<
" R " << rpos <<
ok;
273 return std::make_pair(nCorner, firstCorner);