10#include <tracking/trackFindingCDC/geometry/Vector2D.h>
11#include <tracking/trackFindingCDC/numerics/Quadratic.h>
13#include <framework/geometry/B2Vector3.h>
14#include <Math/Vector3D.h>
27 namespace TrackFindingCDC {
44 explicit Vector3D(
const TVector3& tVector3);
50 explicit Vector3D(
const ROOT::Math::XYZVector& xyzVector3);
95 (one.
y() + two.
y()) / 2.0,
96 (one.
z() + two.
z()) / 2.0);
111 }
else if (two.
hasNAN()) {
113 }
else if (three.
hasNAN()) {
116 return Vector3D((one.
x() + two.
x() + three.
x()) / 3.0,
117 (one.
y() + two.
y() + three.
y()) / 3.0,
118 (one.
z() + two.
z() + three.
z()) / 3.0);
123 operator const TVector3()
const;
129 operator const ROOT::Math::XYZVector()
const;
134 return x() == rhs.
x() and
y() == rhs.
y() and
z() == rhs.
z();
148 (
z() < rhs.
z() or (
z() == rhs.
z() and (
phi() < rhs.
phi()))));
161 return x() == 0.0 and
y() == 0.0 and
z() == 0.0;
167 return std::isnan(
x()) or std::isnan(
y()) or std::isnan(
z());
176 return x() * rhs.
x() +
y() * rhs.
y() +
z() * rhs.
z();
182 return x() * rhs.
x() +
y() * rhs.
y();
189 z() * rhs.
x() -
x() * rhs.
z(),
190 x() * rhs.
y() -
y() * rhs.
x());
208 return x() *
x() +
y() *
y() +
z() *
z();
214 return hypot3(
x(),
y(),
z());
246 double deltaX =
x() - rhs.x();
247 double deltaY =
y() - rhs.y();
248 double deltaZ =
z() - rhs.z();
249 return hypot3(deltaX, deltaY, deltaZ);
263 return scale(factor);
289 return divide(denominator);
369 double result =
norm();
370 if (result != 0.0)
divide(result);
379 double result =
norm();
380 if (result != 0.0)
scale(toLength / result);
418 return relativTo.
dot(*
this) / relativTo.
norm();
432 return relativTo.
dot(*
this);
520 void set(
const double first,
const double second,
const double third)
578 std::ostream& operator<<(std::ostream& output,
const Vector3D& vector3D);
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Vector2D & divide(const double denominator)
Divides all coordinates by a common denominator in place.
Vector2D & scale(const double factor)
Scales the vector in place by the given factor.
Vector2D & add(const Vector2D &rhs)
Adds a vector to this in place.
double cross(const Vector2D &rhs) const
Calculated the two dimensional cross product.
double x() const
Getter for the x coordinate.
Vector2D & subtract(const Vector2D &rhs)
Subtracts a vector from this 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 .
void setY(const double y)
Setter for the y coordinate.
double y() const
Getter for the y coordinate.
double norm() const
Calculates the length of the vector.
void setX(const double x)
Setter for the x coordinate.
A three dimensional vector.
Vector3D operator-(const Vector3D &rhs) const
Returns a new vector as difference of this and rhs.
double normalize()
Normalizes the vector to unit length.
Vector3D passiveMovedBy(const Vector3D &by)
Passively moves the vector inplace by the given vector.
bool operator<(const Vector3D &rhs) const
Total ordering based on cylindrical radius first the z component second and azimuth angle third.
Vector3D & operator=(const TVector3 &tVector3)
Assignment translating from a TVector3 instance.
std::string __str__() const
Output operator for python.
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
double distance(const Vector3D &rhs=Vector3D(0.0, 0.0, 0.0)) const
Calculates the distance of this point to the rhs.
Vector3D & operator+=(const Vector3D &rhs)
Same as add()
Vector3D & operator+=(const Vector2D &rhs)
Same as add()
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
double unnormalizedOrthogonalComp(const Vector3D &relativTo) const
Same as orthogonalComp() but assumes the given vector to be of unit length.
double cotTheta() const
Getter for the cotangent of the polar angle.
double sinWith(const Vector3D &rhs) const
Sine of the angle between this and rhs.
Vector3D & scale(const double factor)
Scales the vector in place by the given factor.
static Vector3D getLowest()
Getter for the lowest possible vector.
static Vector3D average(const Vector3D &one, const Vector3D &two, const Vector3D &three)
Constructs the average of three vectors.
double dotXY(const Vector3D &rhs) const
Calculates the two dimensional dot product in xy projection.
double lambda() const
Getter for lambda.
Vector3D cross(const Vector3D &rhs) const
Calculated the three dimensional cross product.
Vector3D orthogonalVector(const Vector3D &relativTo) const
Calculates the part of this vector that is parallel to the given vector.
Vector3D & operator/=(const double denominator)
Same as divide()
double cosWith(const Vector3D &rhs) const
double orthogonalComp(const Vector3D &relativTo) const
Calculates the component orthogonal to the given vector.
Vector3D & add(const Vector3D &rhs)
Adds a vector to this in place.
Vector3D(const Vector2D &xy, double z)
Constructor augmeting a Vector2D to a Vector3D setting z explicitly.
Vector3D parallelVector(const Vector3D &relativTo) const
Calculates the part of this vector that is parallel to the given vector.
double cylindricalR() const
Getter for the cylindrical radius ( xy projected norm )
Vector2D m_xy
Memory for the first and second coordinate available as a vector.
Vector3D(const Vector2D &xy)
Constructor augmeting a Vector2D to a Vector3D setting z to zero.
Vector3D operator+(const Vector3D &rhs) const
Returns a new vector as sum of this and rhs.
void passiveMoveBy(const Vector3D &by)
Passively moves the vector inplace by the given vector.
Vector3D operator*(const double factor) const
Same as scaled()
double dot(const Vector3D &rhs) const
Calculates the three dimensional dot product.
double parallelComp(const Vector3D &relativTo) const
Calculates the component parallel to the given vector.
Vector3D unit() const
Returns a unit vector colaligned with this.
Vector3D & add(const Vector2D &rhs)
Adds a two dimensional vector to this in place taking z of the given vector as zero.
double tanLambda() const
Getter for the tangent of lambda equivalent to cotTheta()
Vector3D operator-() const
Same as reversed()
double x() const
Getter for the x coordinate.
static Vector3D average(const Vector3D &one, const Vector3D &two)
Constructs the average of two vectors.
Vector3D & divide(const double denominator)
Divides all coordinates by a common denominator in place.
Vector3D & subtract(const Vector2D &rhs)
Subtracts a two dimensional vector from this in place taking z of the given vector as zero.
double crossXY(const Vector2D &rhs) const
Calculates the two dimensional cross product in xy projection.
Vector3D(double x, double y, double z)
Constructor from three coordinates.
Vector3D & operator*=(const double factor)
Same as scale()
void setZ(const double z)
Setter for the z coordinate.
double angleWith(const Vector3D &rhs) const
The angle between this and rhs.
double phi() const
Getter for the azimuth angle.
double cylindricalRSquared() const
Getter for the squared cylindrical radius ( xy projected squared norm )
Vector3D operator/(const double denominator) const
Same as divided()
void setXY(const Vector2D &xy)
Setter for the xy projected vector.
double normSquared() const
Calculates the squared length of the vector.
bool isNull() const
Checks if the vector is the null vector.
double unnormalizedParallelComp(const Vector3D &relativTo) const
Same as parallelComp() but assumes the given vector to be of unit length.
Vector3D scaled(const double factor) const
Returns a scaled copy of the vector.
bool hasNAN() const
Checks if one of the coordinates is NAN.
bool operator==(const Vector3D &rhs) const
Equality comparison with all three coordinates.
void setY(const double y)
Setter for the y coordinate.
double y() const
Getter for the y coordinate.
Vector3D & subtract(const Vector3D &rhs)
Subtracts a vector to this in place.
double m_z
Memory for the third coordinate.
void set(const double first, const double second, const double third)
Setter for all three coordinates.
double crossXY(const Vector3D &rhs) const
Calculates the two dimensional cross product in xy projection.
double norm() const
Calculates the length of the vector.
double z() const
Getter for the z coordinate.
void setX(const double x)
Setter for the x coordinate.
double theta() const
Getter for the polar angle.
Vector3D & operator-=(const Vector3D &rhs)
Same as subtract()
Vector3D & operator-=(const Vector2D &rhs)
Same as subtract()
Vector3D reversed() const
Returns a vector pointing in the opposite direction.
Vector3D()
Default constructor for ROOT compatibility.
Vector3D & reverse()
Reverses the direction of the vector in place.
Vector3D divided(const double denominator) const
Returns a copy where all coordinates got divided by a common denominator.
B2Vector3< double > B2Vector3D
typedef for common usage with double
Abstract base class for different kinds of events.