rivet is hosted by Hepforge, IPPP Durham
FourVector Class Reference

Specialisation of VectorN to a general (non-momentum) Lorentz 4-vector. More...

#include <Vector4.hh>

List of all members.

Public Member Functions

 FourVector ()
template<typename V4 >
 FourVector (const V4 &other)
 FourVector (const Vector< 4 > &other)
 FourVector (const double t, const double x, const double y, const double z)
virtual ~FourVector ()
double t () const
double t2 () const
FourVectorsetT (const double t)
double x () const
double x2 () const
FourVectorsetX (const double x)
double y () const
double y2 () const
FourVectorsetY (const double y)
double z () const
double z2 () const
FourVectorsetZ (const double z)
double invariant () const
bool isNull () const
double angle (const FourVector &v) const
 Angle between this vector and another.
double angle (const Vector3 &v3) const
 Angle between this vector and another (3-vector)
double polarRadius2 () const
 Square of the projection of the 3-vector on to the $ x-y $ plane This is a more efficient function than polarRadius, as it avoids the square root. Use it if you only need the squared value, or e.g. an ordering by magnitude.
double perp2 () const
 Synonym for polarRadius2.
double rho2 () const
 Synonym for polarRadius2.
double polarRadius () const
 Projection of 3-vector on to the $ x-y $ plane.
double perp () const
 Synonym for polarRadius.
double rho () const
 Synonym for polarRadius.
double azimuthalAngle (const PhiMapping mapping=ZERO_2PI) const
 Angle subtended by the 3-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 3-vector and the z-axis.
double theta () const
 Synonym for polarAngle.
double pseudorapidity () const
 Pseudorapidity (defined purely by the 3-vector components)
double eta () const
 Synonym for pseudorapidity.
double abspseudorapidity () const
 Get the $ |\eta| $ directly.
double abseta () const
 Get the $ |\eta| $ directly (alias).
Vector3 vector3 () const
 Get the spatial part of the 4-vector as a 3-vector.
double contract (const FourVector &v) const
 Contract two 4-vectors, with metric signature (+ - - -).
double dot (const FourVector &v) const
 Contract two 4-vectors, with metric signature (+ - - -).
double operator* (const FourVector &v) const
 Contract two 4-vectors, with metric signature (+ - - -).
FourVectoroperator*= (double a)
 Multiply by a scalar.
FourVectoroperator/= (double a)
 Divide by a scalar.
FourVectoroperator+= (const FourVector &v)
 Add to this 4-vector.
FourVectoroperator-= (const FourVector &v)
 Subtract from this 4-vector. NB time as well as space components are subtracted.
FourVector operator- () const
 Multiply all components (space and time) by -1.
FourVector reverse () const
 Multiply space components only by -1.
const double & get (const size_t index) const
double & get (const size_t index)
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

Public Attributes

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

Friends

FourVector multiply (const double a, const FourVector &v)
FourVector multiply (const FourVector &v, const double a)
FourVector add (const FourVector &a, const FourVector &b)
FourVector transform (const LorentzTransform &lt, const FourVector &v4)

Detailed Description

Specialisation of VectorN to a general (non-momentum) Lorentz 4-vector.

Todo:
Add composite set/mk methods from different coord systems

Definition at line 22 of file Vector4.hh.


Constructor & Destructor Documentation

FourVector ( ) [inline]

Definition at line 30 of file Vector4.hh.

: Vector<4>() { }
FourVector ( const V4 &  other) [inline]

Definition at line 33 of file Vector4.hh.

                                {
      this->setT(other.t());
      this->setX(other.x());
      this->setY(other.y());
      this->setZ(other.z());
    }
FourVector ( const Vector< 4 > &  other) [inline]

Definition at line 40 of file Vector4.hh.

      : Vector<4>(other) { }
FourVector ( const double  t,
const double  x,
const double  y,
const double  z 
) [inline]

Definition at line 43 of file Vector4.hh.

                                                                               {
      this->setT(t);
      this->setX(x);
      this->setY(y);
      this->setZ(z);
    }
virtual ~FourVector ( ) [inline, virtual]

Definition at line 50 of file Vector4.hh.

{ }

Member Function Documentation

double abseta ( ) const [inline]

Get the $ |\eta| $ directly (alias).

Definition at line 146 of file Vector4.hh.

{ return fabs(eta()); }
double abspseudorapidity ( ) const [inline]

Get the $ |\eta| $ directly.

Definition at line 144 of file Vector4.hh.

{ return fabs(eta()); }
double angle ( const FourVector v) const [inline]

Angle between this vector and another.

Definition at line 80 of file Vector4.hh.

                                            {
      return vector3().angle( v.vector3() );
    }
double angle ( const Vector3 v3) const [inline]

Angle between this vector and another (3-vector)

Definition at line 84 of file Vector4.hh.

                                          {
      return vector3().angle(v3);
    }
double azimuthalAngle ( const PhiMapping  mapping = ZERO_2PI) const [inline]

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

Definition at line 117 of file Vector4.hh.

                                                                   {
      return vector3().azimuthalAngle(mapping);
    }
double contract ( const FourVector v) const [inline]

Contract two 4-vectors, with metric signature (+ - - -).

Definition at line 157 of file Vector4.hh.

                                               {
      const double result = t()*v.t() - x()*v.x() - y()*v.y() - z()*v.z();
      return result;
    }
double dot ( const FourVector v) const [inline]

Contract two 4-vectors, with metric signature (+ - - -).

Definition at line 163 of file Vector4.hh.

                                          {
      return contract(v);
    }
double eta ( ) const [inline]

Synonym for pseudorapidity.

Definition at line 139 of file Vector4.hh.

                       {
      return vector3().eta();
    }
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, inherited]

Definition at line 41 of file VectorN.hh.

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

Definition at line 70 of file Vector4.hh.

                             {
      // Done this way for numerical precision
      return (t() + z())*(t() - z()) - x()*x() - y()*y();
    }
bool isNull ( ) const [inline]

Definition at line 75 of file Vector4.hh.

                        {
      return Rivet::isZero(invariant());
    }
bool isZero ( double  tolerance = 1E-5) const [inline, inherited]

Check for nullness, allowing for numerical precision.

Definition at line 75 of file VectorN.hh.

                                             {
      for (size_t i=0; i < N; ++i) {
        if (! Rivet::isZero(_vec[i], tolerance) ) return false;
      }
      return true;
    }
double mod ( ) const [inline, inherited]

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

Definition at line 95 of file VectorN.hh.

                       {
      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 84 of file VectorN.hh.

                        {
      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 112 of file VectorN.hh.

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

Contract two 4-vectors, with metric signature (+ - - -).

Definition at line 168 of file Vector4.hh.

                                                {
      return contract(v);
    }
FourVector& operator*= ( double  a) [inline]

Multiply by a scalar.

Reimplemented in FourMomentum.

Definition at line 173 of file Vector4.hh.

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

Add to this 4-vector.

Definition at line 185 of file Vector4.hh.

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

Multiply all components (space and time) by -1.

Reimplemented from Vector< 4 >.

Reimplemented in FourMomentum.

Definition at line 197 of file Vector4.hh.

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

Subtract from this 4-vector. NB time as well as space components are subtracted.

Definition at line 191 of file Vector4.hh.

                                                {
      _vec = add(*this, -v)._vec;
      return *this;
    }
FourVector& operator/= ( double  a) [inline]

Divide by a scalar.

Reimplemented in FourMomentum.

Definition at line 179 of file Vector4.hh.

                                     {
      _vec = multiply(1.0/a, *this)._vec;
      return *this;
    }
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;
    }
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 124 of file VectorN.hh.

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

Definition at line 128 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 50 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 55 of file VectorN.hh.

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

Synonym for polarRadius.

Definition at line 108 of file Vector4.hh.

                        {
      return vector3().perp();
    }
double perp2 ( ) const [inline]

Synonym for polarRadius2.

Definition at line 95 of file Vector4.hh.

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

Synonym for azimuthalAngle.

Definition at line 121 of file Vector4.hh.

                                                        {
      return vector3().phi(mapping);
    }
double polarAngle ( ) const [inline]

Angle subtended by the 3-vector and the z-axis.

Definition at line 126 of file Vector4.hh.

                              {
      return vector3().polarAngle();
    }
double polarRadius ( ) const [inline]

Projection of 3-vector on to the $ x-y $ plane.

Definition at line 104 of file Vector4.hh.

                               {
      return vector3().polarRadius();
    }
double polarRadius2 ( ) const [inline]

Square of the projection of the 3-vector on to the $ x-y $ plane This is a more efficient function than polarRadius, as it avoids the square root. Use it if you only need the squared value, or e.g. an ordering by magnitude.

Definition at line 91 of file Vector4.hh.

                                {
      return vector3().polarRadius2();
    }
double pseudorapidity ( ) const [inline]

Pseudorapidity (defined purely by the 3-vector components)

Definition at line 135 of file Vector4.hh.

                                  {
      return vector3().pseudorapidity();
    }
FourVector reverse ( ) const [inline]

Multiply space components only by -1.

Reimplemented in FourMomentum.

Definition at line 204 of file Vector4.hh.

                               {
      FourVector result = -*this;
      result.setT(-result.t());
      return result;
    }
double rho ( ) const [inline]

Synonym for polarRadius.

Definition at line 112 of file Vector4.hh.

                       {
      return vector3().rho();
    }
double rho2 ( ) const [inline]

Synonym for polarRadius2.

Definition at line 99 of file Vector4.hh.

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

Set indexed value.

Definition at line 60 of file VectorN.hh.

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

Definition at line 56 of file Vector4.hh.

{ set(0, t); return *this; }
FourVector& setX ( const double  x) [inline]

Definition at line 60 of file Vector4.hh.

{ set(1, x); return *this; }
FourVector& setY ( const double  y) [inline]

Definition at line 64 of file Vector4.hh.

{ set(2, y); return *this; }
FourVector& setZ ( const double  z) [inline]

Definition at line 68 of file Vector4.hh.

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

Vector dimensionality.

Definition at line 70 of file VectorN.hh.

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

Definition at line 54 of file Vector4.hh.

{ return get(0); }
double t2 ( ) const [inline]

Definition at line 55 of file Vector4.hh.

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

Synonym for polarAngle.

Definition at line 130 of file Vector4.hh.

                         {
      return vector3().theta();
    }
Vector3 vector3 ( ) const [inline]

Get the spatial part of the 4-vector as a 3-vector.

Definition at line 149 of file Vector4.hh.

                            {
      return Vector3(get(1), get(2), get(3));
    }
double x ( ) const [inline]

Definition at line 58 of file Vector4.hh.

{ return get(1); }
double x2 ( ) const [inline]

Definition at line 59 of file Vector4.hh.

{ return sqr(x()); }
double y ( ) const [inline]

Definition at line 62 of file Vector4.hh.

{ return get(2); }
double y2 ( ) const [inline]

Definition at line 63 of file Vector4.hh.

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

Definition at line 66 of file Vector4.hh.

{ return get(3); }
double z2 ( ) const [inline]

Definition at line 67 of file Vector4.hh.

{ return sqr(z()); }

Friends And Related Function Documentation

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

Definition at line 245 of file Vector4.hh.

                                                                  {
    FourVector result;
    result._vec = a._vec + b._vec;
    return result;
  }
FourVector multiply ( const double  a,
const FourVector v 
) [friend]

Definition at line 223 of file Vector4.hh.

                                                                  {
    FourVector result;
    result._vec = a * v._vec;
    return result;
  }
FourVector multiply ( const FourVector v,
const double  a 
) [friend]

Definition at line 229 of file Vector4.hh.

                                                                  {
    return multiply(a, v);
  }
FourVector transform ( const LorentzTransform lt,
const FourVector v4 
) [friend]

Definition at line 250 of file LorentzTrans.hh.

                                                                                {
      return lt.transform(v4);
  }

Member Data Documentation

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

Vector.

Definition at line 133 of file VectorN.hh.


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