Commit d3bf8e1e authored by Andy Buckley's avatar Andy Buckley Committed by Christian Gutschow

Add optional 'sign' arguments to all deltaEta and deltaRap functions, for use...

Add optional 'sign' arguments to all deltaEta and deltaRap functions, for use with Vector2 and symmetry with deltaPhi.
parent 8fb1adcd
2020-01-29 Andy Buckley <andy.buckley@cern.ch>
* Add optional 'sign' arguments to all deltaEta and deltaRap
functions, for use with Vector2 and symmetry with deltaPhi.
* Add a Vector2 class.
2020-01-15 Jon Butterworth <j.butterworth@cern.ch>
* Add a warning to CMS WZ analysis CMS_2016_I1487288 because
......
#ifndef RIVET_MATH_VECTOR3
#define RIVET_MATH_VECTOR3
#include "Rivet/Math/MathConstants.hh"
#include "Rivet/Math/MathUtils.hh"
#include "Rivet/Math/VectorN.hh"
namespace Rivet {
class Vector2;
typedef Vector2 TwoVector;
//class Matrix2;
Vector2 multiply(const double, const Vector2&);
Vector2 multiply(const Vector2&, const double);
Vector2 add(const Vector2&, const Vector2&);
Vector2 operator*(const double, const Vector2&);
Vector2 operator*(const Vector2&, const double);
Vector2 operator/(const Vector2&, const double);
Vector2 operator+(const Vector2&, const Vector2&);
Vector2 operator-(const Vector2&, const Vector2&);
/// @brief Two-dimensional specialisation of Vector.
class Vector2 : public Vector<2> {
// friend class Matrix2;
friend Vector2 multiply(const double, const Vector2&);
friend Vector2 multiply(const Vector2&, const double);
friend Vector2 add(const Vector2&, const Vector2&);
friend Vector2 subtract(const Vector2&, const Vector2&);
public:
Vector2() : Vector<2>() { }
template<typename V2>
Vector2(const V2& other) {
this->setX(other.x());
this->setY(other.y());
}
Vector2(const Vector<2>& other) {
this->setX(other.get(0));
this->setY(other.get(1));
}
Vector2(double x, double y) {
this->setX(x);
this->setY(y);
}
~Vector2() { }
public:
static Vector2 mkX() { return Vector2(1,0); }
static Vector2 mkY() { return Vector2(0,1); }
public:
double x() const { return get(0); }
double y() const { return get(1); }
Vector2& setX(double x) { set(0, x); return *this; }
Vector2& setY(double y) { set(1, y); return *this; }
/// Dot-product with another vector
double dot(const Vector2& v) const {
return _vec.dot(v._vec);
}
/// Angle in radians to another vector
double angle(const Vector2& v) const {
const double localDotOther = unit().dot(v.unit());
if (localDotOther > 1.0) return 0.0;
if (localDotOther < -1.0) return M_PI;
return acos(localDotOther);
}
/// Unit-normalized version of this vector.
Vector2 unitVec() const {
double md = mod();
if ( md <= 0.0 ) return Vector2();
else return *this * 1.0/md;
}
/// Synonym for unitVec
Vector2 unit() const {
return unitVec();
}
public:
Vector2& operator*=(const double a) {
_vec = multiply(a, *this)._vec;
return *this;
}
Vector2& operator/=(const double a) {
_vec = multiply(1.0/a, *this)._vec;
return *this;
}
Vector2& operator+=(const Vector2& v) {
_vec = add(*this, v)._vec;
return *this;
}
Vector2& operator-=(const Vector2& v) {
_vec = subtract(*this, v)._vec;
return *this;
}
Vector2 operator-() const {
Vector2 rtn;
rtn._vec = -_vec;
return rtn;
}
};
inline double dot(const Vector2& a, const Vector2& b) {
return a.dot(b);
}
inline Vector2 multiply(const double a, const Vector2& v) {
Vector2 result;
result._vec = a * v._vec;
return result;
}
inline Vector2 multiply(const Vector2& v, const double a) {
return multiply(a, v);
}
inline Vector2 operator*(const double a, const Vector2& v) {
return multiply(a, v);
}
inline Vector2 operator*(const Vector2& v, const double a) {
return multiply(a, v);
}
inline Vector2 operator/(const Vector2& v, const double a) {
return multiply(1.0/a, v);
}
inline Vector2 add(const Vector2& a, const Vector2& b) {
Vector2 result;
result._vec = a._vec + b._vec;
return result;
}
inline Vector2 subtract(const Vector2& a, const Vector2& b) {
Vector2 result;
result._vec = a._vec - b._vec;
return result;
}
inline Vector2 operator+(const Vector2& a, const Vector2& b) {
return add(a, b);
}
inline Vector2 operator-(const Vector2& a, const Vector2& b) {
return subtract(a, b);
}
/// Angle (in radians) between two 2-vectors.
inline double angle(const Vector2& a, const Vector2& b) {
return a.angle(b);
}
}
#endif
......@@ -301,18 +301,18 @@ namespace Rivet {
//@{
/// Calculate the difference in pseudorapidity between two spatial vectors.
inline double deltaEta(const Vector3& a, const Vector3& b) {
return deltaEta(a.pseudorapidity(), b.pseudorapidity());
inline double deltaEta(const Vector3& a, const Vector3& b, bool sign=false) {
return deltaEta(a.pseudorapidity(), b.pseudorapidity(), sign);
}
/// Calculate the difference in pseudorapidity between two spatial vectors.
inline double deltaEta(const Vector3& v, double eta2) {
return deltaEta(v.pseudorapidity(), eta2);
inline double deltaEta(const Vector3& v, double eta2, bool sign=false) {
return deltaEta(v.pseudorapidity(), eta2, sign);
}
/// Calculate the difference in pseudorapidity between two spatial vectors.
inline double deltaEta(double eta1, const Vector3& v) {
return deltaEta(eta1, v.pseudorapidity());
inline double deltaEta(double eta1, const Vector3& v, bool sign=false) {
return deltaEta(eta1, v.pseudorapidity(), sign);
}
//@}
......
......@@ -1246,63 +1246,63 @@ namespace Rivet {
//@{
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(const FourMomentum& a, const FourMomentum& b) {
return deltaEta(a.vector3(), b.vector3());
inline double deltaEta(const FourMomentum& a, const FourMomentum& b, bool sign=false) {
return deltaEta(a.vector3(), b.vector3(), sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(const FourMomentum& v, double eta2) {
return deltaEta(v.vector3(), eta2);
inline double deltaEta(const FourMomentum& v, double eta2, bool sign=false) {
return deltaEta(v.vector3(), eta2, sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(double eta1, const FourMomentum& v) {
return deltaEta(eta1, v.vector3());
inline double deltaEta(double eta1, const FourMomentum& v, bool sign=false) {
return deltaEta(eta1, v.vector3(), sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(const FourVector& a, const FourVector& b) {
return deltaEta(a.vector3(), b.vector3());
inline double deltaEta(const FourVector& a, const FourVector& b, bool sign=false) {
return deltaEta(a.vector3(), b.vector3(), sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(const FourVector& v, double eta2) {
return deltaEta(v.vector3(), eta2);
inline double deltaEta(const FourVector& v, double eta2, bool sign=false) {
return deltaEta(v.vector3(), eta2, sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(double eta1, const FourVector& v) {
return deltaEta(eta1, v.vector3());
inline double deltaEta(double eta1, const FourVector& v, bool sign=false) {
return deltaEta(eta1, v.vector3(), sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(const FourVector& a, const FourMomentum& b) {
return deltaEta(a.vector3(), b.vector3());
inline double deltaEta(const FourVector& a, const FourMomentum& b, bool sign=false) {
return deltaEta(a.vector3(), b.vector3(), sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(const FourMomentum& a, const FourVector& b) {
return deltaEta(a.vector3(), b.vector3());
inline double deltaEta(const FourMomentum& a, const FourVector& b, bool sign=false) {
return deltaEta(a.vector3(), b.vector3(), sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(const FourVector& a, const Vector3& b) {
return deltaEta(a.vector3(), b);
inline double deltaEta(const FourVector& a, const Vector3& b, bool sign=false) {
return deltaEta(a.vector3(), b, sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(const Vector3& a, const FourVector& b) {
return deltaEta(a, b.vector3());
inline double deltaEta(const Vector3& a, const FourVector& b, bool sign=false) {
return deltaEta(a, b.vector3(), sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(const FourMomentum& a, const Vector3& b) {
return deltaEta(a.vector3(), b);
inline double deltaEta(const FourMomentum& a, const Vector3& b, bool sign=false) {
return deltaEta(a.vector3(), b, sign);
}
/// Calculate the difference in pseudorapidity between two vectors.
inline double deltaEta(const Vector3& a, const FourMomentum& b) {
return deltaEta(a, b.vector3());
inline double deltaEta(const Vector3& a, const FourMomentum& b, bool sign=false) {
return deltaEta(a, b.vector3(), sign);
}
//@}
......@@ -1312,18 +1312,18 @@ namespace Rivet {
//@{
/// Calculate the difference in rapidity between two 4-momentum vectors.
inline double deltaRap(const FourMomentum& a, const FourMomentum& b) {
return deltaRap(a.rapidity(), b.rapidity());
inline double deltaRap(const FourMomentum& a, const FourMomentum& b, bool sign=false) {
return deltaRap(a.rapidity(), b.rapidity(), sign);
}
/// Calculate the difference in rapidity between two 4-momentum vectors.
inline double deltaRap(const FourMomentum& v, double y2) {
return deltaRap(v.rapidity(), y2);
inline double deltaRap(const FourMomentum& v, double y2, bool sign=false) {
return deltaRap(v.rapidity(), y2, sign);
}
/// Calculate the difference in rapidity between two 4-momentum vectors.
inline double deltaRap(double y1, const FourMomentum& v) {
return deltaRap(y1, v.rapidity());
inline double deltaRap(double y1, const FourMomentum& v, bool sign=false) {
return deltaRap(y1, v.rapidity(), sign);
}
//@}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment