FourVector Class Reference

#include <Vector4.hh>

Inheritance diagram for FourVector:

Inheritance graph
[legend]

Collaboration diagram for FourVector:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 19 of file Vector4.hh.


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 x () const
double y () const
double z () const
FourVectorsetT (const double t)
FourVectorsetX (const double x)
FourVectorsetY (const double y)
FourVectorsetZ (const double z)
double invariant () const
double angle (const FourVector &v) const
double angle (const Vector3 &v3) 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 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
double eta () const
 Synonym for pseudorapidity.
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)
FourVectoroperator-= (const FourVector &v)
FourVector 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

Protected Member Functions

double & get (const size_t index)

Protected 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)

Constructor & Destructor Documentation

FourVector (  )  [inline]

Definition at line 26 of file Vector4.hh.

00026 : Vector<4>() { }

FourVector ( const V4 &  other  )  [inline]

Definition at line 29 of file Vector4.hh.

References FourVector::setT(), FourVector::setX(), FourVector::setY(), and FourVector::setZ().

00029                                 {
00030       this->setT(other.t());
00031       this->setX(other.x());
00032       this->setY(other.y());
00033       this->setZ(other.z());
00034     }

FourVector ( const Vector< 4 > &  other  )  [inline]

Definition at line 36 of file Vector4.hh.

00037     : Vector<4>(other) { }

FourVector ( const double  t,
const double  x,
const double  y,
const double  z 
) [inline]

Definition at line 39 of file Vector4.hh.

References FourVector::setT(), FourVector::setX(), FourVector::setY(), and FourVector::setZ().

00039                                                                                {
00040       this->setT(t);
00041       this->setX(x);
00042       this->setY(y);
00043       this->setZ(z);
00044     }

virtual ~FourVector (  )  [inline, virtual]

Definition at line 46 of file Vector4.hh.

00046 { }


Member Function Documentation

double t (  )  const [inline]

Definition at line 49 of file Vector4.hh.

Referenced by FourVector::contract(), FourMomentum::E(), FourVector::invariant(), and Rivet::toString().

00049 { return get(0); }

double x (  )  const [inline]

double y (  )  const [inline]

double z (  )  const [inline]

FourVector& setT ( const double  t  )  [inline]

Definition at line 53 of file Vector4.hh.

Referenced by FourVector::FourVector(), and FourMomentum::setE().

00053 { set(0, t); return *this; }

FourVector& setX ( const double  x  )  [inline]

Definition at line 54 of file Vector4.hh.

Referenced by FourVector::FourVector(), and FourMomentum::setPx().

00054 { set(1, x); return *this; }

FourVector& setY ( const double  y  )  [inline]

Definition at line 55 of file Vector4.hh.

Referenced by FourVector::FourVector(), and FourMomentum::setPy().

00055 { set(2, y); return *this; }

FourVector& setZ ( const double  z  )  [inline]

Definition at line 56 of file Vector4.hh.

Referenced by FourVector::FourVector(), and FourMomentum::setPz().

00056 { set(3, z); return *this; }

double invariant (  )  const [inline]

Definition at line 58 of file Vector4.hh.

References FourVector::t(), FourVector::x(), FourVector::y(), and FourVector::z().

Referenced by D0_2001_S4674421::analyze(), Rivet::invariant(), and FourMomentum::mass2().

00058                              {
00059       return t()*t() - x()*x() - y()*y() - z()*z();
00060     }

double angle ( const FourVector v  )  const [inline]

Definition at line 62 of file Vector4.hh.

References Vector3::angle(), and FourVector::vector3().

Referenced by D0_1996_S3214044::_fourJetAnalysis(), H1_2000_S4129130::analyze(), H1_1994_S2919893::analyze(), and Rivet::angle().

00062                                             {
00063       return vector3().angle( v.vector3() );
00064     }

double angle ( const Vector3 v3  )  const [inline]

Definition at line 66 of file Vector4.hh.

References Vector3::angle(), and FourVector::vector3().

00066                                           {
00067       return vector3().angle(v3);
00068     }

double polarRadius2 (  )  const [inline]

Definition at line 70 of file Vector4.hh.

References Vector3::polarRadius2(), and FourVector::vector3().

Referenced by Rivet::polarRadius2().

00070                                 {
00071       return vector3().polarRadius2();
00072     }

double perp2 (  )  const [inline]

Synonym for polarRadius2.

Definition at line 75 of file Vector4.hh.

References Vector3::perp2(), and FourVector::vector3().

Referenced by Rivet::perp2().

00075                          {
00076       return vector3().perp2();
00077     }

double rho2 (  )  const [inline]

Synonym for polarRadius2.

Definition at line 80 of file Vector4.hh.

References Vector3::rho2(), and FourVector::vector3().

Referenced by Rivet::rho2().

00080                         {
00081       return vector3().rho2();
00082     }

double polarRadius (  )  const [inline]

Definition at line 84 of file Vector4.hh.

References Vector3::polarRadius(), and FourVector::vector3().

Referenced by Rivet::polarRadius().

00084                                {
00085       return vector3().polarRadius();
00086     }

double perp (  )  const [inline]

Synonym for polarRadius.

Definition at line 89 of file Vector4.hh.

References Vector3::perp(), and FourVector::vector3().

Referenced by Rivet::perp().

00089                         {
00090       return vector3().perp();
00091     }

double rho (  )  const [inline]

Synonym for polarRadius.

Definition at line 94 of file Vector4.hh.

References Vector3::rho(), and FourVector::vector3().

Referenced by Rivet::rho().

00094                        {
00095       return vector3().rho();
00096     }

double azimuthalAngle ( const PhiMapping  mapping = ZERO_2PI  )  const [inline]

double phi ( const PhiMapping  mapping = ZERO_2PI  )  const [inline]

double polarAngle (  )  const [inline]

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

Definition at line 109 of file Vector4.hh.

References Vector3::polarAngle(), and FourVector::vector3().

Referenced by H1_1994_S2919893::beamAngle(), FourMomentum::Et(), Rivet::polarAngle(), and DISKinematics::project().

00109                               {
00110       return vector3().polarAngle();
00111     }

double theta (  )  const [inline]

Synonym for polarAngle.

Definition at line 114 of file Vector4.hh.

References Vector3::theta(), and FourVector::vector3().

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

00114                          {
00115       return vector3().theta();
00116     }

double pseudorapidity (  )  const [inline]

double eta (  )  const [inline]

Vector3 vector3 (  )  const [inline]

double contract ( const FourVector v  )  const [inline]

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

Definition at line 134 of file Vector4.hh.

References FourVector::t(), FourVector::x(), FourVector::y(), and FourVector::z().

Referenced by Rivet::contract(), FourVector::dot(), and FourVector::operator*().

00134                                                {
00135       const double result = t()*v.t() - x()*v.x() - y()*v.y() - z()*v.z();
00136       return result;
00137     }

double dot ( const FourVector v  )  const [inline]

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

Definition at line 140 of file Vector4.hh.

References FourVector::contract().

00140                                           {
00141       return contract(v);
00142     }

double operator* ( const FourVector v  )  const [inline]

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

Definition at line 145 of file Vector4.hh.

References FourVector::contract().

00145                                                 {
00146       return contract(v);
00147     }

FourVector& operator*= ( double  a  )  [inline]

Multiply by a scalar.

Definition at line 150 of file Vector4.hh.

References Vector::_vec, Vector< 4 >::_vec, and FourVector::multiply.

00150                                      {
00151       _vec = multiply(a, *this)._vec;
00152       return *this;
00153     }

FourVector& operator/= ( double  a  )  [inline]

Divide by a scalar.

Definition at line 156 of file Vector4.hh.

References Vector::_vec, Vector< 4 >::_vec, and FourVector::multiply.

00156                                      {
00157       _vec = multiply(1.0/a, *this)._vec;
00158       return *this;
00159     }

FourVector& operator+= ( const FourVector v  )  [inline]

Definition at line 161 of file Vector4.hh.

References Vector< 4 >::_vec.

00161                                                 {
00162       _vec = add(*this, v)._vec;
00163       return *this;
00164     }

FourVector& operator-= ( const FourVector v  )  [inline]

Definition at line 166 of file Vector4.hh.

References Vector< 4 >::_vec.

00166                                                 {
00167       _vec = add(*this, -v)._vec;
00168       return *this;
00169     }

FourVector operator- (  )  const [inline]

Invert the vector.

Reimplemented from Vector< 4 >.

Definition at line 171 of file Vector4.hh.

References Vector< 4 >::_vec, and Vector::_vec.

00171                                  {
00172       FourVector result;
00173       result._vec = -_vec;
00174       return result;
00175     }

const double& get ( const size_t  index  )  const [inline, inherited]

Definition at line 33 of file VectorN.hh.

References Vector::_vec.

00033                                                 {
00034       if (index >= N) {
00035         throw std::runtime_error("Tried to access an invalid vector index.");
00036       } else {
00037         return _vec(index);
00038       }
00039     }

double& get ( const size_t  index  )  [inline, protected, inherited]

Definition at line 126 of file VectorN.hh.

References Vector::_vec.

00126                                     {
00127       if (index >= N) {
00128         throw std::runtime_error("Tried to access an invalid vector index.");
00129       } else {
00130         return _vec(index);
00131       }
00132     }

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.

00042                                                        {
00043       return get(index);
00044     }

double& operator[] ( const size_t  index  )  [inline, inherited]

Direct access to vector elements by index.

Definition at line 47 of file VectorN.hh.

00047                                            {
00048       return get(index);
00049     }

Vector<N>& set ( const size_t  index,
const double  value 
) [inline, inherited]

Set indexed value.

Definition at line 52 of file VectorN.hh.

References Vector::_vec.

00052                                                            {
00053       if (index >= N) {
00054         throw std::runtime_error("Tried to access an invalid vector index.");
00055       } else {
00056         _vec[index] = value;
00057       }
00058       return *this;
00059     }

size_t size (  )  const [inline, inherited]

Vector dimensionality.

Definition at line 62 of file VectorN.hh.

00062                         {
00063       return N;
00064     }

bool isZero ( double  tolerance = 1E-5  )  const [inline, inherited]

Check for nullness, allowing for numerical precision.

Definition at line 67 of file VectorN.hh.

References Vector::_vec, and Rivet::isZero().

00067                                              {
00068       for (size_t i=0; i < N; ++i) {
00069         if (! Rivet::isZero(_vec[i], tolerance) ) return false;
00070       }
00071       return true;
00072     }

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.

References Vector::mod2(), and Vector::size().

00076                         {
00077       double mod2 = 0.0;
00078       for (size_t i = 0; i < size(); ++i) {
00079         const double element = get(i);
00080         mod2 += element*element;
00081       }
00082       return mod2;
00083     }

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.

References Vector::mod2().

00087                        {
00088       const double norm = mod2();
00089       assert(norm >= 0);
00090       return sqrt(norm);
00091     }

bool operator== ( const Vector< N > &  a  )  const [inline, inherited]

Definition at line 100 of file VectorN.hh.

References Vector::_vec.

00100                                               {
00101       return _vec == a._vec;
00102     }

bool operator!= ( const Vector< N > &  a  )  const [inline, inherited]

Definition at line 104 of file VectorN.hh.

References Vector::_vec.

00104                                               {
00105       return _vec != a._vec;
00106     }

bool operator< ( const Vector< N > &  a  )  const [inline, inherited]

Definition at line 108 of file VectorN.hh.

References Vector::_vec.

00108                                              {
00109       return _vec < a._vec;
00110     }

bool operator<= ( const Vector< N > &  a  )  const [inline, inherited]

Definition at line 112 of file VectorN.hh.

References Vector::_vec.

00112                                               {
00113       return _vec <= a._vec;
00114     }

bool operator> ( const Vector< N > &  a  )  const [inline, inherited]

Definition at line 116 of file VectorN.hh.

References Vector::_vec.

00116                                              {
00117       return _vec > a._vec;
00118     }

bool operator>= ( const Vector< N > &  a  )  const [inline, inherited]

Definition at line 120 of file VectorN.hh.

References Vector::_vec.

00120                                               {
00121       return _vec >= a._vec;
00122     }


Friends And Related Function Documentation

FourVector multiply ( const double  a,
const FourVector v 
) [friend]

Definition at line 190 of file Vector4.hh.

Referenced by FourVector::operator*=(), and FourVector::operator/=().

00190                                                                   {
00191     FourVector result;
00192     result._vec = a * v._vec;
00193     return result;
00194   }

FourVector multiply ( const FourVector v,
const double  a 
) [friend]

Definition at line 196 of file Vector4.hh.

00196                                                                   {
00197     return multiply(a, v);
00198   }

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

Definition at line 212 of file Vector4.hh.

00212                                                                   {
00213     FourVector result;
00214     result._vec = a._vec + b._vec;
00215     return result;
00216   }

FourVector transform ( const LorentzTransform lt,
const FourVector v4 
) [friend]

Definition at line 156 of file LorentzTrans.hh.

00156                                                                                 {
00157       return lt.transform(v4);
00158   }


Member Data Documentation

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


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