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_)) {
41 if (((zb1 + 1) != zFront1.end()) && (
std::abs(*(zb1 + 1) - zb) <
tol_)) {
45 if (zb2 != zFront2.begin())
49 << static_cast<int>(zf1 - zFront1.begin()) <<
":" << *zf1 <<
" : "
50 << static_cast<int>(zf2 - zFront2.begin()) <<
":" << *zf2 <<
" zb " << zb <<
":"
51 << static_cast<int>(zb1 - zFront1.begin()) <<
" : " << *zb1 <<
" : "
52 << static_cast<int>(zb2 - zFront2.begin()) <<
":" << *zb2 <<
" Flag " <<
flag;
54 if ((zf1 == zb1) && (zf2 == zb2)) {
56 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:Try 1: " << zf <<
":" << zb <<
" dz " << dz1 <<
":" << dz2;
59 rin.emplace_back(
radius(zf + dz1, zFront1, rFront1, slope1));
60 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
62 rin.emplace_back(
radius(zb + dz2, zFront1, rFront1, slope1));
63 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
64 }
else if (zf1 == zb1) {
67 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:Try 2:" << zf <<
":" << *zb2 <<
" (" << z1 <<
") : " << zb;
70 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
71 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
72 if (
slope(*zb2, zFront2, slope2) <
tol_) {
73 zz.emplace_back(*zb2);
74 rin.emplace_back(
radius(*zb2, zFront1, rFront1, slope1));
75 rout.emplace_back(
radius(*zb2 -
tol_, zFront2, rFront2, slope2));
78 zz.emplace_back(*zb2);
79 rin.emplace_back(
radius(*zb2, zFront1, rFront1, slope1));
80 rout.emplace_back(
radius(*zb2, zFront2, rFront2, slope2));
83 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
84 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
85 }
else if (zf2 == zb2) {
87 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:Try 3: " << zf <<
":" << *zb1 <<
":" << zb;
90 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
91 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
92 if (
slope(*zb1, zFront1, slope1) <
tol_) {
93 zz.emplace_back(*zb1);
94 rin.emplace_back(
radius(*zb1 -
tol_, zFront1, rFront1, slope1));
95 rout.emplace_back(
radius(*zb1, zFront2, rFront2, slope2));
98 zz.emplace_back(*zb1);
99 rin.emplace_back(
radius(*zb1, zFront1, rFront1, slope1));
100 rout.emplace_back(
radius(*zb1, zFront2, rFront2, slope2));
103 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
104 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
109 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:Try 4: " << zf <<
":" << z1 <<
" : " <<
z2 <<
":" << zb;
112 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
113 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
115 rin.emplace_back(
radius(z1, zFront1, rFront1, slope1));
116 rout.emplace_back(
radius(z1, zFront2, rFront2, slope2));
118 rin.emplace_back(
radius(
z2, zFront1, rFront1, slope1));
119 rout.emplace_back(
radius(
z2, zFront2, rFront2, slope2));
121 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
122 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
124 double rmin = *(std::min_element(rout.begin(), rout.end()));
126 for (
auto&
rr : rout)
130 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius has " <<
zz.size() <<
" sections: " << rmin;
131 for (
unsigned int k = 0;
k <
zz.size(); ++
k)
137 std::vector<double>
const& zFront,
138 std::vector<double>
const& rFront,
139 std::vector<double>
const&
slope) {
141 if (itrz != zFront.begin())
143 unsigned int ik = static_cast<unsigned int>(itrz - zFront.begin());
144 if ((ik + 1) < zFront.size() &&
std::abs(
z - zFront[ik + 1]) <
tol_)
146 double r = rFront[ik] + (
z - zFront[ik]) *
slope[ik];
148 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalGeomTools: Z " <<
z <<
" k " << ik <<
" R " <<
r;
154 double z,
int layer0,
int layerf, std::vector<double>
const& zFront, std::vector<double>
const& rFront) {
155 double r = rFront[0];
159 for (
unsigned int k = 0;
k < rFront.size(); ++
k) {
160 int k1 = layerf - layer0 + (
int)(
k);
161 if (k1 < (
int)(zFront.size())) {
166 if (
z < zFront[k1] +
tol_)
171 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalGeomTools: Z " <<
z <<
":" << ik <<
" R " <<
r;
178 switch (waferPosition) {
197 edm::LogVerbatim(
"HGCalGeom") <<
"Shift for " << waferPosition <<
" is (" <<
dx <<
":" <<
dy <<
")";
199 return std::make_pair(
dx,
dy);
204 if (itrz != zFront.begin())
206 unsigned int ik = static_cast<unsigned int>(itrz - zFront.begin());
209 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::slope:z " <<
z <<
" k " << ik <<
" Slope " <<
slope[ik];
216 std::vector<double>
const& zF,
217 std::vector<double>
const& rF) {
219 for (
unsigned int k = 0;
k < rF.size(); ++
k) {
226 return std::make_pair(
z,
r);
230 double xpos,
double ypos,
double r,
double R,
double rMin,
double rMax,
bool oldBug) {
235 yc[1] = ypos + 0.5 *
R;
238 yc[2] = ypos - 0.5 *
R;
241 yc[2] = ypos - 0.5 *
R;
246 yc[4] = ypos - 0.5 *
R;
248 yc[5] = ypos + 0.5 *
R;
249 int32_t nCorner(0), firstCorner(-1), firstMiss(-1);
251 std::vector<uint32_t> corners;
254 double rpos =
sqrt(xc[
k] * xc[
k] + yc[
k] * yc[
k]);
255 if ((rpos <=
rMax) && (rpos >=
rMin)) {
257 corners.emplace_back(
k);
267 if ((nCorner > 1) && (firstCorner == 0) && (firstMiss < nCorner)) {
276 edm::LogVerbatim(
"HGCalGeom") <<
"Corner[" <<
k <<
"] x " << xc[
k] <<
" y " << yc[
k] <<
" R " << rpos <<
ok;
279 return std::make_pair(nCorner, firstCorner);