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);
127 double tolR = tol1, tolPhi = tol2;
131 if (phiLoc < (m_phiMin - tolPhi) || phiLoc > (m_phiMax + tolPhi)) {
141 if (r_mod2 < m_minR*m_minR || r_mod2 > m_maxR*m_maxR) {
150 if (r_mod < (m_minR - tolR) || r_mod > (m_maxR + tolR)) {
193 double dphi = m_phiAvg;
195 double r_strip = locpo_rotated[
Trk::locR];
254 double cosDPhiPhiStrip =
std::cos(dphi - phi_strip);
255 double sinDPhiPhiStrip =
std::sin(dphi - phi_strip);
257 double A = O_x*O_x + 2*O_x*r_strip*cosDPhiPhiStrip
258 + O_y*O_y - 2*O_y*r_strip*sinDPhiPhiStrip
260 double sqrtA = std::sqrt(
A);
263 double B = cosDPhiPhiStrip;
264 double C = -sinDPhiPhiStrip;
265 Eigen::Matrix<double, 2, 2> jacobianStripPCToModulePC;
266 jacobianStripPCToModulePC(0, 0) = (B*O_x + C*O_y + r_strip)/sqrtA;
267 jacobianStripPCToModulePC(0, 1) = r_strip*(B*O_y + O_x*sinDPhiPhiStrip)/sqrtA;
268 jacobianStripPCToModulePC(1, 0) = -(B*O_y - C*O_x)/
A;
269 jacobianStripPCToModulePC(1, 1) = r_strip*(B*O_x + C*O_y + r_strip)/
A;
272 Matrix2D covStripPC = bchk.lCovariance;
275 covModulePC = jacobianStripPCToModulePC * covStripPC * jacobianStripPCToModulePC.transpose();
278 Matrix2D weightStripPC = covStripPC.inverse();
279 Matrix2D weightModulePC = covModulePC.inverse();
285 double currentDist{0.0};
290 currentClosest = closestOnSegment(m_inLeftStripPC, m_outLeftStripPC, locpo_rotated, weightStripPC);
291 currentDist = squaredNorm(locpo_rotated-currentClosest, weightStripPC);
292 minDist = currentDist;
294 currentClosest = closestOnSegment(m_inRightStripPC, m_outRightStripPC, locpo_rotated, weightStripPC);
295 currentDist = squaredNorm(locpo_rotated-currentClosest, weightStripPC);
296 if(currentDist < minDist) {
297 minDist = currentDist;
304 Amg::Vector2D locpoModulePC = stripXYToModulePC(locpoStripXY);
310 currentClosest = closestOnSegment(m_inLeftModulePC, m_inRightModulePC, locpoModulePC, weightModulePC);
311 currentDist = squaredNorm(locpoModulePC-currentClosest, weightModulePC);
312 if(currentDist < minDist) {
313 minDist = currentDist;
316 currentClosest = closestOnSegment(m_outLeftModulePC, m_outRightModulePC, locpoModulePC, weightModulePC);
317 currentDist = squaredNorm(locpoModulePC-currentClosest, weightModulePC);
318 if(currentDist < minDist) {
319 minDist = currentDist;
335 double tolPhi = tol2;
338 return phiLoc >= (m_phiMin - tolPhi) && phiLoc < (m_phiMax + tolPhi);
356 if (r_mod2 < m_minR*m_minR || r_mod2 > m_maxR*m_maxR) {
365 if (r_mod < (m_minR - tolR) || r_mod > (m_maxR + tolR)) {
383 double rStrip = locpo_rotated[
Trk::locR];
387 double rMod = locpoModuleXY.norm();
388 double phiMod = locpoModuleXY.phi();
398 curDist = std::abs(m_minR - rMod);
399 minDist =
std::min(minDist, curDist);
405 curDist = (m_inLeftStripXY - locpoStripXY).
norm();
406 minDist =
std::min(minDist, curDist);
409 curDist = (m_inRightStripXY - locpoStripXY).
norm();
410 minDist =
std::min(minDist, curDist);
413 if (m_phiMin <= phiStrip && phiStrip < m_phiMax) {
415 curDist = std::abs(m_maxR - rMod);
416 minDist =
std::min(minDist, curDist);
420 curDist = (m_outLeftStripXY - locpoStripXY).
norm();
421 minDist =
std::min(minDist, curDist);
424 curDist = (m_outRightStripXY - locpoStripXY).
norm();
425 minDist =
std::min(minDist, curDist);
431 Amg::Vector2D closestLeft = closestOnSegment(m_inLeftStripXY, m_outLeftStripXY, locpoStripXY,
weight);
432 curDist = (closestLeft - locpoStripXY).
norm();
433 if (curDist < minDist) {
438 Amg::Vector2D closestRight = closestOnSegment(m_inRightStripXY, m_outRightStripXY, locpoStripXY,
weight);
439 curDist = (closestRight - locpoStripXY).
norm();
440 if (curDist < minDist) {
450 return (rMax() + rMin()) * 0.5;
455 std::stringstream
ss;
463 sl << std::setiosflags(std::ios::fixed);
464 sl << std::setprecision(7);
465 sl <<
"Trk::AnnulusBoundsPC: (minR, maxR, phiMin, phiMax, phiAvg, origin(x, y)) = " <<
"(" ;
474 sl << std::setprecision(-1);
478 std::array<std::pair<double, double>,4 >
480 auto rot = m_rotationStripPC.inverse();
482 auto to_pair = [](
const Amg::Vector2D&
v) -> std::pair<double, double>
488 to_pair(rot * m_outRightStripPC),
489 to_pair(rot * m_outLeftStripPC),
490 to_pair(rot * m_inLeftStripPC),
491 to_pair(rot * m_inRightStripPC)
500 return {vecModuleXY.norm(), vecModuleXY.phi()};
507 const Eigen::Matrix<double, 2, 2>&
weight)
522 return (
v.transpose() *
weight *
v).value();
528 return Eigen::Rotation2D<double>(m_phiAvg) * m_moduleOrigin;