8#include <tracking/trackFindingCDC/numerics/SinEqLine.h>
10#include <framework/logging/Logger.h>
15using namespace TrackFindingCDC;
21 if (root > 0)
return root;
26 if (root > 0)
return root;
28 for (
int iHalfPeriod = 1; iHalfPeriod <= maxIHalfPeriod; ++iHalfPeriod) {
32 if (root > 0)
return root;
57 if (xLineIsPlusOne > xLineIsMinusOne) {
60 }
else if (xLineIsPlusOne < xLineIsMinusOne) {
69 if (not(lowerX < upperX))
return NAN;
77 B2INFO(
"Coverage early");
95 if (not updatedBound)
return NAN;
107 if (not updatedBound) {
115 if (not updatedBound) {
121 if (not updatedBound)
break;
136 return (lower.
x() + upper.
x()) / 2.0;
141 return (lower.
x() * upper.
y() - upper.
x() * lower.
y()) / (upper.
y() - lower.
y());
146 return pos.x() - pos.y() /
gradient(pos.x());
152 if (not
isBetween(lower, next, upper))
return false;
155 if (incDecInfo == EIncDec::c_Increasing) {
156 if (next.
y() > 0.0 and upper.
y() > 0.0) {
160 }
else if (next.
y() <= 0.0 and lower.
y() <= 0.0) {
168 }
else if (incDecInfo == EIncDec::c_Decreasing) {
169 if (next.
y() >= 0 and lower.
y() >= 0.0) {
173 }
else if (next.
y() < 0 and upper.
y() < 0) {
188 double extremumInFirstHalfPeriod = acos(slope);
190 double extremumInFirstPeriod =
191 isEven(iHalfPeriod) ? extremumInFirstHalfPeriod : 2 * M_PI - extremumInFirstHalfPeriod;
194 return extremumInFirstPeriod + 2 * M_PI * iPeriod;
static bool isBetween(const Vector2D &lower, const Vector2D &next, const Vector2D &upper)
Check is next position is within the interval given by lower and upper.
static EIncDec getEIncDec(const Vector2D &lower, const Vector2D &upper)
Determines if the function is increasing or decreasing in the interval.
double getIntercept() const
Getter for the intercept.
double computeExtremumXInHalfPeriod(int iHalfPeriod) const
Get the local extremum that is located in the half period indicated by the given index.
static bool updateBounds(Vector2D &lower, Vector2D &upper, const Vector2D &next)
Replaces the lower or upper bound inplace if the next candidate position is valid and within the inte...
bool hasLargeSlope() const
Indicates that the slope is so large such that the function has no local extrema.
double computeRootInInterval(double lowerX, double upperX) const
Computes the solution in between the given x values. The x values are generally chosen consecutive lo...
double getSlope() const
Getter for the slope.
double computeSmallestPositiveRoot(int maxIHalfPeriod=5) const
static double secantX(const Vector2D &lower, const Vector2D &upper)
Fall back shrinking method to the secant algorithm.
double computeRootForLargeSlope() const
Compute single solution in the case that fabs(slope) >= 1.
double newtonX(const Vector2D &pos) const
Shrinking method of the newton algorithm return the next candidate root.
double computeRootLargerThanExtemumInHalfPeriod(int iHalfPeriod) const
Computes the solution that is addressed by the given half period index.
static bool isConverged(const Vector2D &lower, const Vector2D &upper)
Check if the interval has shrunk close enough to the solution.
static int getIPeriodFromIHalfPeriod(int iHalfPeriod)
Helper function to translate the index of the half period to index of the containing period.
double gradient(const double x) const
Interpreting as the function f this method calculates the gradient as need in Newtons algorithms.
static double middleX(const Vector2D &lower, const Vector2D &upper)
Simple fall back shrinking method using trivial division of the interval.
double map(const double x) const
Interpreting as the function f this method carries out the translation from x to y coordinates.
static double getConvergedBound(const Vector2D &lower, const Vector2D &upper)
Returns the better solution x from the bounds of the interval.
static bool changesSign(const Vector2D &lower, const Vector2D &upper)
Checks if the function changes sign in the interval.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
void set(const double first, const double second)
Setter for both coordinate.
double x() const
Getter for the x coordinate.
void setY(const double y)
Setter for the y coordinate.
double y() const
Getter for the y coordinate.
void setX(const double x)
Setter for the x coordinate.
EIncDec
Enumeration to represent the distinct possibilities of the right left passage information.
Abstract base class for different kinds of events.