44 auto circIx = [](
double O_x,
double O_y,
double r,
double phi)
55 double m = std::tan(
phi);
57 double x1 = (O_x + O_y*m - std::sqrt(-std::pow(O_x, 2)*std::pow(m, 2) + 2*O_x*O_y*m - std::pow(O_y, 2) + std::pow(m, 2)*std::pow(
r, 2) + std::pow(
r, 2)))/(std::pow(m, 2) + 1);
58 double x2 = (O_x + O_y*m + std::sqrt(-std::pow(O_x, 2)*std::pow(m, 2) + 2*O_x*O_y*m - std::pow(O_y, 2) + std::pow(m, 2)*std::pow(
r, 2) + std::pow(
r, 2)))/(std::pow(m, 2) + 1);
61 if(v1.dot(dir) > 0)
return v1;
82std::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);
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;
151 if (r_mod < (
m_minR - tolR) || r_mod > (
m_maxR + tolR)) {
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();
283 double minDist = std::numeric_limits<double>::max();
286 double currentDist{0.0};
292 currentDist =
squaredNorm(locpo_rotated-currentClosest, weightStripPC);
293 minDist = currentDist;
296 currentDist =
squaredNorm(locpo_rotated-currentClosest, weightStripPC);
297 if(currentDist < minDist) {
298 minDist = currentDist;
312 currentDist =
squaredNorm(locpoModulePC-currentClosest, weightModulePC);
313 if(currentDist < minDist) {
314 minDist = currentDist;
318 currentDist =
squaredNorm(locpoModulePC-currentClosest, weightModulePC);
319 if(currentDist < minDist) {
320 minDist = currentDist;
336 double tolPhi = tol2;
366 if (r_mod < (
m_minR - tolR) || r_mod > (
m_maxR + tolR)) {
384 double rStrip = locpo_rotated[
Trk::locR];
386 Amg::Vector2D locpoStripXY(rStrip*std::cos(phiStrip), rStrip*std::sin(phiStrip));
388 double rMod = locpoModuleXY.norm();
389 double phiMod = locpoModuleXY.phi();
392 double minDist = std::numeric_limits<double>::max();;
399 curDist = std::abs(
m_minR - rMod);
400 minDist = std::min(minDist, curDist);
407 minDist = std::min(minDist, curDist);
411 minDist = std::min(minDist, curDist);
416 curDist = std::abs(
m_maxR - rMod);
417 minDist = std::min(minDist, curDist);
422 minDist = std::min(minDist, curDist);
426 minDist = std::min(minDist, curDist);
429 Matrix2D weight = Matrix2D::Identity();
433 curDist = (closestLeft - locpoStripXY).norm();
434 if (curDist < minDist) {
440 curDist = (closestRight - locpoStripXY).norm();
441 if (curDist < minDist) {
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);
479std::array<std::pair<double, double>,4 >
483 auto to_pair = [](
const Amg::Vector2D&
v) -> std::pair<double, double>
501 return {vecModuleXY.norm(), vecModuleXY.phi()};
508 const Eigen::Matrix<double, 2, 2>& weight)
513 auto f = (n.transpose() * weight * n).value();
515 auto u = ((p -
a).transpose() * weight * n).value() / f;
517 return std::min(std::max(
u, 0.0), 1.0) * n +
a;
523 return (
v.transpose() * weight *
v).value();
double phiMax() const
Returns the left angular edge of the module.
static double squaredNorm(const Amg::Vector2D &v, const Eigen::Matrix< double, 2, 2 > &weight)
Eigen::Matrix< double, 2, 2 > Matrix2D
Amg::Vector2D m_outLeftModulePC
Amg::Vector2D stripXYToModulePC(const Amg::Vector2D &vStripXY) const
MsgStream & dump(MsgStream &sl) const override
helper which dumps the configuration into a stream.
Amg::Vector2D m_inRightStripPC
Transform2D m_rotationStripPC
Amg::Vector2D m_outRightStripPC
Eigen::Transform< double, 2, Eigen::Affine > Transform2D
bool inside(const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const override final
Returns if a point in local coordinates is inside the bounds.
Amg::Vector2D m_outLeftStripPC
double rMin() const
Returns inner radial bounds (module system)
Amg::Vector2D m_inRightModulePC
Amg::Vector2D m_inLeftStripPC
static std::pair< AnnulusBoundsPC, double > fromCartesian(const AnnulusBounds &annbo)
Static factory method to produce an instance of this class from the cartesian implementation.
double phiMin() const
Returns the right angular edge of the module.
Amg::Vector2D m_inRightStripXY
Amg::Vector2D m_outRightModulePC
Eigen::Rotation2D< double > Rotation2D
Amg::Vector2D m_inLeftModulePC
Amg::Vector2D m_inLeftStripXY
AnnulusBoundsPC(double minR, double maxR, double phiMin, double phiMax, Amg::Vector2D moduleOrigin={0, 0}, double phiAvg=0)
Default constructor from parameters.
std::vector< TDD_real_t > m_boundValues
Amg::Vector2D m_outRightStripXY
Amg::Vector2D moduleOrigin() const
Returns moduleOrigin, but rotated out, so avgPhi is already considered.
bool insideLoc2(const Amg::Vector2D &locpo, double tol2=0.) const override final
Check if local point is inside of phi bounds.
double r() const override
Returns middle radius.
std::array< std::pair< double, double >, 4 > corners() const
Returns the four corners of the bounds.
double rMax() const
Returns outer radial bounds (module system)
Amg::Vector2D m_moduleOrigin
double minDistance(const Amg::Vector2D &locpo) const override final
Return minimum distance a point is away from the bounds.
static Amg::Vector2D closestOnSegment(const Amg::Vector2D &a, const Amg::Vector2D &b, const Amg::Vector2D &p, const Eigen::Matrix< double, 2, 2 > &weight)
Transform2D m_translation
bool insideLoc1(const Amg::Vector2D &locpo, double tol1=0.) const override final
Check if local point is inside of r bounds.
Amg::Vector2D m_outLeftStripXY
Bounds for a annulus-like, planar Surface.
std::array< TDD_real_t, 4 > getEdgeLines() const
Returns the gradient and y-intercept of the left and right module edges.
const std::vector< TDD_real_t > & getBoundsValues() const
The BoundaryCheck class allows to steer the way surface boundaries are used for inside/outside checks...
int nSigmas
allowed sigmas for chi2 boundary check
double toleranceLoc2
absolute tolerance in local 2 coordinate
bool checkLoc2
check local 2 coordinate
bool checkLoc1
check local 1 coordinate
@ absolute
absolute check including tolerances
double toleranceLoc1
absolute tolerance in local 1 coordinate
Eigen::Matrix< double, 2, 1 > Vector2D
@ u
Enums for curvilinear frames.
hold the test vectors and ease the comparison