10#include <tracking/trackingUtilities/geometry/Line2D.h>
11#include <tracking/trackingUtilities/geometry/VectorUtil.h>
13#include <tracking/trackingUtilities/numerics/EForwardBackward.h>
14#include <tracking/trackingUtilities/numerics/ERightLeft.h>
15#include <tracking/trackingUtilities/numerics/ERotation.h>
16#include <tracking/trackingUtilities/numerics/ESign.h>
18#include <Math/Vector2D.h>
30 namespace TrackingUtilities {
82 ERotation
orientation = ERotation::c_CounterClockwise);
163 ERotation
orientation = ERotation::c_CounterClockwise);
180 void setN(
const double n0,
const double n1,
const double n2,
const double n3 = 0.0)
193 void setN(
const double n0,
const ROOT::Math::XYVector&
n12,
const double n3 = 0.0)
216 setN(0.0, 0.0, 0.0, 0.0);
257 if (normalization_squared > 0)
scaleN(1.0 / std::sqrt(normalization_squared));
289 const ROOT::Math::XYVector&
n12()
const
304 return n0() == 0 and VectorUtil::isNull(
n12()) and
n3() == 0;
319 return n12().Mag2() - 4 *
n0() *
n3();
349 ROOT::Math::XYVector
gradient(
const ROOT::Math::XYVector& point)
const
351 return point * (2.0 *
n3()) +
n12();
363 ROOT::Math::XYVector
normal(
const ROOT::Math::XYVector& point)
const
365 return VectorUtil::unit(
gradient(point));
376 ROOT::Math::XYVector
tangential(
const ROOT::Math::XYVector& point)
const
378 return VectorUtil::Orthogonal(
normal(point));
387 ROOT::Math::XYVector
closest(
const ROOT::Math::XYVector& point)
const;
392 ROOT::Math::XYVector
perigee()
const;
398 ROOT::Math::XYVector
apogee()
const;
412 ROOT::Math::XYVector difference = to - from;
413 ROOT::Math::XYVector tangentialAtFrom =
tangential(from);
414 return VectorUtil::isForwardOrBackwardOf(tangentialAtFrom, difference);
432 chooseNextForwardOf(
const ROOT::Math::XYVector& start,
const ROOT::Math::XYVector& end1,
const ROOT::Math::XYVector& end2)
const;
435 std::pair<ROOT::Math::XYVector, ROOT::Math::XYVector>
451 ROOT::Math::XYVector
atCylindricalRForwardOf(
const ROOT::Math::XYVector& startPoint,
double cylindricalR)
const;
463 return n0() + point.Dot(
n12()) + point.Mag2() *
n3();
476 double distance(
const ROOT::Math::XYVector& point)
const;
509 return VectorUtil::unit(
tangential(ROOT::Math::XYVector(0.0, 0.0)));
521 return std::fabs(
impact());
542 return static_cast<ERightLeft
>(sign(
fastDistance(point)));
546 bool isLeft(
const ROOT::Math::XYVector& rhs)
const
552 bool isRight(
const ROOT::Math::XYVector& rhs)
const
599 ROOT::Math::XYVector tmp =
n12();
600 return tmp / (-2. *
n3());
606 return 2 * M_PI *
radius();
617 return static_cast<ERotation
>(sign(
n3()));
635 double arcLengthBetween(
const ROOT::Math::XYVector& from,
const ROOT::Math::XYVector& to)
const;
638 double arcLengthTo(
const ROOT::Math::XYVector& to)
const;
682 ROOT::Math::XYVector
atArcLength(
double arcLength)
const;
A two dimensional circle in its natural representation using center and radius as parameters.
GeneralizedCircle()=default
Default constructor for ROOT compatibility.
ROOT::Math::XYVector tangential(const ROOT::Math::XYVector &point) const
Tangential vector to the circle near the given position.
static GeneralizedCircle fromPerigeeParameters(double curvature, const ROOT::Math::XYVector &tangential, double impact)
Constructor of a generalized circle from perigee parameters.
double fastImpact() const
Approximate distance to the origin.
double m_n3
Memory for the fourth parameter.
double n1() const
Getter for the second circle parameter.
ROOT::Math::XYVector gradient(const ROOT::Math::XYVector &point) const
Gradient of the distance field Gives the gradient of the approximated distance field for the given po...
bool isLine() const
Indicates if the generalized circle is actually a line.
void setN(const double n0, const ROOT::Math::XYVector &n12, const double n3=0.0)
Setter for all four circle parameters.
ROOT::Math::XYVector apogee() const
Calculates the point on the circle that is furthest away from the origin.
bool isRight(const ROOT::Math::XYVector &rhs) const
Return if the point given is right of the line.
GeneralizedCircle reversed() const
Returns a copy of the circle with opposite orientation.
double fastDistance(const ROOT::Math::XYVector &point) const
Approximate distance.
bool isInvalid() const
Indicates if all circle parameters are zero.
double minimalCylindricalR() const
Gives the minimal cylindrical radius the circle reaches (unsigned)
void reverse()
Flips the orientation of the circle in place.
void setN0(const double n0)
Setter for first circle parameter.
double arcLengthBetween(const ROOT::Math::XYVector &from, const ROOT::Math::XYVector &to) const
Calculates the arc length between two points of closest approach on the circle.
double radius() const
Gives the signed radius of the circle. If it was a line this will be infinity.
void setN(const Line2D &n012)
Setter for all four circle parameters from another circle.
static GeneralizedCircle fromCenterAndRadius(const ROOT::Math::XYVector ¢er, double absRadius, ERotation orientation=ERotation::c_CounterClockwise)
Constructor from center, radius and a optional orientation.
void setCenterAndRadius(const ROOT::Math::XYVector ¢er, double absRadius, ERotation orientation=ERotation::c_CounterClockwise)
Setter for the circle center and radius.
const ROOT::Math::XYVector & 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.
bool isLeft(const ROOT::Math::XYVector &rhs) const
Return if the point given is left of the line.
ROOT::Math::XYVector closest(const ROOT::Math::XYVector &point) const
Closest approach on the circle to the point.
double omega() const
Gives the omega parameter as used by the framework helix.
void setN3(const double n3)
Setter for fourth circle parameter.
void setN1(const double n1)
Setter for second circle parameter.
double m_n0
Memory for the first parameter.
bool isValid() const
Indicates if the combination of the circle parameters makes up a valid circle.
void setN(const GeneralizedCircle &n0123)
Setter for all four circle parameters from another circle.
EForwardBackward isForwardOrBackwardOf(const ROOT::Math::XYVector &from, const ROOT::Math::XYVector &to) const
Calculates if the to vector is closer to the from vector following the along orientation of the circl...
ROOT::Math::XYVector normal(const ROOT::Math::XYVector &point) const
Normal vector to the circle near the given position.
double impact() const
Gives the signed distance of the origin to the circle.
std::pair< ROOT::Math::XYVector, ROOT::Math::XYVector > intersections(const GeneralizedCircle &generalizedCircle) const
Calculates the two points common to both circles.
void setN12(const double n1, const double n2)
Setter for second and third circle parameter.
double normalizationSquared() const
Calculates the generalized circle specific squared norm.
double absDistance(const ROOT::Math::XYVector &point) const
Gives the proper absolute distance of the point to the circle line.
double maximalCylindricalR() const
Gives the maximal cylindrical radius the circle reaches.
double distance(const ROOT::Math::XYVector &point) const
Gives the proper distance of the point to the circle line retaining the sign of the fast distance.
double arcLengthTo(const ROOT::Math::XYVector &to) const
Calculates the arc length between the perigee and the given point.
double n3() const
Getter for the fourth circle parameter.
void invalidate()
Sets all circle parameters to zero.
ERightLeft isRightOrLeft(const ROOT::Math::XYVector &point) const
Indicates if the point is on the right or left side of the circle.
ROOT::Math::XYVector perigee() const
Calculates the closest approach to the two dimensional origin.
void passiveMoveBy(const ROOT::Math::XYVector &by)
Moves the coordinate system by the given vector.
ROOT::Math::XYVector tangential() const
Gives the tangential vector at the closest approach to the origin / at the perigee.
void conformalTransform()
Transforms the generalized circle to conformal space inplace Applies the conformal map in the self-in...
void scaleN(const double factor)
Scales the circle parameters by a common factor.
double perimeter() const
Gives the perimeter of the circle.
double n2() const
Getter for the third circle parameter.
bool isCircle() const
Indicates if the generalized circle is actually a circle.
void setPerigeeParameters(const double curvature, const double tangentialPhi, const double impact)
Setter for the perigee parameters.
ROOT::Math::XYVector chooseNextForwardOf(const ROOT::Math::XYVector &start, const ROOT::Math::XYVector &end1, const ROOT::Math::XYVector &end2) const
Returns the end point which is first reached if one follows the forward direction of the circle start...
ROOT::Math::XYVector atArcLength(double arcLength) const
Calculates the point, which lies at the give perpendicular travel distance (counted from the perigee)
double curvature() const
Gives the signed curvature of the generalized circle.
double d0() const
Getter for the absolute distance to the z axes at the support point.
double absRadius() const
Gives the signed radius of the circle. If it was a line this will be infinity.
void setPerigeeParameters(double curvature, const ROOT::Math::XYVector &tangential, double impact)
Setter for the perigee parameters.
std::pair< ROOT::Math::XYVector, ROOT::Math::XYVector > atCylindricalR(double cylindricalR) const
Calculates the two points with the given cylindrical radius on the generalised circle.
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...
ROOT::Math::XYVector atCylindricalRForwardOf(const ROOT::Math::XYVector &startPoint, double cylindricalR) const
Approach on the circle with the given cylindrical radius that lies in the forward direction of a star...
void normalize()
Normalizes the circle parameters.
void setN12(const ROOT::Math::XYVector &n12)
Setter for second and third circle parameter.
double tangentialPhi() const
Gives to azimuth angle phi of the direction of flight at the perigee.
ROOT::Math::XYVector center() const
Gives the center of the circle. If it was a line both components will be infinity.
double fastDistance(const double distance) const
Helper function to translate the proper distance to the linearized distance measure of the generalize...
double n0() const
Getter for the first circle parameter.
void setN(const double n0, const double n1, const double n2, const double n3=0.0)
Setter for all four circle parameters.
ERotation orientation() const
Gives the orientation of the circle.
double arcLengthPeriod() const
Getter for the arc length for a full round of the circle.
double arcLengthToCylindricalR(double cylindricalR) const
Calculates the two dimensional arc length till the cylindrical radius is reached If the radius can no...
GeneralizedCircle conformalTransformed() const
Returns a copy of the circle in conformal space.
ROOT::Math::XYVector m_n12
Memory for the second and third parameter.
A two dimensional normal line.
const ROOT::Math::XYVector & n12() const
Getter for the unit normal vector to the line.
double n0() const
Getter for the first line parameter.
Abstract base class for different kinds of events.