14 std::vector<double>
const& zFront1,
15 std::vector<double>
const& rFront1,
16 std::vector<double>
const& slope1,
17 std::vector<double>
const& zFront2,
18 std::vector<double>
const& rFront2,
19 std::vector<double>
const& slope2,
21 std::vector<double>& zz,
22 std::vector<double>& rin,
23 std::vector<double>& rout) {
25 std::ostringstream st1;
26 st1 <<
"Z = " << zf <<
":" << zb <<
"; zFront1 =";
27 for (
const auto&
v : zFront1)
30 for (
const auto& v : rFront1)
33 for (
const auto& v : slope1)
36 for (
const auto& v : zFront2)
39 for (
const auto& v : rFront2)
42 for (
const auto& v : slope2)
45 double dz2f(0), dz2b(0);
47 double dz1f(0), dz1b(0);
49 if (zf1 != zFront1.begin())
51 if (((zf1 + 1) != zFront1.end()) && (
std::abs(*(zf1 + 1) - zf) <
tol_)) {
56 if (zf2 != zFront2.begin())
58 if (((zf2 + 1) != zFront2.end()) && (
std::abs(*(zf2 + 1) - zf) <
tol_)) {
59 if (static_cast<int>(zf2 - zFront2.begin()) >= 2)
66 if (zb1 != zFront1.begin())
68 if ((zb1 != zFront1.begin()) && (
std::abs(*zb1 - zb) <
tol_)) {
72 if (((zb1 + 1) != zFront1.end()) && (
std::abs(*(zb1 + 1) - zb) <
tol_)) {
76 if (zb2 != zFront2.begin()) {
79 if ((zb2 != zFront2.begin()) && (
std::abs(*zb2 - zb) <
tol_)) {
80 if (static_cast<int>(zb2 - zFront2.begin()) > 2)
87 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radiusX:zf " << zf <<
" : "
88 <<
static_cast<int>(zf1 - zFront1.begin()) <<
":" << *zf1 <<
" : "
89 << static_cast<int>(zf2 - zFront2.begin()) <<
":" << *zf2 <<
" zb " << zb <<
":"
90 << static_cast<int>(zb1 - zFront1.begin()) <<
" : " << *zb1 <<
" : "
91 << static_cast<int>(zb2 - zFront2.begin()) <<
":" << *zb2 <<
" Flag " << flag <<
":"
92 << (zf1 == zb1) <<
":" << (zf2 == zb2) <<
" dz " << dz1f <<
":" << dz2f <<
":" << dz1b
95 if ((zf1 == zb1) && (zf2 == zb2)) {
97 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radiusX:Try 1: " << zf <<
":" << zb;
100 rin.emplace_back(
radius(zf + dz1f, zFront1, rFront1, slope1));
101 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
103 rin.emplace_back(
radius(zb + dz1b, zFront1, rFront1, slope1));
104 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
105 }
else if (zf1 == zb1) {
108 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radiusX:Try 2:" << zf <<
":" << *zb2 <<
" (" << z1 <<
") : " << zb
109 <<
" Test " << (
slope(*zb2, zFront2, slope2) <
tol_) <<
":"
113 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
114 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
115 if (
slope(*zb2, zFront2, slope2) <
tol_) {
116 zz.emplace_back(*zb2);
117 rin.emplace_back(
radius(*zb2, zFront1, rFront1, slope1));
118 rout.emplace_back(
radius(*zb2 -
tol_, zFront2, rFront2, slope2));
121 zz.emplace_back(*zb2);
122 rin.emplace_back(
radius(*zb2, zFront1, rFront1, slope1));
123 rout.emplace_back(
radius(*zb2, zFront2, rFront2, slope2));
126 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
127 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
128 }
else if (zf2 == zb2) {
130 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radiusX:Try 3: " << zf <<
":" << *zb1 <<
":" << zb <<
" Test "
131 << (
slope(*zb1, zFront1, slope1) <
tol_) <<
":"
135 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
136 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
137 if (
slope(*zb1, zFront1, slope1) <
tol_) {
138 zz.emplace_back(*zb1);
139 rin.emplace_back(
radius(*zb1 -
tol_, zFront1, rFront1, slope1));
140 rout.emplace_back(
radius(*zb1, zFront2, rFront2, slope2));
143 zz.emplace_back(*zb1);
144 rin.emplace_back(
radius(*zb1, zFront1, rFront1, slope1));
145 rout.emplace_back(
radius(*zb1, zFront2, rFront2, slope2));
148 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
149 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
154 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radiusX:Try 4: " << zf <<
":" << z1 <<
" : " << z2 <<
":" << zb;
157 rin.emplace_back(
radius(zf, zFront1, rFront1, slope1));
158 rout.emplace_back(
radius(zf, zFront2, rFront2, slope2));
160 rin.emplace_back(
radius(z1, zFront1, rFront1, slope1));
161 rout.emplace_back(
radius(z1, zFront2, rFront2, slope2));
163 rin.emplace_back(
radius(z2, zFront1, rFront1, slope1));
164 rout.emplace_back(
radius(z2, zFront2, rFront2, slope2));
166 rin.emplace_back(
radius(zb, zFront1, rFront1, slope1));
167 rout.emplace_back(
radius(zb, zFront2, rFront2, slope2));
169 double rmin = *(std::min_element(rout.begin(), rout.end()));
171 for (
auto&
rr : rout)
175 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::radiusX has " << zz.size() <<
" sections: " << rmin;
176 for (
unsigned int k = 0;
k < zz.size(); ++
k)
177 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] Z = " << zz[
k] <<
" R = " << rin[
k] <<
":" << rout[
k];
182 std::vector<double>
const& zFront,
183 std::vector<double>
const& rFront,
184 std::vector<double>
const&
slope) {
186 std::ostringstream st1;
187 st1 <<
"Z = " << z <<
"; zFront =";
188 for (
const auto&
v : zFront)
191 for (
const auto& v : rFront)
194 for (
const auto& v : slope)
199 if (itrz != zFront.begin())
201 unsigned int ik =
static_cast<unsigned int>(itrz - zFront.begin());
202 if ((ik + 1) < zFront.size() &&
std::abs(z - zFront[ik + 1]) <
tol_)
204 double r = rFront[ik] + (z - zFront[ik]) * slope[ik];
206 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalGeomTools: Z " << z <<
" k " << ik <<
" R " <<
r;
212 double z,
int layer0,
int layerf, std::vector<double>
const& zFront, std::vector<double>
const& rFront) {
213 double r = rFront[0];
217 for (
unsigned int k = 0;
k < rFront.size(); ++
k) {
218 int k1 = layerf - layer0 + (int)(
k);
219 if (k1 < (
int)(zFront.size())) {
224 if (z < zFront[k1] +
tol_)
229 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalGeomTools: Z " << z <<
":" << ik <<
" R " <<
r;
236 switch (waferPosition) {
255 edm::LogVerbatim(
"HGCalGeom") <<
"Shift for " << waferPosition <<
" is (" <<
dx <<
":" << dy <<
")";
257 return std::make_pair(
dx, dy);
262 if (itrz != zFront.begin())
264 unsigned int ik =
static_cast<unsigned int>(itrz - zFront.begin());
267 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomTools::slope:z " << z <<
" k " << ik <<
" Slope " << slope[ik];
274 std::vector<double>
const& zF,
275 std::vector<double>
const& rF) {
277 for (
unsigned int k = 0;
k < rF.size(); ++
k) {
278 if ((z1 > zF[
k] -
tol_) && (z2 < zF[
k] +
tol_)) {
284 return std::make_pair(
z, r);
288 double xpos,
double ypos,
double r,
double R,
double rMin,
double rMax,
bool oldBug) {
293 yc[1] = ypos + 0.5 *
R;
296 yc[2] = ypos - 0.5 *
R;
299 yc[2] = ypos - 0.5 *
R;
304 yc[4] = ypos - 0.5 *
R;
306 yc[5] = ypos + 0.5 *
R;
307 int32_t nCorner(0), firstCorner(-1), firstMiss(-1);
309 std::vector<uint32_t> corners;
312 double rpos =
sqrt(xc[
k] * xc[
k] + yc[
k] * yc[
k]);
313 if ((rpos <= rMax) && (rpos >= rMin)) {
315 corners.emplace_back(k);
325 if ((nCorner > 1) && (firstCorner == 0) && (firstMiss < nCorner)) {
326 firstCorner = firstMiss + HGCalParameters::k_CornerSize - nCorner;
329 edm::LogVerbatim(
"HGCalGeom") <<
"waferCorner:: R " << rMin <<
":" << rMax << nCorner <<
" corners; first corner "
334 edm::LogVerbatim(
"HGCalGeom") <<
"Corner[" << k <<
"] x " << xc[
k] <<
" y " << yc[
k] <<
" R " << rpos <<
ok;
337 return std::make_pair(nCorner, firstCorner);
Log< level::Info, true > LogVerbatim
static const double slope[3]
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
static constexpr uint32_t k_CornerSize
Abs< T >::type abs(const T &t)
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})