rivet is hosted by Hepforge, IPPP Durham

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

#include <Vector4.hh>

Inheritance diagram for FourVector:
Collaboration diagram for FourVector:

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

Detailed Description

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

Definition at line 20 of file Vector4.hh.


Constructor & Destructor Documentation

FourVector ( ) [inline]

Definition at line 28 of file Vector4.hh.

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

Definition at line 31 of file Vector4.hh.

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

                                {
      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 38 of file Vector4.hh.

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

Definition at line 41 of file Vector4.hh.

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

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

Definition at line 48 of file Vector4.hh.

{ }

Member Function Documentation

double abseta ( ) const [inline]

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

Definition at line 142 of file Vector4.hh.

References FourVector::eta().

Referenced by ParticleBase::abseta(), and Rivet::abseta().

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

Get the $ |\eta| $ directly.

Definition at line 139 of file Vector4.hh.

References FourVector::eta().

Referenced by ParticleBase::abspseudorapidity(), and Rivet::abspseudorapidity().

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

Angle between this vector and another.

Definition at line 67 of file Vector4.hh.

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

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

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

Angle between this vector and another (3-vector)

Definition at line 72 of file Vector4.hh.

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

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

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

Definition at line 153 of file Vector4.hh.

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

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

                                               {
      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 159 of file Vector4.hh.

References FourVector::contract().

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

Definition at line 33 of file VectorN.hh.

References Vector< N >::_vec.

                                                {
      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.

References Vector< N >::_vec.

                                    {
      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 61 of file Vector4.hh.

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

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

                             {
      // Done this way for numerical precision
      return (t() + z())*(t() - z()) - x()*x() - y()*y();
    }
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< N >::_vec, and Rivet::isZero().

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

References Vector< N >::mod2().

                       {
      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.

References Vector< N >::mod2(), and Vector< N >::size().

                        {
      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.

References Vector< N >::_vec.

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

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

Definition at line 164 of file Vector4.hh.

References FourVector::contract().

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

Multiply by a scalar.

Reimplemented in FourMomentum.

Definition at line 169 of file Vector4.hh.

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

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

Add to this 4-vector.

Definition at line 181 of file Vector4.hh.

References Vector< 4 >::_vec, Vector< N >::_vec, and FourVector::add.

                                                {
      _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 193 of file Vector4.hh.

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

                                 {
      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 187 of file Vector4.hh.

References Vector< 4 >::_vec, Vector< N >::_vec, and FourVector::add.

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

Divide by a scalar.

Reimplemented in FourMomentum.

Definition at line 175 of file Vector4.hh.

References Vector< 4 >::_vec, Vector< N >::_vec, and FourVector::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.

References Vector< N >::_vec.

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

Definition at line 112 of file VectorN.hh.

References Vector< N >::_vec.

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

Definition at line 100 of file VectorN.hh.

References Vector< N >::_vec.

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

Definition at line 116 of file VectorN.hh.

References Vector< N >::_vec.

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

Definition at line 120 of file VectorN.hh.

References Vector< N >::_vec.

                                              {
      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 perp2 ( ) const [inline]

Synonym for polarRadius2.

Definition at line 84 of file Vector4.hh.

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

Referenced by ATLAS_2011_S9108483::analyze(), and Rivet::perp2().

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

Synonym for azimuthalAngle.

Definition at line 114 of file Vector4.hh.

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

Referenced by STAR_2008_S7993412::analyze(), ATLAS_2011_S9002537::analyze(), MC_DIPHOTON::analyze(), CDF_2005_S6080774::analyze(), ATLAS_2011_S8994773::analyze(), D0_1996_S3324664::analyze(), D0_2008_S6879055::analyze(), CDF_1993_S2742446::analyze(), CDF_2009_S8436959::analyze(), ATLAS_2011_I930220::analyze(), CDF_2012_NOTE10874::analyze(), CMS_2011_S8973270::analyze(), D0_2010_S8570965::analyze(), MC_LEADJETUE::analyze(), D0_2010_S8821313::analyze(), MC_PHOTONJETS::analyze(), CDF_1994_S2952106::analyze(), CMS_2011_S9120041::analyze(), ATLAS_2012_I946427::analyze(), STAR_2009_UE_HELEN::analyze(), CMS_2012_I1107658::analyze(), MC_PHOTONJETUE::analyze(), MC_WWINC::analyze(), CDF_2010_S8591881_QCD::analyze(), MC_GENERIC::analyze(), ATLAS_2011_S9212183::analyze(), ATLAS_2011_S9120807::analyze(), ATLAS_2013_I1217867::analyze(), ATLAS_2011_CONF_2011_098::analyze(), CDF_2001_S4751469::analyze(), ATLAS_2010_S8914702::analyze(), ATLAS_2012_I1095236::analyze(), D0_2008_S7719523::analyze(), ATLAS_2012_I1125961::analyze(), ATLAS_2012_CONF_2012_109::analyze(), ATLAS_2011_S8983313::analyze(), ATLAS_2011_CONF_2011_090::analyze(), ATLAS_2012_I1083318::analyze(), ATLAS_2010_S8894728::analyze(), MC_SUSY::analyze(), ATLAS_2011_S9212353::analyze(), ATLAS_2012_I1093738::analyze(), ATLAS_2011_S9041966::analyze(), MC_VH2BB::analyze(), ATLAS_2012_I1091481::getSeta(), ParticleBase::phi(), and Rivet::phi().

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

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

Definition at line 119 of file Vector4.hh.

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

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

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

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

Definition at line 94 of file Vector4.hh.

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

Referenced by Rivet::polarRadius().

                               {
      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 79 of file Vector4.hh.

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

Referenced by Rivet::polarRadius2().

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

Synonym for polarRadius.

Definition at line 104 of file Vector4.hh.

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

Referenced by Rivet::rho().

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

Synonym for polarRadius2.

Definition at line 89 of file Vector4.hh.

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

Referenced by Rivet::rho2().

                        {
      return vector3().rho2();
    }
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< N >::_vec.

                                                           {
      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.

References FourVector::t().

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

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

Definition at line 57 of file Vector4.hh.

References FourVector::x().

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

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

Definition at line 58 of file Vector4.hh.

References FourVector::y().

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

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

Definition at line 59 of file Vector4.hh.

References FourVector::z().

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

{ set(3, 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 124 of file Vector4.hh.

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

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

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

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

Definition at line 145 of file Vector4.hh.

Referenced by CDF_1996_S3349578::_fiveJetAnalysis(), D0_1996_S3214044::_fourJetAnalysis(), CDF_1996_S3349578::_fourJetAnalysis(), CDF_1997_S3541940::_psi(), CDF_1996_S3349578::_psi(), CDF_1996_S3349578::_threeJetAnalysis(), D0_1996_S3214044::_threeJetAnalysis(), CLEO_2004_S5809304::analyze(), BELLE_2001_S4598261::analyze(), BABAR_2003_I593379::analyze(), ARGUS_1993_S2653028::analyze(), OPAL_1994_S2927284::analyze(), OPAL_1993_S2692198::analyze(), SLD_2004_S5693039::analyze(), OPAL_1998_S3780481::analyze(), SLD_1999_S3743934::analyze(), OPAL_1995_S3198391::analyze(), ARGUS_1993_S2669951::analyze(), CMS_2011_S8957746::analyze(), ALEPH_2002_S4823664::analyze(), ALICE_2012_I1181770::analyze(), OPAL_1996_S3257789::analyze(), OPAL_1998_S3702294::analyze(), DELPHI_1999_S3960137::analyze(), BABAR_2007_S7266081::analyze(), DELPHI_1995_S3137023::analyze(), OPAL_1998_S3749908::analyze(), OPAL_1997_S3396100::analyze(), CDF_1997_S3541940::analyze(), ATLAS_2012_I1082009::analyze(), ARGUS_1993_S2789213::analyze(), MC_ZZINC::analyze(), MC_WWINC::analyze(), TASSO_1990_S2148048::analyze(), ALEPH_1996_S3486095::analyze(), ALEPH_2004_S5765862::analyze(), DELPHI_1996_S3430090::analyze(), FourVector::angle(), Rivet::angle(), FourVector::azimuthalAngle(), FParameter::calc(), Spherocity::calc(), Thrust::calc(), Sphericity::calc(), Rivet::cmpMomByAscP(), Rivet::cmpMomByP(), Rivet::deltaEta(), Rivet::deltaPhi(), Rivet::deltaR(), FourVector::eta(), ATLAS_2012_I1091481::getPionEnergy(), FourMomentum::p(), FourVector::perp(), FourVector::perp2(), FourVector::phi(), FourVector::polarAngle(), FourVector::polarRadius(), FourVector::polarRadius2(), DISKinematics::project(), FoxWolframMoments::project(), MissingMomentum::project(), Hemispheres::project(), FourVector::pseudorapidity(), FourMomentum::pT2(), FourMomentum::pt2(), FourVector::rho(), FourVector::rho2(), and FourVector::theta().

                            {
      return Vector3(get(1), get(2), get(3));
    }

Friends And Related Function Documentation

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

Definition at line 234 of file Vector4.hh.

Referenced by FourVector::operator+=(), and FourVector::operator-=().

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

Definition at line 212 of file Vector4.hh.

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

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

Definition at line 218 of file Vector4.hh.

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

Definition at line 157 of file LorentzTrans.hh.

                                                                                {
      return lt.transform(v4);
  }

Member Data Documentation


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