 |
Belle II Software
release-05-01-25
|
10 #include <tracking/trackFindingCDC/geometry/GeneralizedCircle.h>
12 #include <tracking/trackFindingCDC/geometry/Circle2D.h>
13 #include <tracking/trackFindingCDC/geometry/Line2D.h>
14 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
16 #include <tracking/trackFindingCDC/numerics/EForwardBackward.h>
17 #include <tracking/trackFindingCDC/numerics/ERotation.h>
19 #include <tracking/trackFindingCDC/numerics/SpecialFunctions.h>
20 #include <tracking/trackFindingCDC/numerics/Quadratic.h>
26 using namespace TrackFindingCDC;
63 : m_n3(1.0 / 2.0 / circle.radius())
64 , m_n12(-circle.center().x() * (m_n3 * 2.0), -circle.center().y() * (m_n3 * 2.0))
65 , m_n0((circle.center().normSquared() - circle.radiusSquared()) * m_n3)
70 const double absRadius,
75 return generalizedCircle;
84 return generalizedCircle;
88 const double tangentialPhi,
93 return generalizedCircle;
97 const double absRadius,
133 double closestOrthogonal =
n12().
cross(point) / gradientAtPoint.
norm();
139 double closestParallel = 0.0;
141 closestParallel = -(nOrthogonal * closestOrthogonal +
n0()) / nParallel;
144 const double a =
n3();
145 const double b = nParallel;
146 const double c =
n0() + (nOrthogonal +
n3() * closestOrthogonal) * closestOrthogonal;
148 const std::pair<double, double> closestParallel12 = solveQuadraticABC(a, b, c);
153 const double criterion1 =
154 closestParallel12.first * (closestParallel12.first - 2 * pointParallel);
155 const double criterion2 =
156 closestParallel12.second * (closestParallel12.second - 2 * pointParallel);
158 closestParallel = criterion1 < criterion2 ? closestParallel12.first : closestParallel12.second;
166 result.setCylindricalR(-
impact());
184 if (lengthOnCurve1 >= 0.0) {
186 if (lengthOnCurve2 >= 0.0) {
187 return lengthOnCurve1 < lengthOnCurve2 ? end1 : end2;
193 if (lengthOnCurve2 >= 0.0) {
204 return lengthOnCurve1 < lengthOnCurve2 ? end1 : end2;
223 const double sameCylindricalRParallel = -(
n0() +
n3() * square(cylindricalR)) /
n12().
norm();
226 const double sameCylindricalROrthogonal = sqrt(square(cylindricalR) - square(sameCylindricalRParallel));
235 std::pair<Vector2D, Vector2D> result(sameCylindricalR1, sameCylindricalR2);
240 const double cylindricalR)
const
242 std::pair<Vector2D, Vector2D> candidatePoints =
atCylindricalR(cylindricalR);
252 if (lengthSign == EForwardBackward::c_Unknown) lengthSign = EForwardBackward::c_Forward;
256 double directDistance = closestAtFrom.
distance(closestAtTo);
269 if (lengthSign == EForwardBackward::c_Unknown) lengthSign = EForwardBackward::c_Forward;
271 const Vector2D& closestAtFrom = from;
273 double directDistance = closestAtFrom.
distance(closestAtTo);
285 const double dr =
d0();
286 const double directDistance =
287 sqrt((cylindricalR + dr) * (cylindricalR - dr) / (1 + dr *
omega()));
288 const double arcLength =
arcLengthFactor(directDistance) * directDistance;
294 double x = directDistance *
curvature / 2.0;
312 const double a =
n3();
316 std::pair<double, double> distance12 = solveQuadraticABC(a, b, c);
319 return distance12.second;
323 std::pair<Vector2D, Vector2D>
326 const double m0 = generalizedCircle.
n0();
328 const double m3 = generalizedCircle.
n3();
330 const double n0 = this->
n0();
332 const double n3 = this->
n3();
337 double xParallel = (m0 *
n3 - m3 *
n0) / absC;
345 double b = mn12Orthogonal;
346 double c = (a * xParallel + mn12Parallel) * xParallel + m0 +
n0;
348 std::pair<double, double> xOrthogonal = solveQuadraticABC(a, b, c);
357 double chiHalf = chi / 2.0;
359 double atX = arcLength * sinc(chiHalf) * sin(chiHalf) +
impact();
360 double atY = -arcLength * sinc(chi);
367 output <<
"Line support point = " << circle.
perigee();
370 output <<
"CircleCenter = " << circle.
center() <<
", Radius = " << circle.
absRadius();
Vector2D tangential() const
Gives the tangential vector at the closest approach to the origin / at the perigee.
Vector2D orthogonal() const
Orthogonal vector to the counterclockwise direction.
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
Vector2D unit() const
Returns a unit vector colaligned with this.
EForwardBackward isForwardOrBackwardOf(const Vector2D &from, const Vector2D &to) const
Calculates if the to vector is closer to the from vector following the along orientation of the circl...
void setCenterAndRadius(const Vector2D ¢er, double absRadius, ERotation orientation=ERotation::c_CounterClockwise)
Setter for the circle center and radius.
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
double normalize()
Normalizes the vector to unit length.
double normSquared() const
Calculates .
double tangentialPhi() const
Gives to azimuth angle phi of the direction of flight at the perigee.
double y() const
Getter for the y coordinate.
Vector2D atCylindricalRForwardOf(const Vector2D &startPoint, double cylindricalR) const
Approach on the circle with the given cylindrical radius that lies in the forward direction of a star...
void setN3(const double n3)
Setter for fourth circle parameter.
double second() const
Getter for the second coordinate.
bool isValid(EForwardBackward eForwardBackward)
Check whether the given enum instance is one of the valid values.
double omega() const
Gives the omega parameter as used by the framework helix.
double d0() const
Getter for the absolute distance to the z axes at the support point.
A two dimensional circle in its natural representation using center and radius as parameters.
Vector2D atArcLength(double arcLength) const
Calculates the point, which lies at the give perpendicular travel distance (counted from the perigee)
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
double distance(const Vector2D &rhs=Vector2D(0.0, 0.0)) const
Calculates the distance of this point to the rhs.
double distance(const Vector2D &point) const
Gives the proper distance of the point to the circle line retaining the sign of the fast distance.
double radius() const
Gives the signed radius of the circle. If it was a line this will be infinity.
GeneralizedCircle()
Default constructor for ROOT compatibility.
double first() const
Getter for the first coordinate.
double n3() const
Getter for the fourth circle parameter.
double cross(const Vector2D &rhs) const
Calculated the two dimensional cross product.
double arcLengthTo(const Vector2D &to) const
Calculates the arc length between the perigee and the given point.
Vector2D apogee() const
Calculates the point on the circle that is furthest away from the origin.
void setN(const double n0, const double n1, const double n2, const double n3=0.0)
Setter for all four circle parameters.
double fastDistance(const Vector2D &point) const
Approximate distance.
Vector2D perigee() const
Calculates the closest approach to the two dimensional origin.
Vector2D gradient(const Vector2D &point) const
Gradient of the distance field Gives the gradient of the approximated distance field for the given po...
std::pair< Vector2D, Vector2D > intersections(const GeneralizedCircle &generalizedCircle) const
Calculates the two points common to both circles.
ERotation orientation() const
Gives the orientation of the circle.
Abstract base class for different kinds of events.
void setN0(const double n0)
Setter for first circle parameter.
static GeneralizedCircle fromPerigeeParameters(double curvature, const Vector2D &tangential, double impact)
Constructor of a generalized circle from perigee parameters.
double arcLengthFactor(const double directDistance) const
Helper function the calculate the factor between the length of a secant line and the length on the ar...
double arcLengthToCylindricalR(double cylindricalR) const
Calculates the two dimensional arc length till the cylindrical radius is reached If the radius can no...
double impact() const
Gives the signed distance of the origin to the circle.
double unnormalizedParallelComp(const Vector2D &relativTo) const
Same as parallelComp() but assumes the given vector to be of unit length.
double curvature() const
Gives the signed curvature of the generalized circle.
Vector2D center() const
Gives the center of the circle. If it was a line both components will be infinity.
Vector2D chooseNextForwardOf(const Vector2D &start, const Vector2D &end1, const Vector2D &end2) const
Returns the end point which is first reached if one follows the forward direction of the circle start...
ERotation
Enumeration to represent the distinct possibilities of the right left passage information.
static GeneralizedCircle fromCenterAndRadius(const Vector2D ¢er, double absRadius, ERotation orientation=ERotation::c_CounterClockwise)
Constructor from center, radius and a optional orientation.
double x() const
Getter for the x coordinate.
A two dimensional normal line.
std::pair< Belle2::TrackFindingCDC::Vector2D, Belle2::TrackFindingCDC::Vector2D > atCylindricalR(double cylindricalR) const
Calculates the two points with the given cylindrical radius on the generalised circle.
double norm() const
Calculates the length of the vector.
double n0() const
Getter for the first circle parameter.
void normalize()
Normalizes the circle parameters.
bool isLine() const
Indicates if the generalized circle is actually a line.
Vector2D closest(const Vector2D &point) const
Closest approach on the circle to the point.
void setN1(const double n1)
Setter for second circle parameter.
const Vector2D & n12() const
Getter for the second and third circle parameter which natuarally from a vector.
void setN2(const double n2)
Setter for third circle parameter.
static Vector2D compose(const Vector2D &coordinateVec, const double parallelCoor, const double orthoCoor)
Constructs a vector from a unit coordinate system vector and the coordinates in that system.
void setPerigeeParameters(double curvature, const Vector2D &tangential, double impact)
Setter for the perigee parameters.
double unnormalizedOrthogonalComp(const Vector2D &relativTo) const
Same as orthogonalComp() but assumes the given vector to be of unit length.
double absRadius() const
Gives the signed radius of the circle. If it was a line this will be infinity.
double arcLengthBetween(const Vector2D &from, const Vector2D &to) const
Calculates the arc length between two points of closest approach on the circle.