1 #ifndef RIVET_MATH_VECTOR3 2 #define RIVET_MATH_VECTOR3 4 #include "Rivet/Math/MathConstants.hh" 5 #include "Rivet/Math/MathUtils.hh" 6 #include "Rivet/Math/VectorN.hh" 12 typedef Vector3 ThreeVector;
15 Vector3 multiply(
const double,
const Vector3&);
16 Vector3 multiply(
const Vector3&,
const double);
17 Vector3 add(
const Vector3&,
const Vector3&);
18 Vector3 operator*(
const double,
const Vector3&);
19 Vector3 operator*(
const Vector3&,
const double);
20 Vector3
operator/(
const Vector3&,
const double);
21 Vector3 operator+(
const Vector3&,
const Vector3&);
22 Vector3 operator-(
const Vector3&,
const Vector3&);
39 this->setX(other.x());
40 this->setY(other.y());
41 this->setZ(other.z());
45 this->setX(other.get(0));
46 this->setY(other.get(1));
47 this->setZ(other.get(2));
50 Vector3(
double x,
double y,
double z) {
68 double x()
const {
return get(0); }
69 double y()
const {
return get(1); }
70 double z()
const {
return get(2); }
71 Vector3& setX(
double x) {
set(0, x);
return *
this; }
72 Vector3& setY(
double y) {
set(1, y);
return *
this; }
73 Vector3& setZ(
double z) {
set(2, z);
return *
this; }
78 return _vec.dot(v._vec);
84 result._vec = _vec.
cross(v._vec);
91 if (localDotOther > 1.0)
return 0.0;
92 if (localDotOther < -1.0)
return M_PI;
93 return acos(localDotOther);
100 if ( md <= 0.0 )
return Vector3();
101 else return *
this * 1.0/md;
127 return x()*x() + y()*y();
158 if (x() == 0 && y() == 0)
return 0.0;
160 const double value = atan2( y(), x() );
176 const double polarangle = atan2(
polarRadius(), z());
191 const double epsilon = DBL_EPSILON;
193 if ( m == 0.0 )
return 0.0;
194 double pt =
max(epsilon*m,
perp());
195 double rap = std::log((m + fabs(z()))/pt);
196 return z() > 0.0 ? rap: -rap;
211 Vector3& operator*=(
const double a) {
212 _vec = multiply(a, *
this)._vec;
216 Vector3& operator/=(
const double a) {
217 _vec = multiply(1.0/a, *
this)._vec;
222 _vec = add(*
this, v)._vec;
227 _vec = subtract(*
this, v)._vec;
251 result._vec = a * v._vec;
256 return multiply(a, v);
260 return multiply(a, v);
264 return multiply(a, v);
268 return multiply(1.0/a, v);
273 result._vec = a._vec + b._vec;
279 result._vec = a._vec - b._vec;
288 return subtract(a, b);
363 return sqrt(
deltaR2(v, eta2, phi2));
373 return sqrt(
deltaR2(eta1, phi1, v));
Definition: MC_Cent_pPb.hh:10
Vector3 rhoVec() const
Synonym for polarVec.
Definition: Vector3.hh:121
double polarRadius() const
Polar radius.
Definition: Vector3.hh:139
double rho() const
Synonym for polarRadius.
Definition: Vector3.hh:147
double perp() const
Synonym for polarRadius.
Definition: Vector3.hh:143
double mapAngle(double angle, PhiMapping mapping)
Map an angle into the enum-specified range.
Definition: MathUtils.hh:560
Specialisation of MatrixN to aid 3 dimensional rotations.
Definition: Matrix3.hh:13
double tanTheta() const
Tangent of the polar angle.
Definition: Vector3.hh:169
double deltaEta(double eta1, double eta2, bool sign=false)
Definition: MathUtils.hh:590
double angle(const Vector3 &v) const
Angle in radians to another vector.
Definition: Vector3.hh:89
Vector3 unitVec() const
Unit-normalized version of this vector.
Definition: Vector3.hh:98
Vector3 polarVec() const
Polar projection of this vector into the x-y plane.
Definition: Vector3.hh:111
double dot(const Vector3 &v) const
Dot-product with another vector.
Definition: Vector3.hh:77
string operator/(const string &a, const string &b)
Operator for joining strings a and b with filesystem separators.
Definition: Utils.hh:248
double polarAngle() const
Angle subtended by the vector and the z-axis.
Definition: Vector3.hh:174
PhiMapping
Enum for range of to be mapped into.
Definition: MathConstants.hh:49
double pseudorapidity() const
Definition: Vector3.hh:190
double deltaPhi(double phi1, double phi2, bool sign=false)
Calculate the difference between two angles in radians.
Definition: MathUtils.hh:582
double rho2() const
Synonym for polarRadius2.
Definition: Vector3.hh:134
Vector3 cross(const Vector3 &v) const
Cross-product with another vector.
Definition: Vector3.hh:82
A minimal base class for -dimensional vectors.
Definition: VectorN.hh:13
double deltaR2(double rap1, double phi1, double rap2, double phi2)
Definition: MathUtils.hh:605
double deltaR(double rap1, double phi1, double rap2, double phi2)
Definition: MathUtils.hh:612
double max(const vector< double > &in, double errval=DBL_NAN)
Find the maximum value in the vector.
Definition: Utils.hh:612
Vector3 perpVec() const
Synonym for polarVec.
Definition: Vector3.hh:117
double mapAngle0ToPi(double angle)
Map an angle into the range [0, PI].
Definition: MathUtils.hh:552
Vector3 unit() const
Synonym for unitVec.
Definition: Vector3.hh:105
double azimuthalAngle(const PhiMapping mapping=ZERO_2PI) const
Definition: Vector3.hh:155
double theta() const
Synonym for polarAngle.
Definition: Vector3.hh:181
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition: Vector3.hh:164
double abseta() const
Convenience shortcut for fabs(eta())
Definition: Vector3.hh:205
Three-dimensional specialisation of Vector.
Definition: Vector3.hh:26
double eta() const
Synonym for pseudorapidity.
Definition: Vector3.hh:200
double polarRadius2() const
Square of the polar radius (.
Definition: Vector3.hh:126
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:95
double perp2() const
Synonym for polarRadius2.
Definition: Vector3.hh:130
std::enable_if< std::is_arithmetic< NUM >::value, int >::type sign(NUM val)
Find the sign of a number.
Definition: MathUtils.hh:245