8#include <tracking/trackFindingCDC/geometry/PerigeeCircle.h>
10#include <tracking/trackFindingCDC/geometry/PerigeeParameters.h>
12#include <tracking/trackFindingCDC/geometry/Circle2D.h>
13#include <tracking/trackFindingCDC/geometry/Vector2D.h>
15#include <tracking/trackFindingCDC/numerics/EForwardBackward.h>
16#include <tracking/trackFindingCDC/numerics/ERotation.h>
17#include <tracking/trackFindingCDC/numerics/Quadratic.h>
18#include <tracking/trackFindingCDC/numerics/SpecialFunctions.h>
19#include <tracking/trackFindingCDC/numerics/Angle.h>
30 namespace TrackFindingCDC {
38using namespace TrackFindingCDC;
48 : m_curvature(curvature)
49 , m_phi0(phi0Vec.phi())
56 : m_curvature(curvature)
71 : m_curvature(curvature)
119 double chiHalf = chi / 2.0;
121 double atX = arcLength * sinc(chi);
122 double atY = arcLength * sinc(chiHalf) * sin(chiHalf) +
impact();
153 double newCurvature = -
impact() * denominator;
156 double newImpact = -
curvature() / denominator;
157 return PerigeeCircle(newCurvature, newPhi0, newPhi0Vec, newImpact);
170 return (not std::isfinite(
phi0()) or not std::isfinite(
curvature()) or
193 double delta = deltaVec.
norm();
194 double deltaParallel =
phi0Vec().
dot(deltaVec);
199 double U = UVec.
norm();
222 using namespace NPerigeeParameterIndices;
223 jacobian(c_Curv, c_Curv) = 1;
224 jacobian(c_Curv, c_Phi0) = 0;
225 jacobian(c_Curv, c_I) = 0;
227 jacobian(c_Phi0, c_Curv) = deltaParallel / USquared;
228 jacobian(c_Phi0, c_Phi0) = -u * UOrthogonal / USquared;
231 jacobian(c_I, c_Curv) = (delta - dr) * (delta + dr) / U / 2;
232 jacobian(c_I, c_Phi0) = u * deltaParallel / U;
233 jacobian(c_I, c_I) = -UOrthogonal / U;
249 if (lengthSign == EForwardBackward::c_Unknown) lengthSign = EForwardBackward::c_Forward;
252 double secantLength = closestAtFrom.
distance(closestAtTo);
268 const double secantLength =
sqrt((delta + dr) * (delta - dr) / (1 + dr *
curvature()));
275 double x = secantLength *
curvature() / 2.0;
276 double arcLengthFactor = asinc(x);
277 return secantLength * arcLengthFactor;
283 const double orthogonal = ((square(
impact()) + square(cylindricalR)) *
curvature() / 2.0 +
impact()) / u;
284 const double parallel =
sqrt(square(cylindricalR) - square(orthogonal));
287 std::pair<Vector2D, Vector2D> result(atCylindricalR1, atCylindricalR2);
292 const double cylindricalR)
const
294 std::pair<Vector2D, Vector2D> candidatePoints =
atCylindricalR(cylindricalR);
306 if (fmin(arcLength1, arcLength2) == arcLength1) {
308 }
else if (fmin(arcLength1, arcLength2) == arcLength2) {
323 double U = std::sqrt(1 + A *
curvature());
324 return A / (1.0 + U);
355std::ostream& TrackFindingCDC::operator<<(std::ostream& output,
const PerigeeCircle& circle)
357 return output <<
"PerigeeCircle("
358 <<
"curvature=" << circle.
curvature() <<
","
359 <<
"phi0=" << circle.
phi0() <<
","
360 <<
"impact=" << circle.
impact() <<
")";
A two dimensional circle in its natural representation using center and radius as parameters.
Vector2D center() const
Getter for the central point of the circle.
double absRadius() const
Getter for the absolute radius.
ERotation orientation() const
Indicates if the circle is to be interpreted counterclockwise or clockwise.
A two dimensional normal line.
Extension of the generalized circle also caching the perigee coordinates.
Vector2D atArcLength(double arcLength) const
Calculates the point, which lies at the give perpendicular travel distance (counted from the perigee)
PerigeeCircle reversed() const
Returns a copy of the circle with opposite orientation.
void setCenterAndRadius(const Vector2D ¢er, double absRadius, ERotation orientation=ERotation::c_CounterClockwise)
Setter for the circle center and radius.
double fastDistance(const Vector2D &point) const
Getter for the linearised distance measure to a point.
double m_phi0
Memory for the azimuth angle of the direction of flight at the perigee.
double n1() const
Getter for the generalised circle parameters n1.
Vector2D perigee() const
Getter for the perigee point.
Vector2D gradient(const Vector2D &point) const
Gradient of the distance field, hence indicates the direction of increasing distance.
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...
double phi0() const
Getter for the azimuth angle of the direction of flight at the perigee.
double arcLengthBetween(const Vector2D &from, const Vector2D &to) const
Calculates the arc length between two points of closest approach on the circle.
bool isInvalid() const
Indicates if all circle parameters are zero.
void reverse()
Flips the orientation of the circle in place.
Vector2D normal(const Vector2D &point) const
Unit normal vector from the circle to the given point.
Vector2D chooseNextForwardOf(const Vector2D &start, const Vector2D &end1, const Vector2D &end2) const
Returns the one of two end point which is first reached from the given start if one strictly follows ...
double distance(const Vector2D &point) const
Getter for the proper signed distance of the point to the circle.
void passiveMoveBy(const Vector2D &by)
Moves the coordinates system by the given vector. Updates perigee parameters in place.
EForwardBackward isForwardOrBackwardOf(const Vector2D &from, const Vector2D &to) const
Indicates whether to given point lies in the forward direction from the perigee.
Vector2D n12() const
Getter for the generalised circle parameters n1 and n2.
double impact() const
Getter for the signed distance of the origin to the circle.
Vector2D center() const
Getter for the center of the circle. If it was a line both components will be infinity.
static PerigeeCircle fromCenterAndRadius(const Vector2D ¢er, double absRadius, ERotation orientation=ERotation::c_CounterClockwise)
Constructor from center, radius and a optional orientation.
double arcLengthAtDeltaLength(double delta, double dr) const
Helper method to calculate the arc length to a point at distance delta to the perigee and dr to circl...
const Vector2D & phi0Vec() const
Getter for the unit vector of the direction of flight at the perigee.
double n3() const
Getter for the generalised circle parameter n3.
void invalidate()
Sets all circle parameters to zero.
void conformalTransform()
Transforms the generalized circle to conformal space inplace.
double m_impact
Memory for the signed impact parameter.
double n2() const
Getter for the generalised circle parameters n2.
PerigeeCircle()
Default constructor for ROOT compatibility.
Vector2D m_phi0Vec
Cached unit direction of flight at the perigee.
double m_curvature
Memory for the signed curvature.
double curvature() const
Getter for the signed curvature.
void setN(double n0, double n1, double n2, double n3=0.0)
Setter for four generalised circle parameters.
double absRadius() const
Gives the signed radius of the circle. If it was a line this will be infinity.
Vector2D closest(const Vector2D &point) const
Calculates the point of closest approach on the circle to the given point.
double arcLengthAtSecantLength(double secantLength) const
Helper method to calculate the arc length between to points on the circle from a given direct secant ...
PerigeeCircle conformalTransformed() const
Returns a copy of the circle in conformal space.
PerigeeJacobian passiveMoveByJacobian(const Vector2D &by) const
Computes the Jacobi matrix for a move of the coordinate system by the given vector.
std::pair< Vector2D, Vector2D > atCylindricalR(double cylindricalR) const
Calculates the two points with the given cylindrical radius on the generalised circle.
double n0() const
Getter for the generalised circle parameter n0.
static PerigeeCircle fromN(double n0, double n1, double n2, double n3=0)
Constructor with the four parameters of the generalized circle.
ERotation orientation() const
Getter for the orientation of the circle.
double arcLengthPeriod() const
Getter for the arc length for a full round of the circle.
double arcLengthTo(const Vector2D &point) const
Calculates the arc length between the perigee and the given point.
double arcLengthToCylindricalR(double cylindricalR) const
Calculates the two dimensional arc length till the cylindrical radius is reached If the radius can no...
A matrix implementation to be used as an interface typ through out the track finder.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
double normalize()
Normalizes the vector to unit length.
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.
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
double distance(const Vector2D &rhs=Vector2D(0.0, 0.0)) const
Calculates the distance of this point to the rhs.
double cross(const Vector2D &rhs) const
Calculated the two dimensional cross product.
Vector2D & reverse()
Reverses the direction of the vector in place.
double phi() const
Gives the azimuth angle being the angle to the x axes ( range -M_PI to M_PI )
double normSquared() const
Calculates .
Vector2D orthogonal() const
Orthogonal vector to the counterclockwise direction.
double first() const
Getter for the first coordinate.
double norm() const
Calculates the length of the vector.
static Vector2D Phi(const double phi)
Constructs a unit vector with azimuth angle equal to phi.
double sqrt(double a)
sqrt for double
bool isValid(EForwardBackward eForwardBackward)
Check whether the given enum instance is one of the valid values.
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
EPerigeeParameter
Enumeration to address the individual perigee parameters in a vector or matrix.
ERotation
Enumeration to represent the distinct possibilities of the right left passage information.
ERotation reversed(ERotation eRotation)
Return the reversed rotation. Leaves ERotation::c_Invalid the same.
Abstract base class for different kinds of events.
static void normalise(double &angle)
Normalise an angle inplace to lie in the range from [-pi, pi].
static double reversed(const double angle)
Get the angle that point in the opposite direction.
static CovarianceMatrix identity()
Returns an identity matrix.