Belle II Software light-2406-ragdoll
FourVector Class Reference

Yet another four vector class, with metric +—. More...

#include <FourVector.h>

Collaboration diagram for FourVector:

Public Member Functions

 FourVector ()
 Default constructor.
 
 FourVector (double E_, double px_, double py_, double pz_)
 Constructor from the components.
 
 FourVector (double E_, const ThreeVector &p_)
 Constructor from energy and three momentum.
 
 FourVector (const ThreeVector &p_, double m_)
 Constructor from three momentum and mass.
 
double getE () const
 Returns the energy / 0 component.
 
double getPx () const
 Returns the x momentum / 1 component.
 
double getPy () const
 Returns the y momentum / 2 component.
 
double getPz () const
 Returns the z momentum / 3 component.
 
double getM2 () const
 Returns the mass squared / magnitude squared.
 
double getM () const
 Returns the mass / magnitude.
 
double getMass () const
 Returns the mass / magnitude.
 
double getP2 () const
 Returns the momentum squared / magnitude of the three vector squared.
 
double getP () const
 Returns the momentum / magnitude of the three vector.
 
double getPt2 () const
 Returns the transverse momentum squared / magnitude of the 1 and 2 component vector squared.
 
double getPt () const
 Returns the transverse momentum / magnitude of the 1 and 2 component vector.
 
double getPhi () const
 Returns the azimuthal angle of the momentum / three vector squared.
 
double getTheta () const
 Returns the polar angle of the momentum / three vector squared.
 
double getEta () const
 Returns the pseudo rapidity of the momentum / three vector squared.
 
double getComponent (int i) const
 Returns the i'th component (starting from 0=energy)
 
ThreeVector getBeta () const
 
double getGamma () const
 
ThreeVector getBetaGamma () const
 
const ThreeVectorgetThreeVector () const
 Returns the momentum three vector.
 
FourVectorboost (const FourVector &P)
 
void decayto (FourVector &d1, FourVector &d2) const
 
void setValues (double E_, double px_, double py_, double pz_)
 
FourVectoroperator+= (const FourVector &rhs)
 
FourVectoroperator-= (const FourVector &rhs)
 
FourVectoroperator*= (double rhs)
 

Private Attributes

double E
 The energy / 0 component.
 
ThreeVector p
 The momentum three vector.
 

Related Functions

(Note that these are not member functions.)

FourVector operator+ (const FourVector &lhs, const FourVector &rhs)
 Sum of two four vectors.
 
FourVector operator- (const FourVector &lhs, const FourVector &rhs)
 Difference of two four vectors.
 
FourVector operator- (const FourVector &rhs)
 Negative of a four vector.
 
FourVector operator* (double lhs, const FourVector &rhs)
 Scalar product of a four vector.
 
double operator* (const FourVector &lhs, const FourVector &rhs)
 Scalar product of a four vector.
 
std::ostream & operator<< (std::ostream &os, const FourVector &rhs)
 Prints a four vector.
 

Detailed Description

Yet another four vector class, with metric +—.

Author: Benno List Last update:

Date
2008/02/12 10:19:05

by:

Author
blist

Definition at line 43 of file FourVector.h.

Constructor & Destructor Documentation

◆ FourVector() [1/4]

FourVector ( )
inline

Default constructor.

Definition at line 111 of file FourVector.h.

112 : E(0), p()
113 {}
double E
The energy / 0 component.
Definition: FourVector.h:107
ThreeVector p
The momentum three vector.
Definition: FourVector.h:108

◆ FourVector() [2/4]

FourVector ( double  E_,
double  px_,
double  py_,
double  pz_ 
)
inline

Constructor from the components.

Definition at line 115 of file FourVector.h.

116 : E(E_), p(px_, py_, pz_)
117 {}

◆ FourVector() [3/4]

FourVector ( double  E_,
const ThreeVector p_ 
)
inline

Constructor from energy and three momentum.

Definition at line 119 of file FourVector.h.

120 : E(E_), p(p_)
121 {}

◆ FourVector() [4/4]

FourVector ( const ThreeVector p_,
double  m_ 
)
inline

Constructor from three momentum and mass.

Definition at line 123 of file FourVector.h.

124 : E(std::sqrt(p_.getP2() + m * m)), p(p_)
125 {}

Member Function Documentation

◆ getBeta()

ThreeVector getBeta ( ) const
inline

Definition at line 89 of file FourVector.h.

89{ assert(E > 0); return (1. / E) * p;};

◆ getBetaGamma()

ThreeVector getBetaGamma ( ) const
inline

Definition at line 91 of file FourVector.h.

91{ assert(getM() > 0); return (1. / getM() > 0) * p;};
double getM() const
Returns the mass / magnitude.
Definition: FourVector.h:139

◆ getComponent()

double getComponent ( int  i) const
inline

Returns the i'th component (starting from 0=energy)

Definition at line 147 of file FourVector.h.

148 {
149 switch (i) {
150 case 1: return getPx();
151 case 2: return getPy();
152 case 3: return getPz();
153 }
154 return getE();
155 }
double getPx() const
Returns the x momentum / 1 component.
Definition: FourVector.h:128
double getPz() const
Returns the z momentum / 3 component.
Definition: FourVector.h:130
double getPy() const
Returns the y momentum / 2 component.
Definition: FourVector.h:129
double getE() const
Returns the energy / 0 component.
Definition: FourVector.h:127

◆ getE()

double getE ( ) const
inline

Returns the energy / 0 component.

Definition at line 127 of file FourVector.h.

127{ return E; }

◆ getEta()

double getEta ( ) const
inline

Returns the pseudo rapidity of the momentum / three vector squared.

Definition at line 145 of file FourVector.h.

145{ return p.getEta(); }

◆ getGamma()

double getGamma ( ) const
inline

Definition at line 90 of file FourVector.h.

90{ assert(getM() > 0); return getE() / getM();};

◆ getM()

double getM ( ) const
inline

Returns the mass / magnitude.

Definition at line 139 of file FourVector.h.

139{ return std::sqrt(getM2()); }
double getM2() const
Returns the mass squared / magnitude squared.
Definition: FourVector.h:138

◆ getM2()

double getM2 ( ) const
inline

Returns the mass squared / magnitude squared.

Definition at line 138 of file FourVector.h.

138{ return std::abs(getE() * getE() - getP2()); }
double getP2() const
Returns the momentum squared / magnitude of the three vector squared.
Definition: FourVector.h:135

◆ getMass()

double getMass ( ) const
inline

Returns the mass / magnitude.

Definition at line 140 of file FourVector.h.

140{ return std::sqrt(getM2()); }

◆ getP()

double getP ( ) const
inline

Returns the momentum / magnitude of the three vector.

Definition at line 136 of file FourVector.h.

136{ return p.getP(); }

◆ getP2()

double getP2 ( ) const
inline

Returns the momentum squared / magnitude of the three vector squared.

Definition at line 135 of file FourVector.h.

135{ return p.getP2(); }

◆ getPhi()

double getPhi ( ) const
inline

Returns the azimuthal angle of the momentum / three vector squared.

Definition at line 142 of file FourVector.h.

142{ return p.getPhi(); }

◆ getPt()

double getPt ( ) const
inline

Returns the transverse momentum / magnitude of the 1 and 2 component vector.

Definition at line 133 of file FourVector.h.

133{ return p.getPt(); }

◆ getPt2()

double getPt2 ( ) const
inline

Returns the transverse momentum squared / magnitude of the 1 and 2 component vector squared.

Definition at line 132 of file FourVector.h.

132{ return p.getPt2(); }

◆ getPx()

double getPx ( ) const
inline

Returns the x momentum / 1 component.

Definition at line 128 of file FourVector.h.

128{ return p.getPx(); }

◆ getPy()

double getPy ( ) const
inline

Returns the y momentum / 2 component.

Definition at line 129 of file FourVector.h.

129{ return p.getPy(); }

◆ getPz()

double getPz ( ) const
inline

Returns the z momentum / 3 component.

Definition at line 130 of file FourVector.h.

130{ return p.getPz(); }

◆ getTheta()

double getTheta ( ) const
inline

Returns the polar angle of the momentum / three vector squared.

Definition at line 143 of file FourVector.h.

143{ return p.getTheta(); }

◆ getThreeVector()

const ThreeVector & getThreeVector ( ) const
inline

Returns the momentum three vector.

Definition at line 94 of file FourVector.h.

94{ return p;}

◆ operator*=()

FourVector & operator*= ( double  rhs)
inline

Definition at line 177 of file FourVector.h.

178 {
179 p *= rhs;
180 E *= rhs;
181 return *this;
182 }

◆ operator+=()

FourVector & operator+= ( const FourVector rhs)
inline

Definition at line 163 of file FourVector.h.

164 {
165 p += rhs.p;
166 E += rhs.E;
167 return *this;
168 }

◆ operator-=()

FourVector & operator-= ( const FourVector rhs)
inline

Definition at line 170 of file FourVector.h.

171 {
172 p -= rhs.p;
173 E -= rhs.E;
174 return *this;
175 }

◆ setValues()

void setValues ( double  E_,
double  px_,
double  py_,
double  pz_ 
)
inline

Definition at line 157 of file FourVector.h.

158 {
159 E = E_;
160 p.setValues(px_, py_, pz_);
161 }

Friends And Related Function Documentation

◆ operator*() [1/2]

double operator* ( const FourVector lhs,
const FourVector rhs 
)
related

Scalar product of a four vector.

Definition at line 224 of file FourVector.h.

225 {
226 return lhs.getE() * rhs.getE() - lhs.getPx() * rhs.getPx() - lhs.getPy() * rhs.getPy() - lhs.getPz() * rhs.getPz();
227 }

◆ operator*() [2/2]

FourVector operator* ( double  lhs,
const FourVector rhs 
)
related

Scalar product of a four vector.

Definition at line 215 of file FourVector.h.

216 {
217 return FourVector(lhs * rhs.getE(), lhs * rhs.getPx(), lhs * rhs.getPy(), lhs * rhs.getPz());
218 }
FourVector()
Default constructor.
Definition: FourVector.h:111

◆ operator+()

FourVector operator+ ( const FourVector lhs,
const FourVector rhs 
)
related

Sum of two four vectors.

Definition at line 188 of file FourVector.h.

189 {
190 return FourVector(lhs.getE() + rhs.getE(), lhs.getPx() + rhs.getPx(), lhs.getPy() + rhs.getPy(), lhs.getPz() + rhs.getPz());
191 }

◆ operator-() [1/2]

FourVector operator- ( const FourVector lhs,
const FourVector rhs 
)
related

Difference of two four vectors.

Definition at line 197 of file FourVector.h.

198 {
199 return FourVector(lhs.getE() - rhs.getE(), lhs.getPx() - rhs.getPx(), lhs.getPy() - rhs.getPy(), lhs.getPz() - rhs.getPz());
200 }

◆ operator-() [2/2]

FourVector operator- ( const FourVector rhs)
related

Negative of a four vector.

Definition at line 206 of file FourVector.h.

207 {
208 return FourVector(-rhs.getE(), -rhs.getPx(), -rhs.getPy(), -rhs.getPz());
209 }

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const FourVector rhs 
)
related

Prints a four vector.

Definition at line 234 of file FourVector.h.

237 {
238 os << "(" << rhs.getE() << ", " << rhs.getPx() << ", " << rhs.getPy() << ", " << rhs.getPz() << ")";
239 return os;
240 }

Member Data Documentation

◆ E

double E
private

The energy / 0 component.

Definition at line 107 of file FourVector.h.

◆ p

ThreeVector p
private

The momentum three vector.

Definition at line 108 of file FourVector.h.


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