FourMomentum Class Reference

Specialized version of the FourVector with momentum/energy functionality. More...

#include <Vector4.hh>

Inheritance diagram for FourMomentum:
Inheritance graph
[legend]
Collaboration diagram for FourMomentum:
Collaboration graph
[legend]

List of all members.

Classes

struct  byEAscending
 struct for sorting by increasing energy More...
struct  byEDescending
 struct for sorting by decreasing energy More...

Public Member Functions

 FourMomentum ()
template<typename V4 >
 FourMomentum (const V4 &other)
 FourMomentum (const Vector< 4 > &other)
 FourMomentum (const double E, const double px, const double py, const double pz)
 ~FourMomentum ()
double E () const
 Get energy $ E $ (time component of momentum).
Vector3 p () const
 Get 3-momentum part, $ p $.
double px () const
 Get x-component of momentum $ p_x $.
double py () const
 Get y-component of momentum $ p_y $.
double pz () const
 Get z-component of momentum $ p_z $.
FourMomentumsetE (double E)
 Set energy $ E $ (time component of momentum).
FourMomentumsetPx (double px)
 Set x-component of momentum $ p_x $.
FourMomentumsetPy (double py)
 Set y-component of momentum $ p_y $.
FourMomentumsetPz (double pz)
 Set z-component of momentum $ p_z $.
double mass2 () const
 Get squared mass $ m^2 = E^2 - p^2 $ (the Lorentz self-invariant).
double mass () const
 Get mass $ m = \sqrt{E^2 - p^2} $ (the Lorentz self-invariant).
double rapidity () const
 Calculate rapidity.
double pT2 () const
 Calculate squared transverse momentum $ p_T^2 $.
double pT () const
 Calculate transverse momentum $ p_T $.
double Et2 () const
 Calculate transverse energy $ E_T^2 = E^2 \sin^2{\theta} $.
double Et () const
 Calculate transverse energy $ E_T = E \sin{\theta} $.
Vector3 boostVector () const
 Calculate boost vector (in units of $ \beta $).
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.

Detailed Description

Specialized version of the FourVector with momentum/energy functionality.

Definition at line 310 of file Vector4.hh.


Constructor & Destructor Documentation

FourMomentum (  )  [inline]

Definition at line 312 of file Vector4.hh.

00312 { }

FourMomentum ( const V4 &  other  )  [inline]

Definition at line 315 of file Vector4.hh.

References FourMomentum::setE(), FourMomentum::setPx(), FourMomentum::setPy(), and FourMomentum::setPz().

00315                                   {
00316       this->setE(other.t());
00317       this->setPx(other.x());
00318       this->setPy(other.y());
00319       this->setPz(other.z());
00320     }

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

Definition at line 322 of file Vector4.hh.

00323       : FourVector(other) { }

FourMomentum ( const double  E,
const double  px,
const double  py,
const double  pz 
) [inline]

Definition at line 325 of file Vector4.hh.

References FourMomentum::setE(), FourMomentum::setPx(), FourMomentum::setPy(), and FourMomentum::setPz().

00325                                                                                     {
00326       this->setE(E);
00327       this->setPx(px);
00328       this->setPy(py);
00329       this->setPz(pz);
00330     }

~FourMomentum (  )  [inline]

Definition at line 332 of file Vector4.hh.

00332 {}


Member Function Documentation

double angle ( const Vector3 v3  )  const [inline, inherited]

Definition at line 68 of file Vector4.hh.

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

00068                                           {
00069       return vector3().angle(v3);
00070     }

double angle ( const FourVector v  )  const [inline, inherited]

Definition at line 64 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().

00064                                             {
00065       return vector3().angle( v.vector3() );
00066     }

double azimuthalAngle ( const PhiMapping  mapping = ZERO_2PI  )  const [inline, inherited]
Vector3 boostVector (  )  const [inline]

Calculate boost vector (in units of $ \beta $).

Todo:
Be careful about c=1 convention...

Definition at line 403 of file Vector4.hh.

References FourMomentum::E(), FourMomentum::px(), FourMomentum::py(), and FourMomentum::pz().

Referenced by CDF_1997_S3541940::_avg_beam_in_lab(), CDF_1996_S3349578::_avg_beam_in_lab(), CDF_1996_S3349578::_fiveJetAnalysis(), D0_1996_S3214044::_fourJetAnalysis(), CDF_1996_S3349578::_fourJetAnalysis(), D0_1996_S3214044::_threeJetAnalysis(), CDF_1996_S3349578::_threeJetAnalysis(), CDF_1997_S3541940::analyze(), CDF_1996_S3108457::analyze(), BELLE_2006_S6265367::analyze(), Rivet::boostVector(), and DISKinematics::project().

00403                                 {
00404       // const Vector3 p3 = vector3();
00405       // const double m2 = mass2();
00406       // if (Rivet::isZero(m2)) return p3.unit();
00407       // else {
00408       //   // Could also do this via beta = tanh(rapidity), but that's
00409       //   // probably more messy from a numerical hygiene point of view.
00410       //   const double p2 = p3.mod2();
00411       //   const double beta = sqrt( p2 / (m2 + p2) );
00412       //   return beta * p3.unit();
00413       // }
00414       /// @todo Be careful about c=1 convention...
00415       return Vector3(px()/E(), py()/E(), pz()/E());
00416     }

double contract ( const FourVector v  )  const [inline, inherited]

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

Definition at line 136 of file Vector4.hh.

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

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

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

double dot ( const FourVector v  )  const [inline, inherited]

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

Definition at line 142 of file Vector4.hh.

References FourVector::contract().

00142                                           {
00143       return contract(v);
00144     }

double E (  )  const [inline]
double Et (  )  const [inline]
double Et2 (  )  const [inline]

Calculate transverse energy $ E_T^2 = E^2 \sin^2{\theta} $.

Definition at line 393 of file Vector4.hh.

References FourMomentum::Et().

Referenced by Rivet::Et2(), and byETAscending::operator()().

00393                        {
00394       return Et() * Et();
00395     }

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

Definition at line 126 of file VectorN.hh.

References Vector< N >::_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& get ( const size_t  index  )  const [inline, inherited]

Definition at line 33 of file VectorN.hh.

References Vector< N >::_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 invariant (  )  const [inline, inherited]

Definition at line 59 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().

00059                              {
00060       // Done this way for numerical precision
00061       return (t() + z())*(t() - z()) - x()*x() - y()*y();
00062     }

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

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 mass (  )  const [inline]
double mass2 (  )  const [inline]
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().

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

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

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     }

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

Definition at line 104 of file VectorN.hh.

References Vector< N >::_vec.

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

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

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

Definition at line 147 of file Vector4.hh.

References FourVector::contract().

00147                                                 {
00148       return contract(v);
00149     }

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

Multiply by a scalar.

Definition at line 152 of file Vector4.hh.

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

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

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

Definition at line 163 of file Vector4.hh.

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

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

FourVector operator- (  )  const [inline, inherited]

Invert the vector.

Reimplemented from Vector< 4 >.

Definition at line 173 of file Vector4.hh.

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

00173                                  {
00174       FourVector result;
00175       result._vec = -_vec;
00176       return result;
00177     }

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

Definition at line 168 of file Vector4.hh.

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

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

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

Divide by a scalar.

Definition at line 158 of file Vector4.hh.

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

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

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

Definition at line 108 of file VectorN.hh.

References Vector< N >::_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< N >::_vec.

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

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

Definition at line 100 of file VectorN.hh.

References Vector< N >::_vec.

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

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

Definition at line 116 of file VectorN.hh.

References Vector< N >::_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< N >::_vec.

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

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     }

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     }

Vector3 p (  )  const [inline]

Get 3-momentum part, $ p $.

Definition at line 339 of file Vector4.hh.

References FourVector::vector3().

Referenced by ATLAS_2010_CONF_2010_049::analyze().

00339 { return vector3(); }

double perp (  )  const [inline, inherited]

Synonym for polarRadius.

Definition at line 91 of file Vector4.hh.

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

Referenced by MC_TTBAR::analyze(), LHCB_2010_S8758301::analyze(), ATLAS_2010_CONF_2010_081::analyze(), and Rivet::perp().

00091                         {
00092       return vector3().perp();
00093     }

double perp2 (  )  const [inline, inherited]

Synonym for polarRadius2.

Definition at line 77 of file Vector4.hh.

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

Referenced by Rivet::perp2().

00077                          {
00078       return vector3().perp2();
00079     }

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

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

Definition at line 111 of file Vector4.hh.

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

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

00111                               {
00112       return vector3().polarAngle();
00113     }

double polarRadius (  )  const [inline, inherited]

Definition at line 86 of file Vector4.hh.

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

Referenced by Rivet::polarRadius().

00086                                {
00087       return vector3().polarRadius();
00088     }

double polarRadius2 (  )  const [inline, inherited]

Definition at line 72 of file Vector4.hh.

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

Referenced by Rivet::polarRadius2().

00072                                 {
00073       return vector3().polarRadius2();
00074     }

double pseudorapidity (  )  const [inline, inherited]
double pT (  )  const [inline]

Calculate transverse momentum $ p_T $.

Definition at line 388 of file Vector4.hh.

References FourMomentum::pT2().

Referenced by SVertex::_applyVtxTrackCuts(), CDF_2004_S5839831::_calcTransCones(), FinalState::accept(), UA1_1990_S2044935::analyze(), STAR_2009_UE_HELEN::analyze(), STAR_2008_S7993412::analyze(), STAR_2008_S7869363::analyze(), STAR_2006_S6870392::analyze(), STAR_2006_S6860818::analyze(), STAR_2006_S6500200::analyze(), MC_ZZJETS::analyze(), MC_ZJETS::analyze(), MC_WWJETS::analyze(), MC_WJETS::analyze(), MC_SUSY::analyze(), MC_PHOTONJETUE::analyze(), MC_PHOTONJETS::analyze(), MC_LEADINGJETS::analyze(), MC_HJETS::analyze(), MC_GENERIC::analyze(), MC_DIPHOTON::analyze(), MC_DIJET::analyze(), D0_2010_S8671338::analyze(), D0_2010_S8570965::analyze(), D0_2009_S8349509::analyze(), D0_2008_S7863608::analyze(), D0_2008_S7719523::analyze(), D0_2007_S7075677::analyze(), D0_2006_S6438750::analyze(), D0_2001_S4674421::analyze(), D0_1998_S3711838::analyze(), CDF_2009_S8233977::analyze(), CDF_2008_S8095620::analyze(), CDF_2008_S7782535::analyze(), CDF_2008_S7541902::analyze(), CDF_2008_NOTE_9351::analyze(), CDF_2008_LEADINGJETS::analyze(), CDF_2005_S6080774::analyze(), CDF_2004_S5839831::analyze(), CDF_2002_S4796047::analyze(), CDF_2001_S4751469::analyze(), CDF_2000_S4155203::analyze(), CDF_1994_S2952106::analyze(), CDF_1991_S2313472::analyze(), CDF_1988_S1865951::analyze(), ATLAS_2010_S8591806::analyze(), ATLAS_2010_CONF_2010_081::analyze(), ATLAS_2010_CONF_2010_031::analyze(), ALICE_2010_S8706239::analyze(), JetShape::calc(), Rivet::cmpMomByAscPt(), Rivet::cmpMomByPt(), Rivet::cmpParticleByAscPt(), Rivet::cmpParticleByPt(), JetAlg::jets(), STARRandomFilter::operator()(), VetoedFinalState::project(), ClosestJetShape::project(), and Rivet::pT().

00388                       {
00389       return sqrt(pT2());
00390     }

double pT2 (  )  const [inline]

Calculate squared transverse momentum $ p_T^2 $.

Definition at line 383 of file Vector4.hh.

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

Referenced by byPTAscending::operator()(), FourMomentum::pT(), and Rivet::pT2().

00383                        {
00384       return vector3().polarRadius2();
00385     }

double px (  )  const [inline]
double py (  )  const [inline]

Get y-component of momentum $ p_y $.

Definition at line 345 of file Vector4.hh.

References FourVector::y().

Referenced by OPAL_1993_S2692198::analyze(), CDF_2008_S7541902::analyze(), FourMomentum::boostVector(), FastJets::calc(), Rivet::get2dDecayLength(), and Rivet::get3dDecayLength().

00345 { return y(); }

double pz (  )  const [inline]
double rapidity (  )  const [inline]
double rho (  )  const [inline, inherited]

Synonym for polarRadius.

Definition at line 96 of file Vector4.hh.

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

Referenced by Rivet::rho().

00096                        {
00097       return vector3().rho();
00098     }

double rho2 (  )  const [inline, inherited]

Synonym for polarRadius2.

Definition at line 82 of file Vector4.hh.

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

Referenced by Rivet::rho2().

00082                         {
00083       return vector3().rho2();
00084     }

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.

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     }

FourMomentum& setE ( double  E  )  [inline]

Set energy $ E $ (time component of momentum).

Definition at line 351 of file Vector4.hh.

References FourVector::setT().

Referenced by FourMomentum::FourMomentum().

00351 { setT(E); return *this; }

FourMomentum& setPx ( double  px  )  [inline]

Set x-component of momentum $ p_x $.

Definition at line 354 of file Vector4.hh.

References FourVector::setX().

Referenced by FourMomentum::FourMomentum().

00354 { setX(px); return *this; }

FourMomentum& setPy ( double  py  )  [inline]

Set y-component of momentum $ p_y $.

Definition at line 357 of file Vector4.hh.

References FourVector::setY().

Referenced by FourMomentum::FourMomentum().

00357 { setY(py); return *this; }

FourMomentum& setPz ( double  pz  )  [inline]

Set z-component of momentum $ p_z $.

Definition at line 360 of file Vector4.hh.

References FourVector::setZ().

Referenced by FourMomentum::FourMomentum().

00360 { setZ(pz); return *this; }

FourVector& setT ( const double  t  )  [inline, inherited]

Definition at line 54 of file Vector4.hh.

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

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

FourVector& setX ( const double  x  )  [inline, inherited]

Definition at line 55 of file Vector4.hh.

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

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

FourVector& setY ( const double  y  )  [inline, inherited]

Definition at line 56 of file Vector4.hh.

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

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

FourVector& setZ ( const double  z  )  [inline, inherited]

Definition at line 57 of file Vector4.hh.

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

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

size_t size (  )  const [inline, inherited]

Vector dimensionality.

Definition at line 62 of file VectorN.hh.

00062                         {
00063       return N;
00064     }

double t (  )  const [inline, inherited]

Definition at line 50 of file Vector4.hh.

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

00050 { return get(0); }

double theta (  )  const [inline, inherited]

Synonym for polarAngle.

Definition at line 116 of file Vector4.hh.

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

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

00116                          {
00117       return vector3().theta();
00118     }

Vector3 vector3 (  )  const [inline, inherited]
double x (  )  const [inline, inherited]
double y (  )  const [inline, inherited]
double z (  )  const [inline, inherited]

Member Data Documentation

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

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