21 m_moduleOrigin(moduleOrigin),
44 auto circIx = [](
double O_x,
double O_y,
double r,
double phi)
61 if(v1.dot(
dir) > 0)
return v1;
82 std::pair<Trk::AnnulusBoundsPC, double>
87 double O_x = (d_L - d_R) / (k_R - k_L);
88 double O_y = std::fma(O_x, k_L, d_L);
100 double phiMax =
phi/2.0;
101 double phiMin = -phiMax;
104 double phiShift = M_PI_2 - phiS;
109 Amg::Vector2D originStripXYRotated = avgPhiRotation * originStripXY;
115 originStripXYRotated,
118 return std::make_pair(std::move(abpc), phiShift);
128 double tolPhi = tol2;
132 if (phiLoc < (m_phiMin - tolPhi) || phiLoc > (m_phiMax + tolPhi)) {
142 if (r_mod2 < m_minR*m_minR || r_mod2 > m_maxR*m_maxR) {
151 if (r_mod < (m_minR - tolR) || r_mod > (m_maxR + tolR)) {
194 double dphi = m_phiAvg;
196 double r_strip = locpo_rotated[
Trk::locR];
255 double cosDPhiPhiStrip =
std::cos(dphi - phi_strip);
256 double sinDPhiPhiStrip =
std::sin(dphi - phi_strip);
258 double A = O_x*O_x + 2*O_x*r_strip*cosDPhiPhiStrip
259 + O_y*O_y - 2*O_y*r_strip*sinDPhiPhiStrip
261 double sqrtA = std::sqrt(
A);
264 double B = cosDPhiPhiStrip;
265 double C = -sinDPhiPhiStrip;
266 Eigen::Matrix<double, 2, 2> jacobianStripPCToModulePC;
267 jacobianStripPCToModulePC(0, 0) = (B*O_x + C*O_y + r_strip)/sqrtA;
268 jacobianStripPCToModulePC(0, 1) = r_strip*(B*O_y + O_x*sinDPhiPhiStrip)/sqrtA;
269 jacobianStripPCToModulePC(1, 0) = -(B*O_y - C*O_x)/
A;
270 jacobianStripPCToModulePC(1, 1) = r_strip*(B*O_x + C*O_y + r_strip)/
A;
273 Matrix2D covStripPC = bchk.lCovariance;
276 covModulePC = jacobianStripPCToModulePC * covStripPC * jacobianStripPCToModulePC.transpose();
279 Matrix2D weightStripPC = covStripPC.inverse();
280 Matrix2D weightModulePC = covModulePC.inverse();
286 double currentDist{0.0};
291 currentClosest = closestOnSegment(m_inLeftStripPC, m_outLeftStripPC, locpo_rotated, weightStripPC);
292 currentDist = squaredNorm(locpo_rotated-currentClosest, weightStripPC);
293 minDist = currentDist;
295 currentClosest = closestOnSegment(m_inRightStripPC, m_outRightStripPC, locpo_rotated, weightStripPC);
296 currentDist = squaredNorm(locpo_rotated-currentClosest, weightStripPC);
297 if(currentDist < minDist) {
298 minDist = currentDist;
305 Amg::Vector2D locpoModulePC = stripXYToModulePC(locpoStripXY);
311 currentClosest = closestOnSegment(m_inLeftModulePC, m_inRightModulePC, locpoModulePC, weightModulePC);
312 currentDist = squaredNorm(locpoModulePC-currentClosest, weightModulePC);
313 if(currentDist < minDist) {
314 minDist = currentDist;
317 currentClosest = closestOnSegment(m_outLeftModulePC, m_outRightModulePC, locpoModulePC, weightModulePC);
318 currentDist = squaredNorm(locpoModulePC-currentClosest, weightModulePC);
319 if(currentDist < minDist) {
320 minDist = currentDist;
336 double tolPhi = tol2;
339 return phiLoc >= (m_phiMin - tolPhi) && phiLoc < (m_phiMax + tolPhi);
357 if (r_mod2 < m_minR*m_minR || r_mod2 > m_maxR*m_maxR) {
366 if (r_mod < (m_minR - tolR) || r_mod > (m_maxR + tolR)) {
384 double rStrip = locpo_rotated[
Trk::locR];
388 double rMod = locpoModuleXY.norm();
389 double phiMod = locpoModuleXY.phi();
399 curDist = std::abs(m_minR - rMod);
400 minDist =
std::min(minDist, curDist);
406 curDist = (m_inLeftStripXY - locpoStripXY).
norm();
407 minDist =
std::min(minDist, curDist);
410 curDist = (m_inRightStripXY - locpoStripXY).
norm();
411 minDist =
std::min(minDist, curDist);
414 if (m_phiMin <= phiStrip && phiStrip < m_phiMax) {
416 curDist = std::abs(m_maxR - rMod);
417 minDist =
std::min(minDist, curDist);
421 curDist = (m_outLeftStripXY - locpoStripXY).
norm();
422 minDist =
std::min(minDist, curDist);
425 curDist = (m_outRightStripXY - locpoStripXY).
norm();
426 minDist =
std::min(minDist, curDist);
432 Amg::Vector2D closestLeft = closestOnSegment(m_inLeftStripXY, m_outLeftStripXY, locpoStripXY,
weight);
433 curDist = (closestLeft - locpoStripXY).
norm();
434 if (curDist < minDist) {
439 Amg::Vector2D closestRight = closestOnSegment(m_inRightStripXY, m_outRightStripXY, locpoStripXY,
weight);
440 curDist = (closestRight - locpoStripXY).
norm();
441 if (curDist < minDist) {
451 return (rMax() + rMin()) * 0.5;
456 std::stringstream
ss;
464 sl << std::setiosflags(std::ios::fixed);
465 sl << std::setprecision(7);
466 sl <<
"Trk::AnnulusBoundsPC: (minR, maxR, phiMin, phiMax, phiAvg, origin(x, y)) = " <<
"(" ;
475 sl << std::setprecision(-1);
479 std::array<std::pair<double, double>,4 >
481 auto rot = m_rotationStripPC.inverse();
483 auto to_pair = [](
const Amg::Vector2D&
v) -> std::pair<double, double>
489 to_pair(rot * m_outRightStripPC),
490 to_pair(rot * m_outLeftStripPC),
491 to_pair(rot * m_inLeftStripPC),
492 to_pair(rot * m_inRightStripPC)
501 return {vecModuleXY.norm(), vecModuleXY.phi()};
508 const Eigen::Matrix<double, 2, 2>&
weight)
523 return (
v.transpose() *
weight *
v).value();
529 return Eigen::Rotation2D<double>(m_phiAvg) * m_moduleOrigin;