rivet is hosted by Hepforge, IPPP Durham

Three-dimensional specialisation of Vector. More...

#include <Vector3.hh>

Inheritance diagram for Vector3:
Collaboration diagram for Vector3:

List of all members.

Public Member Functions

 Vector3 ()
template<typename V3 >
 Vector3 (const V3 &other)
 Vector3 (const Vector< 3 > &other)
 Vector3 (double x, double y, double z)
 ~Vector3 ()
double x () const
double y () const
double z () const
Vector3setX (double x)
Vector3setY (double y)
Vector3setZ (double z)
double dot (const Vector3 &v) const
Vector3 cross (const Vector3 &v) const
double angle (const Vector3 &v) const
Vector3 unit () const
double polarRadius2 () const
double perp2 () const
 Synonym for polarRadius2.
double rho2 () const
 Synonym for polarRadius2.
double polarRadius () const
double perp () const
 Synonym for polarRadius.
double rho () const
 Synonym for polarRadius.
double azimuthalAngle (const PhiMapping mapping=ZERO_2PI) const
 Angle subtended by the vector's projection in x-y and the x-axis.
double phi (const PhiMapping mapping=ZERO_2PI) const
 Synonym for azimuthalAngle.
double polarAngle () const
 Angle subtended by the vector and the z-axis.
double theta () const
 Synonym for polarAngle.
double pseudorapidity () const
double eta () const
 Synonym for pseudorapidity.
Vector3operator*= (const double a)
Vector3operator/= (const double a)
Vector3operator+= (const Vector3 &v)
Vector3operator-= (const Vector3 &v)
Vector3 operator- () const
 Invert the vector.
const double & get (const size_t index) const
const double & operator[] (const size_t index) const
 Direct access to vector elements by index.
double & operator[] (const size_t index)
 Direct access to vector elements by index.
Vector< N > & set (const size_t index, const double value)
 Set indexed value.
size_t size () const
 Vector dimensionality.
bool isZero (double tolerance=1E-5) const
 Check for nullness, allowing for numerical precision.
double mod2 () const
 Calculate the modulus-squared of a vector. $ \sum_{i=1}^N x_i^2 $.
double mod () const
 Calculate the modulus of a vector. $ \sqrt{\sum_{i=1}^N x_i^2} $.
bool operator== (const Vector< N > &a) const
bool operator!= (const Vector< N > &a) const
bool operator< (const Vector< N > &a) const
bool operator<= (const Vector< N > &a) const
bool operator> (const Vector< N > &a) const
bool operator>= (const Vector< N > &a) const

Static Public Member Functions

static Vector3 mkX ()
static Vector3 mkY ()
static Vector3 mkZ ()

Protected Member Functions

double & get (const size_t index)

Protected Attributes

Eigen::Vector< double, N > _vec
 Vector.

Friends

class Matrix3
Vector3 multiply (const double, const Vector3 &)
Vector3 multiply (const Vector3 &, const double)
Vector3 add (const Vector3 &, const Vector3 &)
Vector3 subtract (const Vector3 &, const Vector3 &)

Detailed Description

Three-dimensional specialisation of Vector.

Definition at line 26 of file Vector3.hh.


Constructor & Destructor Documentation

Vector3 ( ) [inline]

Definition at line 35 of file Vector3.hh.

Referenced by Vector3::mkX(), Vector3::mkY(), and Vector3::mkZ().

: Vector<3>() { }
Vector3 ( const V3 &  other) [inline]

Definition at line 38 of file Vector3.hh.

References Vector3::setX(), Vector3::setY(), and Vector3::setZ().

                             {
      this->setX(other.x());
      this->setY(other.y());
      this->setZ(other.z());
    }
Vector3 ( const Vector< 3 > &  other) [inline]

Definition at line 44 of file Vector3.hh.

References Vector< N >::get(), Vector3::setX(), Vector3::setY(), and Vector3::setZ().

                                    {
      this->setX(other.get(0));
      this->setY(other.get(1));
      this->setZ(other.get(2));
    }
Vector3 ( double  x,
double  y,
double  z 
) [inline]

Definition at line 50 of file Vector3.hh.

References Vector3::setX(), Vector3::setY(), and Vector3::setZ().

                                          {
      this->setX(x);
      this->setY(y);
      this->setZ(z);
    }
~Vector3 ( ) [inline]

Definition at line 56 of file Vector3.hh.

{ }

Member Function Documentation

double angle ( const Vector3 v) const [inline]

Definition at line 81 of file Vector3.hh.

References Vector3::dot(), Rivet::fuzzyEquals(), and Vector3::unit().

Referenced by FourVector::angle(), and Rivet::angle().

                                         {
      const double localDotOther = unit().dot(v.unit());
      if (fuzzyEquals(localDotOther, 1.0)) return 0.0;
      else if (fuzzyEquals(localDotOther, -1.0)) return M_PI;
      return acos(localDotOther);
    }
double azimuthalAngle ( const PhiMapping  mapping = ZERO_2PI) const [inline]

Angle subtended by the vector's projection in x-y and the x-axis.

Definition at line 123 of file Vector3.hh.

References Rivet::isZero(), Rivet::mapAngle(), Vector< 3 >::mod2(), Vector3::x(), and Vector3::y().

Referenced by FourVector::azimuthalAngle(), Rivet::azimuthalAngle(), Rivet::deltaPhi(), Rivet::deltaR(), Vector3::phi(), and DISKinematics::project().

                                                                     {
      // If this is a null vector, return zero rather than let atan2 set an error state
      if (Rivet::isZero(mod2())) return 0.0;

      // Calculate the arctan and return in the requested range
      const double value = atan2( y(), x() );
      return mapAngle(value, mapping);
    }
double eta ( ) const [inline]

Synonym for pseudorapidity.

Definition at line 156 of file Vector3.hh.

References Vector3::pseudorapidity().

Referenced by FourVector::eta(), and Rivet::eta().

                       {
      return pseudorapidity();
    }
const double& get ( const size_t  index) const [inline, inherited]

Definition at line 33 of file VectorN.hh.

                                                {
      if (index >= N) {
        throw std::runtime_error("Tried to access an invalid vector index.");
      } else {
        return _vec(index);
      }
    }
double& get ( const size_t  index) [inline, protected, inherited]

Definition at line 126 of file VectorN.hh.

                                    {
      if (index >= N) {
        throw std::runtime_error("Tried to access an invalid vector index.");
      } else {
        return _vec(index);
      }
    }
bool isZero ( double  tolerance = 1E-5) const [inline, inherited]

Check for nullness, allowing for numerical precision.

Definition at line 67 of file VectorN.hh.

Referenced by Vector3::unit().

                                             {
      for (size_t i=0; i < N; ++i) {
        if (! Rivet::isZero(_vec[i], tolerance) ) return false;
      }
      return true;
    }
static Vector3 mkX ( ) [inline, static]

Definition at line 59 of file Vector3.hh.

References Vector3::Vector3().

Referenced by DISKinematics::project(), and LorentzTransform::setBoost().

{ return Vector3(1,0,0); }
static Vector3 mkY ( ) [inline, static]

Definition at line 60 of file Vector3.hh.

References Vector3::Vector3().

Referenced by DISKinematics::project().

{ return Vector3(0,1,0); }
static Vector3 mkZ ( ) [inline, static]

Definition at line 61 of file Vector3.hh.

References Vector3::Vector3().

Referenced by DISKinematics::project().

{ return Vector3(0,0,1); }
double mod ( ) const [inline, inherited]

Calculate the modulus of a vector. $ \sqrt{\sum_{i=1}^N x_i^2} $.

Definition at line 87 of file VectorN.hh.

Referenced by Vector3::unit().

                       {
      const double norm = mod2();
      assert(norm >= 0);
      return sqrt(norm);
    }
double mod2 ( ) const [inline, inherited]

Calculate the modulus-squared of a vector. $ \sum_{i=1}^N x_i^2 $.

Definition at line 76 of file VectorN.hh.

Referenced by Vector3::azimuthalAngle().

                        {
      double mod2 = 0.0;
      for (size_t i = 0; i < size(); ++i) {
        const double element = get(i);
        mod2 += element*element;
      }
      return mod2;
    }
bool operator!= ( const Vector< N > &  a) const [inline, inherited]

Definition at line 104 of file VectorN.hh.

                                              {
      return _vec != a._vec;
    }
Vector3& operator*= ( const double  a) [inline]

Definition at line 161 of file Vector3.hh.

References Vector< 3 >::_vec, Vector< N >::_vec, and Vector3::multiply.

                                        {
      _vec = multiply(a, *this)._vec;
      return *this;
    }
Vector3& operator+= ( const Vector3 v) [inline]

Definition at line 171 of file Vector3.hh.

References Vector< 3 >::_vec, Vector< N >::_vec, and Vector3::add.

                                          {
      _vec = add(*this, v)._vec;
      return *this;
    }
Vector3 operator- ( ) const [inline]

Invert the vector.

Reimplemented from Vector< 3 >.

Definition at line 181 of file Vector3.hh.

References Vector< N >::_vec, and Vector< 3 >::_vec.

                              {
      Vector3 rtn;
      rtn._vec = -_vec;
      return rtn;
    }
Vector3& operator-= ( const Vector3 v) [inline]

Definition at line 176 of file Vector3.hh.

References Vector< 3 >::_vec, Vector< N >::_vec, and Vector3::subtract.

                                          {
      _vec = subtract(*this, v)._vec;
      return *this;
    }
Vector3& operator/= ( const double  a) [inline]

Definition at line 166 of file Vector3.hh.

References Vector< 3 >::_vec, Vector< N >::_vec, and Vector3::multiply.

                                        {
      _vec = multiply(1.0/a, *this)._vec;
      return *this;
    }
bool operator< ( const Vector< N > &  a) const [inline, inherited]

Definition at line 108 of file VectorN.hh.

                                             {
      return _vec < a._vec;
    }
bool operator<= ( const Vector< N > &  a) const [inline, inherited]

Definition at line 112 of file VectorN.hh.

                                              {
      return _vec <= a._vec;
    }
bool operator== ( const Vector< N > &  a) const [inline, inherited]

Definition at line 100 of file VectorN.hh.

                                              {
      return _vec == a._vec;
    }
bool operator> ( const Vector< N > &  a) const [inline, inherited]

Definition at line 116 of file VectorN.hh.

                                             {
      return _vec > a._vec;
    }
bool operator>= ( const Vector< N > &  a) const [inline, inherited]

Definition at line 120 of file VectorN.hh.

                                              {
      return _vec >= a._vec;
    }
const double& operator[] ( const size_t  index) const [inline, inherited]

Direct access to vector elements by index.

Definition at line 42 of file VectorN.hh.

                                                       {
      return get(index);
    }
double& operator[] ( const size_t  index) [inline, inherited]

Direct access to vector elements by index.

Definition at line 47 of file VectorN.hh.

                                           {
      return get(index);
    }
double perp ( ) const [inline]

Synonym for polarRadius.

Definition at line 113 of file Vector3.hh.

References Vector3::polarRadius().

Referenced by FourVector::perp(), and Rivet::perp().

                        {
      return polarRadius();
    }
double perp2 ( ) const [inline]

Synonym for polarRadius2.

Definition at line 99 of file Vector3.hh.

References Vector3::polarRadius2().

Referenced by FourVector::perp2(), and Rivet::perp2().

                         {
      return polarRadius2();
    }
double phi ( const PhiMapping  mapping = ZERO_2PI) const [inline]

Synonym for azimuthalAngle.

Definition at line 133 of file Vector3.hh.

References Vector3::azimuthalAngle().

Referenced by FourVector::phi(), and Rivet::phi().

                                                          {
      return azimuthalAngle(mapping);
    }
double polarAngle ( ) const [inline]

Angle subtended by the vector and the z-axis.

Definition at line 138 of file Vector3.hh.

References Rivet::mapAngle0ToPi(), Vector3::polarRadius(), and Vector3::z().

Referenced by FourVector::polarAngle(), Rivet::polarAngle(), Vector3::pseudorapidity(), and Vector3::theta().

                              {
      // Get number beween [0,PI]
      const double polarangle = atan2(polarRadius(), z());
      return mapAngle0ToPi(polarangle);
    }
double polarRadius ( ) const [inline]
double polarRadius2 ( ) const [inline]
double pseudorapidity ( ) const [inline]

Purely geometric approximation to rapidity; exact for massless particles and in the central region.

Definition at line 151 of file Vector3.hh.

References Vector3::polarAngle().

Referenced by Rivet::deltaEta(), Rivet::deltaR(), Vector3::eta(), FourVector::pseudorapidity(), and Rivet::pseudorapidity().

                                  {
      return -std::log(tan( 0.5 * polarAngle() ));
    }
double rho ( ) const [inline]

Synonym for polarRadius.

Definition at line 118 of file Vector3.hh.

References Vector3::polarRadius().

Referenced by FourVector::rho(), and Rivet::rho().

                       {
      return polarRadius();
    }
double rho2 ( ) const [inline]

Synonym for polarRadius2.

Definition at line 104 of file Vector3.hh.

References Vector3::polarRadius2().

Referenced by FourVector::rho2(), and Rivet::rho2().

                        {
      return polarRadius2();
    }
Vector<N>& set ( const size_t  index,
const double  value 
) [inline, inherited]

Set indexed value.

Definition at line 52 of file VectorN.hh.

                                                           {
      if (index >= N) {
        throw std::runtime_error("Tried to access an invalid vector index.");
      } else {
        _vec[index] = value;
      }
      return *this;
    }
Vector3& setX ( double  x) [inline]

Definition at line 67 of file Vector3.hh.

References Vector3::x().

Referenced by Vector3::Vector3().

{ set(0, x); return *this; }
Vector3& setY ( double  y) [inline]

Definition at line 68 of file Vector3.hh.

References Vector3::y().

Referenced by Vector3::Vector3().

{ set(1, y); return *this; }
Vector3& setZ ( double  z) [inline]

Definition at line 69 of file Vector3.hh.

References Vector3::z().

Referenced by CMS_2011_S8957746::analyze(), CMS_2013_I1209721::analyze(), MissingMomentum::project(), and Vector3::Vector3().

{ set(2, z); return *this; }
size_t size ( ) const [inline, inherited]

Vector dimensionality.

Definition at line 62 of file VectorN.hh.

                        {
      return N;
    }
double theta ( ) const [inline]

Synonym for polarAngle.

Definition at line 145 of file Vector3.hh.

References Vector3::polarAngle().

Referenced by ALEPH_1996_S3196992::analyze(), FourVector::theta(), and Rivet::theta().

                         {
      return polarAngle();
    }
double z ( ) const [inline]

Definition at line 66 of file Vector3.hh.

Referenced by Thrust::_calcThrust(), Vector3::polarAngle(), and Vector3::setZ().

{ return get(2); }

Friends And Related Function Documentation

Vector3 add ( const Vector3 a,
const Vector3 b 
) [friend]

Referenced by Vector3::operator+=().

friend class Matrix3 [friend]

Definition at line 28 of file Vector3.hh.

Vector3 multiply ( const double  a,
const Vector3 v 
) [friend]
Vector3 multiply ( const Vector3 v,
const double  a 
) [friend]
Vector3 subtract ( const Vector3 a,
const Vector3 b 
) [friend]

Definition at line 227 of file Vector3.hh.

Referenced by Vector3::operator-=().

                                                              {
    Vector3 result;
    result._vec = a._vec - b._vec;
    return result;
  }

Member Data Documentation

Eigen::Vector<double,N> _vec [protected, inherited]

The documentation for this class was generated from the following file: