LorentzTrans.hh
#ifndef RIVET_MATH_LORENTZTRANS
#define RIVET_MATH_LORENTZTRANS
#include <iostream>
#include "Rivet/Math/MathHeader.hh"
#include "Rivet/Math/MathUtils.hh"
#include "Rivet/Math/MatrixN.hh"
#include "Rivet/Math/Matrix3.hh"
#include "Rivet/Math/Vector4.hh"
namespace Rivet {
inline double lorentzGamma(const double beta) {
return 1.0 / sqrt(1 - beta*beta);
}
class LorentzTransform {
friend string toString(const LorentzTransform& lt);
public:
LorentzTransform() {
_boostMatrix = Matrix<4>::mkIdentity();
}
LorentzTransform(const Vector3& boost) {
setBoost(boost);
}
LorentzTransform(const double betaX, const double betaY, const double betaZ) {
setBoost(betaX, betaY, betaZ);
}
LorentzTransform& setBoost(const Vector3& boost) {
assert(boost.mod2() < 1);
const double beta = boost.mod();
const double gamma = lorentzGamma(beta);
_boostMatrix = Matrix<4>::mkIdentity();
_boostMatrix.set(0, 0, gamma);
_boostMatrix.set(1, 1, gamma);
// Positive coeff since these are active boosts
_boostMatrix.set(0, 1, +beta*gamma);
_boostMatrix.set(1, 0, +beta*gamma);
_boostMatrix = rotate(Vector3::mkX(), boost)._boostMatrix;
return *this;
}
// LorentzTransform& setBoost(const Vector3& boostdirection, const double beta) {
// const Vector3 boost = boostdirection.unit() * beta;
// return setBoost(boost);
// }
LorentzTransform& setBoost(const double betaX, const double betaY, const double betaZ) {
return setBoost(Vector3(betaX, betaY, betaZ));
}
Vector3 boost() const {
FourMomentum boost(_boostMatrix.getColumn(0));
//cout << "!!!" << boost << endl;
if (boost.isZero()) return boost;
assert(boost.E() > 0);
const double beta = boost.p().mod() / boost.E();
return boost.p().unit() * beta;
}
double beta() const {
return boost().mod();
}
double gamma() const {
return lorentzGamma(beta());
}
LorentzTransform rotate(const Vector3& from, const Vector3& to) const {
return rotate(Matrix3(from, to));
}
LorentzTransform rotate(const Vector3& axis, const double angle) const {
return rotate(Matrix3(axis, angle));
}
LorentzTransform rotate(const Matrix3& rot) const {
LorentzTransform lt = *this;
const Matrix4 rot4 = mkMatrix4(rot);
const Matrix4 newlt = rot4 * _boostMatrix * rot4.inverse();
lt._boostMatrix = newlt;
return lt;
}
FourVector transform(const FourVector& v4) const {
return multiply(_boostMatrix, v4);
}
LorentzTransform inverse() const {
LorentzTransform rtn;
rtn._boostMatrix = _boostMatrix.inverse();
return rtn;
}
LorentzTransform combine(const LorentzTransform& lt) const {
LorentzTransform rtn;
rtn._boostMatrix = _boostMatrix * lt._boostMatrix;
return rtn;
}
Matrix4 toMatrix() const {
return _boostMatrix;
}
LorentzTransform operator*(const LorentzTransform& lt) const {
return combine(lt);
}
LorentzTransform preMult(const Matrix3 & m3) {
_boostMatrix = multiply(mkMatrix4(m3),_boostMatrix);
return *this;
}
LorentzTransform postMult(const Matrix3 & m3) {
_boostMatrix *= mkMatrix4(m3);
return *this;
}
private:
Matrix4 mkMatrix4(const Matrix3& m3) const {
Matrix4 m4 = Matrix4::mkIdentity();
for (size_t i = 0; i < 3; ++i) {
for (size_t j = 0; j < 3; ++j) {
m4.set(i+1, j+1, m3.get(i, j));
}
}
return m4;
}
private:
Matrix4 _boostMatrix;
};
inline LorentzTransform inverse(const LorentzTransform& lt) {
return lt.inverse();
}
inline LorentzTransform combine(const LorentzTransform& a, const LorentzTransform& b) {
return a.combine(b);
}
inline FourVector transform(const LorentzTransform& lt, const FourVector& v4) {
return lt.transform(v4);
}
inline string toString(const LorentzTransform& lt) {
return toString(lt._boostMatrix);
}
inline ostream& operator<<(std::ostream& out, const LorentzTransform& lt) {
out << toString(lt);
return out;
}
}
#endif
Rivet
Definition: MC_JetAnalysis.hh:9
boost
Rivet::Vector::isZero
bool isZero(double tolerance=1E-5) const
Check for nullness, allowing for numerical precision.
Definition: VectorN.hh:67
Rivet::Vector::mod
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:87
Rivet::Matrix3
Specialisation of MatrixN to aid 3 dimensional rotations.
Definition: Matrix3.hh:13
Rivet::LorentzTransform::combine
LorentzTransform combine(const LorentzTransform &lt) const
Combine LTs, treating this as the LH matrix.
Definition: LorentzTrans.hh:105
Rivet::Matrix::inverse
Matrix< N > inverse() const
Calculate inverse.
Definition: MatrixN.hh:134
Rivet::Vector3::unit
Vector3 unit() const
Definition: Vector3.hh:88
Rivet::LorentzTransform
Object implementing Lorentz transform calculations and boosts.
Definition: LorentzTrans.hh:21
Rivet::angle
double angle(const Vector3 &a, const Vector3 &b)
Angle (in radians) between two 3-vectors.
Definition: Vector3.hh:244
Rivet::Matrix
General -dimensional mathematical matrix object.
Definition: MatrixN.hh:14
Rivet::FourVector
Specialisation of VectorN to a general (non-momentum) Lorentz 4-vector.
Definition: Vector4.hh:20
Rivet::Vector::mod2
double mod2() const
Calculate the modulus-squared of a vector. .
Definition: VectorN.hh:76
Rivet::toString
std::string toString(const AnalysisInfo &ai)
String representation.
Definition: AnalysisInfo.cc:234
Rivet::Vector3
Three-dimensional specialisation of Vector.
Definition: Vector3.hh:26
Rivet::operator<<
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition: AnalysisInfo.hh:239
Rivet::FourMomentum
Specialized version of the FourVector with momentum/energy functionality.
Definition: Vector4.hh:324