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 " << 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 " << 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));
71 zz.emplace_back(*zb2);
72 rin.emplace_back(
radius(*zb2, zFront1, rFront1, slope1));
73 rout.emplace_back(
radius(*zb2, zFront2, rFront2, slope2));
75 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
76 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
77 }
else if (zf2 == zb2) {
79 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:Try " << zf <<
":" << *zb1 <<
":" << zb;
82 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
83 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
84 if (
slope(*zb1, zFront1, slope1) <
tol_) {
85 zz.emplace_back(*zb1);
86 rin.emplace_back(
radius(*zb1 -
tol_, zFront1, rFront1, slope1));
87 rout.emplace_back(
radius(*zb1, zFront2, rFront2, slope2));
89 zz.emplace_back(*zb1);
90 rin.emplace_back(
radius(*zb1, zFront1, rFront1, slope1));
91 rout.emplace_back(
radius(*zb1, zFront2, rFront2, slope2));
93 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
94 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
99 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius:Try " << zf <<
":" << z1 <<
" : " <<
z2 <<
":" << zb;
102 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
103 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
105 rin.emplace_back(
radius(z1, zFront1, rFront1, slope1));
106 rout.emplace_back(
radius(z1, zFront2, rFront2, slope2));
108 rin.emplace_back(
radius(
z2, zFront1, rFront1, slope1));
109 rout.emplace_back(
radius(
z2, zFront2, rFront2, slope2));
111 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
112 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
114 double rmin = *(std::min_element(rout.begin(), rout.end()));
116 for (
auto&
rr : rout)
120 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radius has " <<
zz.size() <<
" sections: " << rmin;
121 for (
unsigned int k = 0;
k <
zz.size(); ++
k)
127 std::vector<double>
const& zFront,
128 std::vector<double>
const& rFront,
129 std::vector<double>
const&
slope) {
131 if (itrz != zFront.begin())
133 unsigned int ik = static_cast<unsigned int>(itrz - zFront.begin());
134 if ((ik + 1) < zFront.size() &&
std::abs(
z - zFront[ik + 1]) <
tol_)
136 double r = rFront[ik] + (
z - zFront[ik]) *
slope[ik];
138 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalGeomTools: Z " <<
z <<
" k " << ik <<
" R " <<
r;
144 double z,
int layer0,
int layerf, std::vector<double>
const& zFront, std::vector<double>
const& rFront) {
145 double r = rFront[0];
149 for (
unsigned int k = 0;
k < rFront.size(); ++
k) {
150 int k1 = layerf - layer0 + (
int)(
k);
151 if (k1 < (
int)(zFront.size())) {
156 if (
z < zFront[k1] +
tol_)
161 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalGeomTools: Z " <<
z <<
":" << ik <<
" R " <<
r;
168 switch (waferPosition) {
187 edm::LogVerbatim(
"HGCalGeom") <<
"Shift for " << waferPosition <<
" is (" <<
dx <<
":" <<
dy <<
")";
189 return std::make_pair(
dx,
dy);
194 if (itrz != zFront.begin())
196 unsigned int ik = static_cast<unsigned int>(itrz - zFront.begin());
199 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::slope:z " <<
z <<
" k " << ik <<
" Slope " <<
slope[ik];
206 std::vector<double>
const& zF,
207 std::vector<double>
const& rF) {
209 for (
unsigned int k = 0;
k < rF.size(); ++
k) {
216 return std::make_pair(
z,
r);
220 double xpos,
double ypos,
double r,
double R,
double rMin,
double rMax,
bool oldBug) {
225 yc[1] = ypos + 0.5 *
R;
228 yc[2] = ypos - 0.5 *
R;
231 yc[2] = ypos - 0.5 *
R;
236 yc[4] = ypos - 0.5 *
R;
238 yc[5] = ypos + 0.5 *
R;
239 int32_t nCorner(0), firstCorner(-1), firstMiss(-1);
241 std::vector<uint32_t> corners;
244 double rpos =
sqrt(xc[
k] * xc[
k] + yc[
k] * yc[
k]);
245 if ((rpos <=
rMax) && (rpos >=
rMin)) {
247 corners.emplace_back(
k);
257 if ((nCorner > 1) && (firstCorner == 0) && (firstMiss < nCorner)) {
266 edm::LogVerbatim(
"HGCalGeom") <<
"Corner[" <<
k <<
"] x " << xc[
k] <<
" y " << yc[
k] <<
" R " << rpos <<
ok;
269 return std::make_pair(nCorner, firstCorner);