Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
76a8f9d
Template the GenVector Plane3D, Transform3D and Translation3D classes…
cjones051073 Feb 25, 2017
7e9c2b7
Use the 'using namespace std' trick with Cartesian3D and Plane3D to f…
cjones051073 Feb 25, 2017
b15d62a
Extend the 'using namespace std' trick to a few more classes
cjones051073 Feb 25, 2017
2b2fc17
Change class to typename
cjones051073 Feb 25, 2017
2e74f0d
Explicitly cast some constants to the scalar type (needed for Vc types)
cjones051073 Feb 25, 2017
c3175c6
Remove empty implementation files
cjones051073 Feb 25, 2017
9bdfb8e
Template the Boost classes
cjones051073 Feb 25, 2017
c97245c
Remove empty implementation files for Boost classes
cjones051073 Feb 25, 2017
f12d368
Clean up some indentations
cjones051073 Feb 25, 2017
bbbbbd0
Add some missing template types to the Boost classes
cjones051073 Feb 25, 2017
9a0ee77
Remove empty Boost implementation file
cjones051073 Feb 25, 2017
371d50d
Small cleanups
cjones051073 Feb 25, 2017
dcb0b30
Clean up some initialisations
cjones051073 Feb 25, 2017
29e7e30
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Feb 27, 2017
14e73b4
Add Scalar/Vector Plane3D::Normalise() methods using SFINAE
cjones051073 Feb 27, 2017
27bbb57
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Feb 27, 2017
196a00b
Roll back some changes for now, as they are causing problems in the t…
cjones051073 Feb 27, 2017
0ad5828
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Feb 27, 2017
1928c75
Add specific vectorised implementations of a few methods
cjones051073 Feb 28, 2017
5ccdaea
Extend ostream operator for Displacement and Position vectors to supp…
cjones051073 Feb 28, 2017
ef1aea9
Fix the vector abs method (not fabs) and Vector Unit() for vectorised…
cjones051073 Feb 28, 2017
6cac16a
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Feb 28, 2017
68ba28a
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 1, 2017
939b7cb
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 4, 2017
d9b810b
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 6, 2017
776ce1a
Add override qualifier
cjones051073 Mar 6, 2017
fbe74d2
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 10, 2017
12b43b0
Fix initialisation bug
cjones051073 Mar 10, 2017
8367bdf
remove space
cjones051073 Mar 10, 2017
0f404ba
Some small changes following review comments
cjones051073 Mar 10, 2017
65a701d
remove spaces
cjones051073 Mar 10, 2017
4ba8a1b
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 10, 2017
ff94a5a
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 11, 2017
b8ca822
Fix formatting using clang-format
cjones051073 Mar 11, 2017
b32cb6a
some more 'using namespace std' updates
cjones051073 Mar 11, 2017
febe783
Fix more clang format issues
cjones051073 Mar 11, 2017
a628a2a
fix (hopefully) one more clang format issue
cjones051073 Mar 11, 2017
89b2d26
clang format is picky...
cjones051073 Mar 11, 2017
6bf0368
Merge branch 'master' of github.com:root-mirror/root into GenVector-A…
cjones051073 Mar 11, 2017
bd96bd0
revert changes in VectorUtils.h
cjones051073 Mar 13, 2017
dea8d05
Add new test for GenVector with Vc types
cjones051073 Mar 13, 2017
a18221a
extend test to 96 photons
cjones051073 Mar 13, 2017
eb0b8ed
reorder headers
cjones051073 Mar 13, 2017
7da1945
remove comment that number of test photons must be multiple of 8, as …
cjones051073 Mar 13, 2017
a271eab
Add <cmath> header includes
cjones051073 Mar 13, 2017
decbe11
revert back to using std:: as it seems to cause issues with gcc build…
cjones051073 Mar 14, 2017
58c6315
Include Vc before ROOT in test application. Needed for std:: support...
cjones051073 Mar 14, 2017
17f42a3
Add some more missing std::
cjones051073 Mar 14, 2017
434396d
More math updates
cjones051073 Mar 14, 2017
b145899
Change enable_if implementation in GenVector
cjones051073 Mar 14, 2017
ad8d3a5
update comment
cjones051073 Mar 14, 2017
b018a03
Extend the GenVector Vc test with a timing test that asserts that the…
cjones051073 Mar 14, 2017
bb1e386
add fabs on timing diff and extend Vc genvector expected diff to 25%
cjones051073 Mar 14, 2017
1786383
do not return a failure from the Vc speed test, as test could be run …
cjones051073 Mar 14, 2017
380dd35
Update enable_if pattern in GenVector Vc test
cjones051073 Mar 15, 2017
ccd81f3
resolve conflicts
cjones051073 Mar 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Roll back some changes for now, as they are causing problems in the t…
…ests. Start with a limited scope and just update Plane3D, Translation3D and Transformation3D
  • Loading branch information
cjones051073 committed Feb 27, 2017
commit 196a00bb00748ddd68f27077fac994827a31350e
244 changes: 55 additions & 189 deletions math/genvector/inc/Math/GenVector/Boost.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,9 @@
#include "Math/GenVector/BoostY.h"
#include "Math/GenVector/BoostZ.h"

//#ifdef TEX
/**

A variable names bgamma appears in several places in this file. A few
words of elaboration are needed to make its meaning clear. On page 69
of Misner, Thorne and Wheeler, (Exercise 2.7) the elements of the matrix
for a general Lorentz boost are given as

\f[ \Lambda^{j'}_k = \Lambda^{k'}_j
= (\gamma - 1) n^j n^k + \delta^{jk} \f]

where the n^i are unit vectors in the direction of the three spatial
axes. Using the definitions, \f$ n^i = \beta_i/\beta \f$ , then, for example,

\f[ \Lambda_{xy} = (\gamma - 1) n_x n_y
= (\gamma - 1) \beta_x \beta_y/\beta^2 \f]

By definition, \f[ \gamma^2 = 1/(1 - \beta^2) \f]

so that \f[ \gamma^2 \beta^2 = \gamma^2 - 1 \f]

or \f[ \beta^2 = (\gamma^2 - 1)/\gamma^2 \f]

If we insert this into the expression for \f$ \Lambda_{xy} \f$, we get

\f[ \Lambda_{xy} = (\gamma - 1) \gamma^2/(\gamma^2 - 1) \beta_x \beta_y \f]

or, finally

\f[ \Lambda_{xy} = \gamma^2/(\gamma+1) \beta_x \beta_y \f]

The expression \f$ \gamma^2/(\gamma+1) \f$ is what we call <em>bgamma</em> in the code below.

\class ROOT::Math::Boost
*/
//#endif

namespace ROOT {
namespace Math {
namespace Impl {

namespace Math {

//__________________________________________________________________________________________
/**
Expand All @@ -77,14 +40,14 @@ namespace Impl {
transformations which do not mix space and time components.

@ingroup GenVector

*/

template < typename T >
class Boost {

public:

typedef T Scalar;
typedef double Scalar;

enum ELorentzRotationMatrixIndex {
kLXX = 0, kLXY = 1, kLXZ = 2, kLXT = 3
Expand All @@ -98,7 +61,6 @@ class Boost {
, kYY = 4, kYZ = 5, kYT = 6
, kZZ = 7, kZT = 8
, kTT = 9
, kNElems = 10
};

// ========== Constructors and Assignment =====================
Expand All @@ -112,7 +74,7 @@ class Boost {
Construct given a three Scalars beta_x, beta_y, and beta_z
*/
Boost(Scalar beta_x, Scalar beta_y, Scalar beta_z)
{ SetComponents(beta_x, beta_y, beta_z); }
{ SetComponents(beta_x, beta_y, beta_z); }

/**
Construct given a beta vector (which must have methods x(), y(), z())
Expand All @@ -131,26 +93,26 @@ class Boost {
/**
copy constructor
*/
Boost( Boost<T> const & b) {
Boost(Boost const & b) {
*this = b;
}

/**
Construct from an axial boost
*/

explicit Boost( BoostX<T> const & bx ) {SetComponents(bx.BetaVector());}
explicit Boost( BoostY<T> const & by ) {SetComponents(by.BetaVector());}
explicit Boost( BoostZ<T> const & bz ) {SetComponents(bz.BetaVector());}
explicit Boost( BoostX const & bx ) {SetComponents(bx.BetaVector());}
explicit Boost( BoostY const & by ) {SetComponents(by.BetaVector());}
explicit Boost( BoostZ const & bz ) {SetComponents(bz.BetaVector());}

// The compiler-generated copy ctor, copy assignment, and dtor are OK.

/**
Assignment operator
*/
Boost<T> &
operator=(Boost<T> const & rhs ) {
for (unsigned int i=0; i < kNElems; ++i) {
Boost &
operator=(Boost const & rhs ) {
for (unsigned int i=0; i < 10; ++i) {
fM[i] = rhs.fM[i];
}
return *this;
Expand All @@ -159,79 +121,32 @@ class Boost {
/**
Assign from an axial pure boost
*/
Boost<T> &
operator=( BoostX<T> const & bx ) { return operator=(Boost<T>(bx)); }
Boost<T> &
operator=( BoostY<T> const & by ) { return operator=(Boost<T>(by)); }
Boost<T> &
operator=( BoostZ<T> const & bz ) { return operator=(Boost<T>(bz)); }
Boost &
operator=( BoostX const & bx ) { return operator=(Boost(bx)); }
Boost &
operator=( BoostY const & by ) { return operator=(Boost(by)); }
Boost &
operator=( BoostZ const & bz ) { return operator=(Boost(bz)); }

/**
Re-adjust components to eliminate small deviations from a perfect
orthosyplectic matrix.
*/
void Rectify() {
// Assuming the representation of this is close to a true Lorentz Rotation,
// but may have drifted due to round-off error from many operations,
// this forms an "exact" orthosymplectic matrix for the Lorentz Rotation
// again.

if ( fM[kTT] <= Scalar(0) ) {
GenVector::Throw("Attempt to rectify a boost with non-positive gamma");
}
else
{
DisplacementVector3D< Cartesian3D<Scalar> > beta ( fM[kXT], fM[kYT], fM[kZT] );
beta /= fM[kTT];
if ( beta.mag2() >= Scalar(1) ) {
beta /= ( beta.R() * Scalar( 1.0 + 1.0e-16 ) );
}
SetComponents ( beta );
}
}
void Rectify();

// ======== Components ==============

/**
Set components from beta_x, beta_y, and beta_z
*/
void
SetComponents (Scalar bx, Scalar by, Scalar bz) {
using namespace std;
// set the boost beta as 3 components
const Scalar bp2 = bx*bx + by*by + bz*bz;
if ( bp2 >= Scalar(1) ) {
GenVector::Throw("Beta Vector supplied to set Boost represents speed >= c");
// SetIdentity();
}
else
{
const Scalar gamma = Scalar(1) / sqrt( Scalar(1) - bp2 );
const Scalar bgamma = gamma * gamma / ( Scalar(1) + gamma );
fM[kXX] = Scalar(1) + bgamma * bx * bx;
fM[kYY] = Scalar(1) + bgamma * by * by;
fM[kZZ] = Scalar(1) + bgamma * bz * bz;
fM[kXY] = bgamma * bx * by;
fM[kXZ] = bgamma * bx * bz;
fM[kYZ] = bgamma * by * bz;
fM[kXT] = gamma * bx;
fM[kYT] = gamma * by;
fM[kZT] = gamma * bz;
fM[kTT] = gamma;
}
}
SetComponents (Scalar beta_x, Scalar beta_y, Scalar beta_z);

/**
Get components into beta_x, beta_y, and beta_z
*/
void
GetComponents (Scalar& bx, Scalar& by, Scalar& bz) const {
// get beta of the boots as 3 components
const Scalar gaminv = Scalar(1)/fM[kTT];
bx = fM[kXT]*gaminv;
by = fM[kYT]*gaminv;
bz = fM[kZT]*gaminv;
}
GetComponents (Scalar& beta_x, Scalar& beta_y, Scalar& beta_z) const;

/**
Set components from a beta vector
Expand Down Expand Up @@ -277,23 +192,18 @@ class Boost {
*/
template<class IT>
void GetComponents(IT begin ) const {
T bx(0), by(0), bz(0);
GetComponents (bx,by,bz);
*begin++ = bx;
*begin++ = by;
*begin = bz;
double bx,by,bz = 0;
GetComponents (bx,by,bz);
*begin++ = bx;
*begin++ = by;
*begin = bz;
}

/**
The beta vector for this boost
*/
typedef DisplacementVector3D<Cartesian3D<T>, DefaultCoordinateSystemTag > XYZVector;
XYZVector BetaVector() const {
// get boost beta vector
const Scalar gaminv = Scalar(1)/fM[kTT];
return DisplacementVector3D< Cartesian3D<Scalar> >
( fM[kXT]*gaminv, fM[kYT]*gaminv, fM[kZT]*gaminv );
}
typedef DisplacementVector3D<Cartesian3D<double>, DefaultCoordinateSystemTag > XYZVector;
XYZVector BetaVector() const;

/**
Get elements of internal 4x4 symmetric representation, into a data
Expand All @@ -302,33 +212,16 @@ class Boost {
that large, then this will lead to undefined behavior.
*/
void
GetLorentzRotation (Scalar r[]) const {
// get Lorentz rotation corresponding to this boost as an array of 16 values
r[kLXX] = fM[kXX]; r[kLXY] = fM[kXY]; r[kLXZ] = fM[kXZ]; r[kLXT] = fM[kXT];
r[kLYX] = fM[kXY]; r[kLYY] = fM[kYY]; r[kLYZ] = fM[kYZ]; r[kLYT] = fM[kYT];
r[kLZX] = fM[kXZ]; r[kLZY] = fM[kYZ]; r[kLZZ] = fM[kZZ]; r[kLZT] = fM[kZT];
r[kLTX] = fM[kXT]; r[kLTY] = fM[kYT]; r[kLTZ] = fM[kZT]; r[kLTT] = fM[kTT];
}
GetLorentzRotation (Scalar r[]) const;

// =========== operations ==============

/**
Lorentz transformation operation on a Minkowski ('Cartesian')
LorentzVector
*/
LorentzVector< ROOT::Math::PxPyPzE4D<T> >
operator() (const LorentzVector< ROOT::Math::PxPyPzE4D<T> > & v) const {
// apply boost to a PxPyPzE LorentzVector
const Scalar x = v.Px();
const Scalar y = v.Py();
const Scalar z = v.Pz();
const Scalar t = v.E();
return LorentzVector< PxPyPzE4D<T> >
( fM[kXX]*x + fM[kXY]*y + fM[kXZ]*z + fM[kXT]*t
, fM[kXY]*x + fM[kYY]*y + fM[kYZ]*z + fM[kYT]*t
, fM[kXZ]*x + fM[kYZ]*y + fM[kZZ]*z + fM[kZT]*t
, fM[kXT]*x + fM[kYT]*y + fM[kZT]*z + fM[kTT]*t );
}
LorentzVector< ROOT::Math::PxPyPzE4D<double> >
operator() (const LorentzVector< ROOT::Math::PxPyPzE4D<double> > & v) const;

/**
Lorentz transformation operation on a LorentzVector in any
Expand All @@ -337,8 +230,8 @@ class Boost {
template <class CoordSystem>
LorentzVector<CoordSystem>
operator() (const LorentzVector<CoordSystem> & v) const {
const LorentzVector< PxPyPzE4D<T> > xyzt(v);
const LorentzVector< PxPyPzE4D<T> > r_xyzt = operator()(xyzt);
LorentzVector< PxPyPzE4D<double> > xyzt(v);
LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt);
return LorentzVector<CoordSystem> ( r_xyzt );
}

Expand All @@ -350,8 +243,8 @@ class Boost {
template <class Foreign4Vector>
Foreign4Vector
operator() (const Foreign4Vector & v) const {
const LorentzVector< PxPyPzE4D<T> > xyzt(v);
const LorentzVector< PxPyPzE4D<T> > r_xyzt = operator()(xyzt);
LorentzVector< PxPyPzE4D<double> > xyzt(v);
LorentzVector< PxPyPzE4D<double> > r_xyzt = operator()(xyzt);
return Foreign4Vector ( r_xyzt.X(), r_xyzt.Y(), r_xyzt.Z(), r_xyzt.T() );
}

Expand All @@ -368,51 +261,33 @@ class Boost {
/**
Invert a Boost in place
*/
void Invert() {
// invert in place boost (modifying the object)
fM[kXT] = -fM[kXT];
fM[kYT] = -fM[kYT];
fM[kZT] = -fM[kZT];
}

void Invert();

/**
Return inverse of a boost
*/
Boost<T> Inverse() const {
// return inverse of boost
Boost<T> tmp(*this);
tmp.Invert();
return tmp;
}
Boost Inverse() const;

/**
Equality/inequality operators
*/
bool operator == (const Boost<T> & rhs) const {
bool OK = true;
for (unsigned int i=0; i < kNElems; ++i) {
if ( fM[i] != rhs.fM[i] ) { OK = false; break; }
bool operator == (const Boost & rhs) const {
for (unsigned int i=0; i < 10; ++i) {
if( fM[i] != rhs.fM[i] ) return false;
}
return OK;
return true;
}

bool operator != (const Boost & rhs) const {
return ! operator==(rhs);
}

protected:

void SetIdentity() {
// set identity boost
fM[kXX] = Scalar(1); fM[kXY] = Scalar(0); fM[kXZ] = Scalar(0); fM[kXT] = Scalar(0);
fM[kYY] = Scalar(1); fM[kYZ] = Scalar(0); fM[kYT] = Scalar(0);
fM[kZZ] = Scalar(1); fM[kZT] = Scalar(0);
fM[kTT] = Scalar(1);
}
void SetIdentity();

private:

Scalar fM[kNElems];
Scalar fM[10];

}; // Boost

Expand All @@ -423,25 +298,16 @@ class Boost {
*/
// TODO - I/O should be put in the manipulator form

template< typename T >
std::ostream & operator<< (std::ostream & os, const Boost<T> & b ) {
// TODO - this will need changing for machine-readable issues
// and even the human readable form needs formatiing improvements
T m[16];
b.GetLorentzRotation(m);
os << "\n" << m[0] << " " << m[1] << " " << m[2] << " " << m[3];
os << "\n" << "\t" << " " << m[5] << " " << m[6] << " " << m[7];
os << "\n" << "\t" << " " << "\t" << " " << m[10] << " " << m[11];
os << "\n" << "\t" << " " << "\t" << " " << "\t" << " " << m[15] << "\n";
return os;
}

} // namespace Impl

typedef Impl::Boost<double> Boost;
typedef Impl::Boost<float> BoostF;

} // namespace Math
} // namespace ROOT
std::ostream & operator<< (std::ostream & os, const Boost & b);


} //namespace Math
} //namespace ROOT







#endif /* ROOT_Math_GenVector_Boost */
Loading