Import Geant4 9.5.0 source tree
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// AxisAngle.h - provide HepAxisAngle class
|
||||
//
|
||||
// History:
|
||||
// 23-Jan-1998 WEB Initial draft
|
||||
// 15-Jun-1998 WEB Added namespace support
|
||||
// 02-May-2000 WEB No global using
|
||||
// 27-Jul-2000 MF CLHEP version
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#ifndef HEP_AXISANGLE_H
|
||||
#define HEP_AXISANGLE_H
|
||||
|
||||
#include <iostream>
|
||||
#include "CLHEP/Vector/ThreeVector.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Declarations of classes and global methods
|
||||
class HepAxisAngle;
|
||||
std::ostream & operator<<( std::ostream & os, const HepAxisAngle & aa );
|
||||
std::istream & operator>>( std::istream & is, HepAxisAngle & aa );
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepAxisAngle {
|
||||
|
||||
public:
|
||||
typedef double Scalar;
|
||||
|
||||
protected:
|
||||
typedef HepAxisAngle AA; // just an abbreviation
|
||||
static Scalar tolerance; // to determine relative nearness
|
||||
|
||||
public:
|
||||
|
||||
// ---------- Constructors:
|
||||
inline HepAxisAngle();
|
||||
inline HepAxisAngle( const Hep3Vector axis, Scalar delta );
|
||||
|
||||
// ---------- Destructor, copy constructor, assignment:
|
||||
// use C++ defaults
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
public:
|
||||
inline Hep3Vector getAxis() const;
|
||||
inline Hep3Vector axis() const;
|
||||
inline AA & setAxis( const Hep3Vector axis );
|
||||
|
||||
inline double getDelta() const;
|
||||
inline double delta() const ;
|
||||
inline AA & setDelta( Scalar delta );
|
||||
|
||||
inline AA & set( const Hep3Vector axis, Scalar delta );
|
||||
|
||||
// ---------- Operations:
|
||||
|
||||
// comparisons:
|
||||
inline int compare ( const AA & aa ) const;
|
||||
|
||||
inline bool operator==( const AA & aa ) const;
|
||||
inline bool operator!=( const AA & aa ) const;
|
||||
inline bool operator< ( const AA & aa ) const;
|
||||
inline bool operator<=( const AA & aa ) const;
|
||||
inline bool operator> ( const AA & aa ) const;
|
||||
inline bool operator>=( const AA & aa ) const;
|
||||
|
||||
// relative comparison:
|
||||
inline static double getTolerance();
|
||||
inline static double setTolerance( Scalar tol );
|
||||
|
||||
protected:
|
||||
double distance( const HepAxisAngle & aa ) const;
|
||||
public:
|
||||
|
||||
bool isNear ( const AA & aa, Scalar epsilon = tolerance ) const;
|
||||
double howNear( const AA & aa ) const;
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
friend std::ostream & operator<<( std::ostream & os, const AA & aa );
|
||||
friend std::istream & operator>>( std::istream & is, AA & aa );
|
||||
|
||||
private:
|
||||
Hep3Vector axis_; // Note: After construction, this is always of mag 1
|
||||
double delta_;
|
||||
|
||||
}; // HepAxisAngle
|
||||
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/AxisAngle.icc"
|
||||
|
||||
#endif // HEP_AXISANGLE_H
|
||||
@@ -0,0 +1,121 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// AxisAngle.icc
|
||||
//
|
||||
// History:
|
||||
// 23-Jan-1998 WEB Initial draft
|
||||
// 12-Mar-1998 WEB Gave default constructor proper default values
|
||||
// 13-Mar-1998 WEB Corrected setDelta; simplified compare()
|
||||
// 17-Jun-1998 WEB Added namespace support
|
||||
// 26-Jul-2000 MF CLHEP version
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
inline HepAxisAngle::HepAxisAngle() :
|
||||
axis_( Hep3Vector(0,0,1) ), delta_( 0.0 )
|
||||
{} // HepAxisAngle::HepAxisAngle()
|
||||
|
||||
inline HepAxisAngle::HepAxisAngle( const Hep3Vector axis, Scalar delta ) :
|
||||
axis_( axis.unit() ), delta_( delta )
|
||||
{} // HepAxisAngle::HepAxisAngle()
|
||||
|
||||
|
||||
inline Hep3Vector HepAxisAngle::getAxis() const {
|
||||
return axis_;
|
||||
} // HepAxisAngle::getAxis()
|
||||
|
||||
inline Hep3Vector HepAxisAngle::axis() const {
|
||||
return axis_;
|
||||
} // HepAxisAngle::axis()
|
||||
|
||||
|
||||
inline HepAxisAngle & HepAxisAngle::setAxis( const Hep3Vector axis ) {
|
||||
axis_ = axis.unit();
|
||||
return *this;
|
||||
} // HepAxisAngle::setAxis()
|
||||
|
||||
|
||||
inline double HepAxisAngle::getDelta() const {
|
||||
return delta_;
|
||||
} // HepAxisAngle::getDelta()
|
||||
|
||||
inline double HepAxisAngle::delta() const {
|
||||
return delta_;
|
||||
} // HepAxisAngle::delta()
|
||||
|
||||
|
||||
inline HepAxisAngle & HepAxisAngle::setDelta( Scalar delta ) {
|
||||
delta_ = delta;
|
||||
return *this;
|
||||
} // HepAxisAngle::setDelta()
|
||||
|
||||
|
||||
inline HepAxisAngle & HepAxisAngle::set( const Hep3Vector axis, Scalar delta ) {
|
||||
axis_ = axis.unit();
|
||||
delta_ = delta;
|
||||
return *this;
|
||||
} // HepAxisAngle::set()
|
||||
|
||||
|
||||
inline int HepAxisAngle::compare( const AA & aa ) const {
|
||||
|
||||
return delta_ < aa.delta_ ? -1
|
||||
: delta_ > aa.delta_ ? +1
|
||||
: axis_ < aa.axis_ ? -1
|
||||
: axis_ > aa.axis_ ? +1
|
||||
: 0;
|
||||
|
||||
} // HepAxisAngle::compare()
|
||||
|
||||
|
||||
inline bool HepAxisAngle::operator==( const AA & aa ) const {
|
||||
return ( compare( aa ) == 0 );
|
||||
} // HepAxisAngle::operator==()
|
||||
|
||||
|
||||
inline bool HepAxisAngle::operator!=( const AA & aa ) const {
|
||||
return ( compare( aa ) != 0 );
|
||||
} // HepAxisAngle::operator!=()
|
||||
|
||||
|
||||
inline bool HepAxisAngle::operator<( const AA & aa ) const {
|
||||
return ( compare( aa ) < 0 );
|
||||
} // HepAxisAngle::operator<()
|
||||
|
||||
|
||||
inline bool HepAxisAngle::operator<=( const AA & aa ) const {
|
||||
return ( compare( aa ) <= 0 );
|
||||
} // HepAxisAngle::operator<=()
|
||||
|
||||
|
||||
inline bool HepAxisAngle::operator>( const AA & aa ) const {
|
||||
return ( compare( aa ) > 0 );
|
||||
} // HepAxisAngle::operator>()
|
||||
|
||||
|
||||
inline bool HepAxisAngle::operator>=( const AA & aa ) const {
|
||||
return ( compare( aa ) >= 0 );
|
||||
} // HepAxisAngle::operator>=()
|
||||
|
||||
|
||||
inline double HepAxisAngle::getTolerance() {
|
||||
return tolerance;
|
||||
} // HepAxisAngle::getTolerance()
|
||||
|
||||
|
||||
inline double HepAxisAngle::setTolerance( Scalar tol ) {
|
||||
Scalar oldTolerance( tolerance );
|
||||
tolerance = tol;
|
||||
return oldTolerance;
|
||||
} // HepAxisAngle::setTolerance()
|
||||
|
||||
} // namespace CLHEP
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definition of the HepBoost class for performing specialized
|
||||
// Lorentz transformations which are pure boosts on objects of the
|
||||
// HepLorentzVector class.
|
||||
//
|
||||
// HepBoost is a concrete implementation of Hep4RotationInterface.
|
||||
//
|
||||
// .SS See Also
|
||||
// RotationInterfaces.h
|
||||
// LorentzVector.h LorentzRotation.h
|
||||
// BoostX.h BoostY.h BoostZ.h
|
||||
//
|
||||
// .SS Author
|
||||
// Mark Fischler
|
||||
|
||||
#ifndef HEP_BOOST_H
|
||||
#define HEP_BOOST_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "CLHEP/Vector/RotationInterfaces.h"
|
||||
#include "CLHEP/Vector/BoostX.h"
|
||||
#include "CLHEP/Vector/BoostY.h"
|
||||
#include "CLHEP/Vector/BoostZ.h"
|
||||
#include "CLHEP/Vector/LorentzVector.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Declarations of classes and global methods
|
||||
class HepBoost;
|
||||
inline HepBoost inverseOf ( const HepBoost & lt );
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepBoost {
|
||||
|
||||
public:
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepBoost();
|
||||
// Default constructor. Gives a boost of 0.
|
||||
|
||||
inline HepBoost(const HepBoost & m);
|
||||
// Copy constructor.
|
||||
|
||||
inline HepBoost & operator = (const HepBoost & m);
|
||||
// Assignment.
|
||||
|
||||
HepBoost & set (double betaX, double betaY, double betaZ);
|
||||
inline HepBoost (double betaX, double betaY, double betaZ);
|
||||
// Constructor from three components of beta vector
|
||||
|
||||
HepBoost & set (const HepRep4x4Symmetric & m);
|
||||
inline HepBoost (const HepRep4x4Symmetric & m);
|
||||
// Constructor from symmetric HepRep4x4
|
||||
|
||||
HepBoost & set (Hep3Vector direction, double beta);
|
||||
inline HepBoost (Hep3Vector direction, double beta);
|
||||
// Constructor from a three vector direction and the magnitude of beta
|
||||
|
||||
HepBoost & set (const Hep3Vector & boost);
|
||||
inline HepBoost (const Hep3Vector & boost);
|
||||
// Constructor from a 3-vector of less than unit length
|
||||
|
||||
inline HepBoost & set (const HepBoostX & boost);
|
||||
inline HepBoost & set (const HepBoostY & boost);
|
||||
inline HepBoost & set (const HepBoostZ & boost);
|
||||
inline HepBoost (const HepBoostX & boost);
|
||||
inline HepBoost (const HepBoostY & boost);
|
||||
inline HepBoost (const HepBoostZ & boost);
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline double beta() const;
|
||||
inline double gamma() const;
|
||||
inline Hep3Vector boostVector() const;
|
||||
inline Hep3Vector getDirection() const;
|
||||
inline Hep3Vector direction() const;
|
||||
|
||||
inline double xx() const;
|
||||
inline double xy() const;
|
||||
inline double xz() const;
|
||||
inline double xt() const;
|
||||
inline double yx() const;
|
||||
inline double yy() const;
|
||||
inline double yz() const;
|
||||
inline double yt() const;
|
||||
inline double zx() const;
|
||||
inline double zy() const;
|
||||
inline double zz() const;
|
||||
inline double zt() const;
|
||||
inline double tx() const;
|
||||
inline double ty() const;
|
||||
inline double tz() const;
|
||||
inline double tt() const;
|
||||
// Elements of the matrix.
|
||||
|
||||
inline HepLorentzVector col1() const;
|
||||
inline HepLorentzVector col2() const;
|
||||
inline HepLorentzVector col3() const;
|
||||
inline HepLorentzVector col4() const;
|
||||
// orthosymplectic column vectors
|
||||
|
||||
inline HepLorentzVector row1() const;
|
||||
inline HepLorentzVector row2() const;
|
||||
inline HepLorentzVector row3() const;
|
||||
inline HepLorentzVector row4() const;
|
||||
// orthosymplectic row vectors
|
||||
|
||||
inline HepRep4x4 rep4x4() const;
|
||||
// 4x4 representation.
|
||||
|
||||
inline HepRep4x4Symmetric rep4x4Symmetric() const;
|
||||
// Symmetric 4x4 representation.
|
||||
|
||||
// ---------- Decomposition:
|
||||
|
||||
void decompose (HepRotation & rotation, HepBoost & boost) const;
|
||||
void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
|
||||
// Find R and B such that L = R*B -- trivial, since R is identity
|
||||
|
||||
void decompose (HepBoost & boost, HepRotation & rotation) const;
|
||||
void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
|
||||
// Find R and B such that L = B*R -- trivial, since R is identity
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline int compare( const HepBoost & b ) const;
|
||||
// Dictionary-order comparison, in order tt,zt,zz,yt,yz,yy,xt,xz,xy,xx
|
||||
// Used in operator<, >, <=, >=
|
||||
|
||||
inline bool operator == (const HepBoost & b) const;
|
||||
inline bool operator != (const HepBoost & b) const;
|
||||
inline bool operator <= (const HepBoost & b) const;
|
||||
inline bool operator >= (const HepBoost & b) const;
|
||||
inline bool operator < (const HepBoost & b) const;
|
||||
inline bool operator > (const HepBoost & b) const;
|
||||
// Comparisons.
|
||||
|
||||
inline bool isIdentity() const;
|
||||
// Returns true if a null boost.
|
||||
|
||||
inline double distance2( const HepBoost & b ) const;
|
||||
inline double distance2( const HepBoostX & bx ) const;
|
||||
inline double distance2( const HepBoostY & by ) const;
|
||||
inline double distance2( const HepBoostZ & bz ) const;
|
||||
// Defined as the distance2 between the vectors (gamma*betaVector)
|
||||
|
||||
double distance2( const HepRotation & r ) const;
|
||||
double distance2( const HepLorentzRotation & lt ) const;
|
||||
// Distance between this and other sorts of transformations
|
||||
|
||||
inline double howNear( const HepBoost & b ) const;
|
||||
inline bool isNear( const HepBoost & b,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
double howNear( const HepRotation & r ) const;
|
||||
double howNear( const HepLorentzRotation & lt ) const;
|
||||
|
||||
bool isNear( const HepRotation & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepLorentzRotation & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
double norm2() const;
|
||||
// (beta*gamma)^2
|
||||
|
||||
void rectify();
|
||||
// set as an exact boost, based on the timelike part of the boost matrix.
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline HepLorentzVector operator()( const HepLorentzVector & p ) const;
|
||||
// Transform a Lorentz Vector.
|
||||
|
||||
inline HepLorentzVector operator* ( const HepLorentzVector & p ) const;
|
||||
// Multiplication with a Lorentz Vector.
|
||||
|
||||
// ---------- Operations in the group of 4-Rotations
|
||||
|
||||
HepLorentzRotation operator * (const HepBoost & b) const;
|
||||
HepLorentzRotation operator * (const HepRotation & r) const;
|
||||
HepLorentzRotation operator * (const HepLorentzRotation & lt) const;
|
||||
// Product of two Lorentz Rotations (this) * lt - matrix multiplication
|
||||
// Notice that the product of two pure boosts is no longer a pure boost
|
||||
|
||||
inline HepBoost inverse() const;
|
||||
// Return the inverse.
|
||||
|
||||
inline friend HepBoost inverseOf ( const HepBoost & lt );
|
||||
// global methods to invert.
|
||||
|
||||
inline HepBoost & invert();
|
||||
// Inverts the Boost matrix.
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
// Output form is (bx, by, bz)
|
||||
|
||||
// ---------- Tolerance
|
||||
|
||||
static inline double getTolerance();
|
||||
static inline double setTolerance(double tol);
|
||||
|
||||
protected:
|
||||
|
||||
inline HepLorentzVector vectorMultiplication
|
||||
( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a Lorentz Vector.
|
||||
|
||||
HepLorentzRotation matrixMultiplication (const HepRep4x4 & m) const;
|
||||
HepLorentzRotation matrixMultiplication (const HepRep4x4Symmetric & m) const;
|
||||
|
||||
inline HepBoost
|
||||
(double xx, double xy, double xz, double xt,
|
||||
double yy, double yz, double yt,
|
||||
double zz, double zt,
|
||||
double tt);
|
||||
// Protected constructor.
|
||||
// DOES NOT CHECK FOR VALIDITY AS A LORENTZ BOOST.
|
||||
|
||||
inline void setBoost(double bx, double by, double bz);
|
||||
|
||||
HepRep4x4Symmetric rep_;
|
||||
|
||||
}; // HepBoost
|
||||
|
||||
inline
|
||||
std::ostream & operator <<
|
||||
( std::ostream & os, const HepBoost& b ) {return b.print(os);}
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/Boost.icc"
|
||||
|
||||
#endif /* HEP_BOOST_H */
|
||||
@@ -0,0 +1,291 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// HepBoost class
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepBoost::HepBoost() : rep_() {}
|
||||
|
||||
inline HepBoost::HepBoost(const HepBoost & m) : rep_(m.rep_) {}
|
||||
|
||||
inline HepBoost & HepBoost::operator = (const HepBoost & m) {
|
||||
rep_ = m.rep_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepBoost::HepBoost(double betaX, double betaY, double betaZ)
|
||||
{
|
||||
set(betaX, betaY, betaZ);
|
||||
}
|
||||
|
||||
inline HepBoost::HepBoost(const HepRep4x4Symmetric & m) : rep_(m) {}
|
||||
|
||||
inline HepBoost::HepBoost(Hep3Vector direction, double beta)
|
||||
{
|
||||
double length = direction.mag();
|
||||
if (length==0) {
|
||||
std::cerr << "HepBoost::HepBoost() - "
|
||||
<< "HepBoost constructed using a zero vector as direction"
|
||||
<< std::endl;
|
||||
set(0,0,0);
|
||||
}
|
||||
set(beta*direction.x()/length,
|
||||
beta*direction.y()/length,
|
||||
beta*direction.z()/length);
|
||||
}
|
||||
|
||||
inline HepBoost::HepBoost(const Hep3Vector & boost)
|
||||
{
|
||||
set(boost.x(), boost.y(), boost.z());
|
||||
}
|
||||
|
||||
inline HepBoost::HepBoost(const HepBoostX & boost) {set(boost.boostVector());}
|
||||
inline HepBoost::HepBoost(const HepBoostY & boost) {set(boost.boostVector());}
|
||||
inline HepBoost::HepBoost(const HepBoostZ & boost) {set(boost.boostVector());}
|
||||
inline HepBoost & HepBoost::set(const HepBoostX & boost)
|
||||
{return set(boost.boostVector());}
|
||||
inline HepBoost & HepBoost::set(const HepBoostY & boost)
|
||||
{return set(boost.boostVector());}
|
||||
inline HepBoost & HepBoost::set(const HepBoostZ & boost)
|
||||
{return set(boost.boostVector());}
|
||||
|
||||
// - Protected method:
|
||||
inline HepBoost::HepBoost (
|
||||
double xx, double xy, double xz, double xt,
|
||||
double yy, double yz, double yt,
|
||||
double zz, double zt,
|
||||
double tt) :
|
||||
rep_ ( xx, xy, xz, xt, yy, yz, yt, zz, zt, tt ) {}
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline double HepBoost::beta() const {
|
||||
return std::sqrt( 1.0 - 1.0 / (rep_.tt_ * rep_.tt_) );
|
||||
}
|
||||
|
||||
inline double HepBoost::gamma() const {
|
||||
return rep_.tt_;
|
||||
}
|
||||
|
||||
inline Hep3Vector HepBoost::boostVector() const {
|
||||
return (1.0/rep_.tt_) * Hep3Vector( rep_.xt_, rep_.yt_, rep_.zt_ );
|
||||
}
|
||||
|
||||
inline Hep3Vector HepBoost::getDirection() const {
|
||||
double norm = 1.0/beta();
|
||||
return (norm*boostVector());
|
||||
}
|
||||
|
||||
inline Hep3Vector HepBoost::direction() const {
|
||||
return getDirection();
|
||||
}
|
||||
|
||||
inline double HepBoost::xx() const { return rep_.xx_; }
|
||||
inline double HepBoost::xy() const { return rep_.xy_; }
|
||||
inline double HepBoost::xz() const { return rep_.xz_; }
|
||||
inline double HepBoost::xt() const { return rep_.xt_; }
|
||||
inline double HepBoost::yx() const { return rep_.xy_; }
|
||||
inline double HepBoost::yy() const { return rep_.yy_; }
|
||||
inline double HepBoost::yz() const { return rep_.yz_; }
|
||||
inline double HepBoost::yt() const { return rep_.yt_; }
|
||||
inline double HepBoost::zx() const { return rep_.xz_; }
|
||||
inline double HepBoost::zy() const { return rep_.yz_; }
|
||||
inline double HepBoost::zz() const { return rep_.zz_; }
|
||||
inline double HepBoost::zt() const { return rep_.zt_; }
|
||||
inline double HepBoost::tx() const { return rep_.xt_; }
|
||||
inline double HepBoost::ty() const { return rep_.yt_; }
|
||||
inline double HepBoost::tz() const { return rep_.zt_; }
|
||||
inline double HepBoost::tt() const { return rep_.tt_; }
|
||||
|
||||
inline HepLorentzVector HepBoost::col1() const {
|
||||
return HepLorentzVector ( xx(), yx(), zx(), tx() );
|
||||
}
|
||||
inline HepLorentzVector HepBoost::col2() const {
|
||||
return HepLorentzVector ( xy(), yy(), zy(), ty() );
|
||||
}
|
||||
inline HepLorentzVector HepBoost::col3() const {
|
||||
return HepLorentzVector ( xz(), yz(), zz(), tz() );
|
||||
}
|
||||
inline HepLorentzVector HepBoost::col4() const {
|
||||
return HepLorentzVector ( xt(), yt(), zt(), tt() );
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepBoost::row1() const {
|
||||
return HepLorentzVector ( col1() );
|
||||
}
|
||||
inline HepLorentzVector HepBoost::row2() const {
|
||||
return HepLorentzVector ( col2() );
|
||||
}
|
||||
inline HepLorentzVector HepBoost::row3() const {
|
||||
return HepLorentzVector ( col3() );
|
||||
}
|
||||
inline HepLorentzVector HepBoost::row4() const {
|
||||
return HepLorentzVector ( col4() );
|
||||
}
|
||||
|
||||
inline HepRep4x4 HepBoost::rep4x4() const {
|
||||
return HepRep4x4( rep_ );
|
||||
}
|
||||
|
||||
inline HepRep4x4Symmetric HepBoost::rep4x4Symmetric() const {
|
||||
return rep_;
|
||||
}
|
||||
|
||||
|
||||
inline void HepBoost::setBoost(double bx, double by, double bz) {
|
||||
set(bx, by, bz);
|
||||
}
|
||||
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
int HepBoost::compare ( const HepBoost & b ) const {
|
||||
const HepRep4x4Symmetric & s = b.rep4x4Symmetric();
|
||||
if (rep_.tt_ < s.tt_) return -1; else if (rep_.tt_ > s.tt_) return 1;
|
||||
else if (rep_.zt_ < s.zt_) return -1; else if (rep_.zt_ > s.zt_) return 1;
|
||||
else if (rep_.zz_ < s.zz_) return -1; else if (rep_.zz_ > s.zz_) return 1;
|
||||
else if (rep_.yt_ < s.yt_) return -1; else if (rep_.yt_ > s.yt_) return 1;
|
||||
else if (rep_.yz_ < s.yz_) return -1; else if (rep_.yz_ > s.yz_) return 1;
|
||||
else if (rep_.yy_ < s.yy_) return -1; else if (rep_.yy_ > s.yy_) return 1;
|
||||
else if (rep_.xt_ < s.xt_) return -1; else if (rep_.xt_ > s.xt_) return 1;
|
||||
else if (rep_.xz_ < s.xz_) return -1; else if (rep_.xz_ > s.xz_) return 1;
|
||||
else if (rep_.xy_ < s.xy_) return -1; else if (rep_.xy_ > s.xy_) return 1;
|
||||
else if (rep_.xx_ < s.xx_) return -1; else if (rep_.xx_ > s.xx_) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
inline bool
|
||||
HepBoost::operator == (const HepBoost & b) const {
|
||||
const HepRep4x4Symmetric & s = b.rep4x4Symmetric();
|
||||
return (
|
||||
rep_.xx_==s.xx_ && rep_.xy_==s.xy_ && rep_.xz_==s.xz_ && rep_.xt_==s.xt_
|
||||
&& rep_.yy_==s.yy_ && rep_.yz_==s.yz_ && rep_.yt_==s.yt_
|
||||
&& rep_.zz_==s.zz_ && rep_.zt_==s.zt_
|
||||
&& rep_.tt_==s.tt_
|
||||
);
|
||||
}
|
||||
|
||||
inline bool
|
||||
HepBoost::operator != (const HepBoost & r) const {
|
||||
return ( !(operator==(r)) );
|
||||
}
|
||||
inline bool HepBoost::operator <= ( const HepBoost & b ) const
|
||||
{ return compare(b)<= 0; }
|
||||
inline bool HepBoost::operator >= ( const HepBoost & b ) const
|
||||
{ return compare(b)>= 0; }
|
||||
inline bool HepBoost::operator < ( const HepBoost & b ) const
|
||||
{ return compare(b)< 0; }
|
||||
inline bool HepBoost::operator > ( const HepBoost & b ) const
|
||||
{ return compare(b)> 0; }
|
||||
|
||||
inline bool HepBoost::isIdentity() const {
|
||||
return (xx() == 1.0 && xy() == 0.0 && xz() == 0.0 && xt() == 0.0
|
||||
&& yy() == 1.0 && yz() == 0.0 && yt() == 0.0
|
||||
&& zz() == 1.0 && zt() == 0.0
|
||||
&& tt() == 1.0);
|
||||
}
|
||||
|
||||
inline double HepBoost::distance2( const HepBoost & b ) const {
|
||||
double bgx = rep_.xt_ - b.rep_.xt_;
|
||||
double bgy = rep_.yt_ - b.rep_.yt_;
|
||||
double bgz = rep_.zt_ - b.rep_.zt_;
|
||||
return bgx*bgx+bgy*bgy+bgz*bgz;
|
||||
}
|
||||
|
||||
inline double HepBoost::distance2( const HepBoostX & bx ) const {
|
||||
double bgx = rep_.xt_ - bx.beta()*bx.gamma();
|
||||
double bgy = rep_.yt_;
|
||||
double bgz = rep_.zt_;
|
||||
return bgx*bgx+bgy*bgy+bgz*bgz;
|
||||
}
|
||||
|
||||
inline double HepBoost::distance2( const HepBoostY & by ) const {
|
||||
double bgy = rep_.xt_;
|
||||
double bgx = rep_.yt_ - by.beta()*by.gamma();
|
||||
double bgz = rep_.zt_;
|
||||
return bgx*bgx+bgy*bgy+bgz*bgz;
|
||||
}
|
||||
|
||||
inline double HepBoost::distance2( const HepBoostZ & bz ) const {
|
||||
double bgz = rep_.xt_;
|
||||
double bgy = rep_.yt_;
|
||||
double bgx = rep_.zt_ - bz.beta()*bz.gamma();
|
||||
return bgx*bgx+bgy*bgy+bgz*bgz;
|
||||
}
|
||||
|
||||
inline double HepBoost::howNear ( const HepBoost & b ) const {
|
||||
return std::sqrt(distance2(b));
|
||||
}
|
||||
|
||||
inline bool HepBoost::isNear(const HepBoost & b, double epsilon) const{
|
||||
return (distance2(b) <= epsilon*epsilon);
|
||||
}
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
// - Protected method:
|
||||
inline HepLorentzVector
|
||||
HepBoost::vectorMultiplication(const HepLorentzVector & p) const {
|
||||
register double x = p.x();
|
||||
register double y = p.y();
|
||||
register double z = p.z();
|
||||
register double t = p.t();
|
||||
return HepLorentzVector( rep_.xx_*x + rep_.xy_*y + rep_.xz_*z + rep_.xt_*t,
|
||||
rep_.xy_*x + rep_.yy_*y + rep_.yz_*z + rep_.yt_*t,
|
||||
rep_.xz_*x + rep_.yz_*y + rep_.zz_*z + rep_.zt_*t,
|
||||
rep_.xt_*x + rep_.yt_*y + rep_.zt_*z + rep_.tt_*t);
|
||||
}
|
||||
|
||||
inline HepLorentzVector
|
||||
HepBoost::operator () (const HepLorentzVector & p) const {
|
||||
return vectorMultiplication(p);
|
||||
}
|
||||
|
||||
inline HepLorentzVector
|
||||
HepBoost::operator * (const HepLorentzVector & p) const {
|
||||
return vectorMultiplication(p);
|
||||
}
|
||||
|
||||
|
||||
// ---------- Operations in the group of 4-Rotations
|
||||
|
||||
inline HepBoost HepBoost::inverse() const {
|
||||
return HepBoost( xx(), yx(), zx(), -tx(),
|
||||
yy(), zy(), -ty(),
|
||||
zz(), -tz(),
|
||||
tt());
|
||||
}
|
||||
|
||||
inline HepBoost inverseOf ( const HepBoost & lt ) {
|
||||
return HepBoost( lt.xx(), lt.yx(), lt.zx(), -lt.tx(),
|
||||
lt.yy(), lt.zy(), -lt.ty(),
|
||||
lt.zz(), -lt.tz(),
|
||||
lt.tt());
|
||||
}
|
||||
|
||||
inline HepBoost & HepBoost::invert() {
|
||||
rep_.xt_ = -rep_.xt_;
|
||||
rep_.yt_ = -rep_.yt_;
|
||||
rep_.zt_ = -rep_.zt_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---------- Tolerance:
|
||||
|
||||
inline double HepBoost::getTolerance() {
|
||||
return Hep4RotationInterface::tolerance;
|
||||
}
|
||||
inline double HepBoost::setTolerance(double tol) {
|
||||
return Hep4RotationInterface::setTolerance(tol);
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,221 @@
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definition of the HepBoostX class for performing specialized
|
||||
// Lorentz transformations which are pure boosts in the X direction, on
|
||||
// objects of the HepLorentzVector class.
|
||||
//
|
||||
// HepLorentzRotation is a concrete implementation of Hep4RotationInterface.
|
||||
//
|
||||
// .SS See Also
|
||||
// RotationInterfaces.h
|
||||
// LorentzVector.h LorentzRotation.h
|
||||
// Boost.h
|
||||
//
|
||||
// .SS Author
|
||||
// Mark Fischler
|
||||
|
||||
#ifndef HEP_BOOSTX_H
|
||||
#define HEP_BOOSTX_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "CLHEP/Vector/RotationInterfaces.h"
|
||||
#include "CLHEP/Vector/LorentzVector.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Declarations of classes and global methods
|
||||
class HepBoostX;
|
||||
inline HepBoostX inverseOf ( const HepBoostX & b );
|
||||
class HepBoost;
|
||||
class HepRotation;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepBoostX {
|
||||
|
||||
public:
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepBoostX();
|
||||
// Default constructor. Gives a boost of 0.
|
||||
|
||||
inline HepBoostX(const HepBoostX & b);
|
||||
// Copy constructor.
|
||||
|
||||
inline HepBoostX & operator = (const HepBoostX & m);
|
||||
// Assignment.
|
||||
|
||||
HepBoostX & set (double beta);
|
||||
inline HepBoostX (double beta);
|
||||
// Constructor from beta
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline double beta() const;
|
||||
inline double gamma() const;
|
||||
inline Hep3Vector boostVector() const;
|
||||
inline Hep3Vector getDirection() const;
|
||||
|
||||
inline double xx() const;
|
||||
inline double xy() const;
|
||||
inline double xz() const;
|
||||
inline double xt() const;
|
||||
inline double yx() const;
|
||||
inline double yy() const;
|
||||
inline double yz() const;
|
||||
inline double yt() const;
|
||||
inline double zx() const;
|
||||
inline double zy() const;
|
||||
inline double zz() const;
|
||||
inline double zt() const;
|
||||
inline double tx() const;
|
||||
inline double ty() const;
|
||||
inline double tz() const;
|
||||
inline double tt() const;
|
||||
// Elements of the matrix.
|
||||
|
||||
inline HepLorentzVector col1() const;
|
||||
inline HepLorentzVector col2() const;
|
||||
inline HepLorentzVector col3() const;
|
||||
inline HepLorentzVector col4() const;
|
||||
// orthosymplectic column vectors
|
||||
|
||||
inline HepLorentzVector row1() const;
|
||||
inline HepLorentzVector row2() const;
|
||||
inline HepLorentzVector row3() const;
|
||||
inline HepLorentzVector row4() const;
|
||||
// orthosymplectic row vectors
|
||||
|
||||
HepRep4x4 rep4x4() const;
|
||||
// 4x4 representation:
|
||||
|
||||
HepRep4x4Symmetric rep4x4Symmetric() const;
|
||||
// Symmetric 4x4 representation.
|
||||
|
||||
// ---------- Decomposition:
|
||||
|
||||
void decompose (HepRotation & rotation, HepBoost & boost) const;
|
||||
void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
|
||||
// Find R and B such that L = R*B -- trivial, since R is identity
|
||||
|
||||
void decompose ( HepBoost & boost, HepRotation & rotation) const;
|
||||
void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
|
||||
// Find R and B such that L = B*R -- trivial, since R is identity
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline int compare( const HepBoostX & b ) const;
|
||||
// Dictionary-order comparison, in order of beta.
|
||||
// Used in operator<, >, <=, >=
|
||||
|
||||
inline bool operator == (const HepBoostX & b) const;
|
||||
inline bool operator != (const HepBoostX & b) const;
|
||||
inline bool operator <= (const HepBoostX & b) const;
|
||||
inline bool operator >= (const HepBoostX & b) const;
|
||||
inline bool operator < (const HepBoostX & b) const;
|
||||
inline bool operator > (const HepBoostX & b) const;
|
||||
// Comparisons.
|
||||
|
||||
inline bool isIdentity() const;
|
||||
// Returns true if a null boost.
|
||||
|
||||
inline double distance2( const HepBoostX & b ) const;
|
||||
double distance2( const HepBoost & b ) const;
|
||||
// Defined as the distance2 between the vectors (gamma*betaVector)
|
||||
|
||||
double distance2( const HepRotation & r ) const;
|
||||
double distance2( const HepLorentzRotation & lt ) const;
|
||||
// Decompose lt = B*R; add norm2 to distance2 to between boosts.
|
||||
|
||||
inline double howNear( const HepBoostX & b ) const;
|
||||
inline double howNear( const HepBoost & b ) const;
|
||||
inline double howNear( const HepRotation & r ) const;
|
||||
inline double howNear( const HepLorentzRotation & lt ) const;
|
||||
|
||||
inline bool isNear( const HepBoostX & b,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
inline bool isNear( const HepBoost & b,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepRotation & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepLorentzRotation & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
inline double norm2() const;
|
||||
// distance2 (IDENTITY), which is beta^2 * gamma^2
|
||||
|
||||
void rectify();
|
||||
// sets according to the stored beta
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
|
||||
// Transform a Lorentz Vector.
|
||||
|
||||
inline HepLorentzVector operator* ( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a Lorentz Vector.
|
||||
|
||||
// ---------- Operations in the group of 4-Rotations
|
||||
|
||||
HepBoostX operator * (const HepBoostX & b) const;
|
||||
HepLorentzRotation operator * (const HepBoost & b) const;
|
||||
HepLorentzRotation operator * (const HepRotation & r) const;
|
||||
HepLorentzRotation operator * (const HepLorentzRotation & lt) const;
|
||||
// Product of two Lorentz Rotations (this) * lt - matrix multiplication
|
||||
// Notice that the product of two pure boosts in different directions
|
||||
// is no longer a pure boost.
|
||||
|
||||
inline HepBoostX inverse() const;
|
||||
// Return the inverse.
|
||||
|
||||
inline friend HepBoostX inverseOf ( const HepBoostX & b );
|
||||
// global methods to invert.
|
||||
|
||||
inline HepBoostX & invert();
|
||||
// Inverts the Boost matrix.
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
// Output form is BOOSTX (beta=..., gamma=...);
|
||||
|
||||
// ---------- Tolerance
|
||||
|
||||
static inline double getTolerance();
|
||||
static inline double setTolerance(double tol);
|
||||
|
||||
protected:
|
||||
|
||||
inline HepLorentzVector vectorMultiplication
|
||||
( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a Lorentz Vector.
|
||||
|
||||
HepLorentzRotation matrixMultiplication (const HepRep4x4 & m) const;
|
||||
HepLorentzRotation matrixMultiplication (const HepRep4x4Symmetric & m) const;
|
||||
|
||||
inline HepBoostX (double beta, double gamma);
|
||||
|
||||
double beta_;
|
||||
double gamma_;
|
||||
|
||||
}; // HepBoostX
|
||||
|
||||
inline
|
||||
std::ostream & operator <<
|
||||
( std::ostream & os, const HepBoostX& b ) {return b.print(os);}
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/BoostX.icc"
|
||||
|
||||
#endif /* HEP_BOOSTX_H */
|
||||
@@ -0,0 +1,200 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// HepBoostX class
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepBoostX::HepBoostX() : beta_(0.0), gamma_(1.0) {}
|
||||
|
||||
inline HepBoostX::HepBoostX(const HepBoostX & b) :
|
||||
beta_ (b.beta_),
|
||||
gamma_(b.gamma_) {}
|
||||
|
||||
inline HepBoostX & HepBoostX::operator = (const HepBoostX & b) {
|
||||
beta_ = b.beta_;
|
||||
gamma_ = b.gamma_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepBoostX::HepBoostX(double beta) { set(beta); }
|
||||
|
||||
// - Protected method:
|
||||
inline HepBoostX::HepBoostX( double beta, double gamma ) :
|
||||
beta_(beta), gamma_(gamma) {}
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline double HepBoostX::beta() const {
|
||||
return beta_;
|
||||
}
|
||||
|
||||
inline double HepBoostX::gamma() const {
|
||||
return gamma_;
|
||||
}
|
||||
|
||||
inline Hep3Vector HepBoostX::boostVector() const {
|
||||
return Hep3Vector( beta_, 0, 0 );
|
||||
}
|
||||
|
||||
inline Hep3Vector HepBoostX::getDirection() const {
|
||||
return Hep3Vector(1.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
inline double HepBoostX::xx() const { return gamma();}
|
||||
inline double HepBoostX::xy() const { return 0.0;}
|
||||
inline double HepBoostX::xz() const { return 0.0;}
|
||||
inline double HepBoostX::xt() const { return beta()*gamma();}
|
||||
inline double HepBoostX::yx() const { return 0.0;}
|
||||
inline double HepBoostX::yy() const { return 1.0;}
|
||||
inline double HepBoostX::yz() const { return 0.0;}
|
||||
inline double HepBoostX::yt() const { return 0.0;}
|
||||
inline double HepBoostX::zx() const { return 0.0;}
|
||||
inline double HepBoostX::zy() const { return 0.0;}
|
||||
inline double HepBoostX::zz() const { return 1.0;}
|
||||
inline double HepBoostX::zt() const { return 0.0;}
|
||||
inline double HepBoostX::tx() const { return beta()*gamma();}
|
||||
inline double HepBoostX::ty() const { return 0.0;}
|
||||
inline double HepBoostX::tz() const { return 0.0;}
|
||||
inline double HepBoostX::tt() const { return gamma();}
|
||||
|
||||
inline HepLorentzVector HepBoostX::col1() const {
|
||||
return HepLorentzVector ( gamma(), 0, 0, beta()*gamma() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostX::col2() const {
|
||||
return HepLorentzVector ( 0, 1, 0, 0 );
|
||||
}
|
||||
inline HepLorentzVector HepBoostX::col3() const {
|
||||
return HepLorentzVector ( 0, 0, 1, 0 );
|
||||
}
|
||||
inline HepLorentzVector HepBoostX::col4() const {
|
||||
return HepLorentzVector ( beta()*gamma(), 0, 0, gamma() );
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepBoostX::row1() const {
|
||||
return HepLorentzVector ( col1() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostX::row2() const {
|
||||
return HepLorentzVector ( col2() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostX::row3() const {
|
||||
return HepLorentzVector ( col3() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostX::row4() const {
|
||||
return HepLorentzVector ( col4() );
|
||||
}
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline int HepBoostX::compare( const HepBoostX & b ) const {
|
||||
if (beta() < b.beta()) {
|
||||
return -1;
|
||||
} else if (beta() > b.beta()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool HepBoostX::operator == ( const HepBoostX & b ) const {
|
||||
return beta_ == b.beta_;
|
||||
}
|
||||
inline bool HepBoostX::operator != ( const HepBoostX & b ) const {
|
||||
return beta_ != b.beta_;
|
||||
}
|
||||
inline bool HepBoostX::operator <= ( const HepBoostX & b ) const {
|
||||
return beta_ <= b.beta_;
|
||||
}
|
||||
inline bool HepBoostX::operator >= ( const HepBoostX & b ) const {
|
||||
return beta_ >= b.beta_;
|
||||
}
|
||||
inline bool HepBoostX::operator < ( const HepBoostX & b ) const {
|
||||
return beta_ < b.beta_;
|
||||
}
|
||||
inline bool HepBoostX::operator > ( const HepBoostX & b ) const {
|
||||
return beta_ > b.beta_;
|
||||
}
|
||||
|
||||
inline bool HepBoostX::isIdentity() const {
|
||||
return ( beta() == 0 );
|
||||
}
|
||||
|
||||
inline double HepBoostX::distance2( const HepBoostX & b ) const {
|
||||
double d = beta()*gamma() - b.beta()*b.gamma();
|
||||
return d*d;
|
||||
}
|
||||
|
||||
inline double HepBoostX::howNear(const HepBoostX & b) const {
|
||||
return std::sqrt(distance2(b)); }
|
||||
inline double HepBoostX::howNear(const HepBoost & b) const {
|
||||
return std::sqrt(distance2(b)); }
|
||||
inline double HepBoostX::howNear(const HepRotation & r) const {
|
||||
return std::sqrt(distance2(r)); }
|
||||
inline double HepBoostX::howNear(const HepLorentzRotation & lt) const {
|
||||
return std::sqrt(distance2(lt)); }
|
||||
|
||||
inline bool HepBoostX::isNear(const HepBoostX & b,
|
||||
double epsilon) const {
|
||||
return (distance2(b) <= epsilon*epsilon);
|
||||
}
|
||||
inline bool HepBoostX::isNear(const HepBoost & b,
|
||||
double epsilon) const {
|
||||
return (distance2(b) <= epsilon*epsilon);
|
||||
}
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
inline double HepBoostX::norm2() const {
|
||||
register double bg = beta_*gamma_;
|
||||
return bg*bg;
|
||||
}
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline HepLorentzVector
|
||||
HepBoostX::operator * (const HepLorentzVector & p) const {
|
||||
double bg = beta_*gamma_;
|
||||
return HepLorentzVector(gamma_*p.x() + bg*p.t(),
|
||||
p.y(),
|
||||
p.z(),
|
||||
gamma_*p.t() + bg*p.x());
|
||||
}
|
||||
|
||||
inline HepLorentzVector
|
||||
HepBoostX::operator() (const HepLorentzVector & w) const {
|
||||
return operator*(w);
|
||||
}
|
||||
|
||||
// ---------- Operations in the group of 4-Rotations
|
||||
|
||||
inline HepBoostX HepBoostX::inverse() const {
|
||||
return HepBoostX( -beta(), gamma() );
|
||||
}
|
||||
|
||||
inline HepBoostX inverseOf ( const HepBoostX & b ) {
|
||||
return HepBoostX( -b.beta(), b.gamma());
|
||||
}
|
||||
|
||||
inline HepBoostX & HepBoostX::invert() {
|
||||
beta_ = -beta_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---------- Tolerance:
|
||||
|
||||
inline double HepBoostX::getTolerance() {
|
||||
return Hep4RotationInterface::tolerance;
|
||||
}
|
||||
inline double HepBoostX::setTolerance(double tol) {
|
||||
return Hep4RotationInterface::setTolerance(tol);
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,222 @@
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definition of the HepBoostY class for performing specialized
|
||||
// Lorentz transformations which are pure boosts in the Y direction, on
|
||||
// objects of the HepLorentzVector class.
|
||||
//
|
||||
// HepLorentzRotation is a concrete implementation of Hep4RotationInterface.
|
||||
//
|
||||
// .SS See Also
|
||||
// RotationInterfaces.h
|
||||
// LorentzVector.h LorentzRotation.h
|
||||
// Boost.h
|
||||
//
|
||||
// .SS Author
|
||||
// Mark Fischler
|
||||
|
||||
#ifndef HEP_BOOSTY_H
|
||||
#define HEP_BOOSTY_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "CLHEP/Vector/RotationInterfaces.h"
|
||||
#include "CLHEP/Vector/LorentzVector.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Declarations of classes and global methods
|
||||
class HepBoostY;
|
||||
inline HepBoostY inverseOf ( const HepBoostY & b );
|
||||
class HepBoost;
|
||||
class HepRotation;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepBoostY {
|
||||
|
||||
public:
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepBoostY();
|
||||
// Default constructor. Gives a boost of 0.
|
||||
|
||||
inline HepBoostY(const HepBoostY & b);
|
||||
// Copy constructor.
|
||||
|
||||
inline HepBoostY & operator = (const HepBoostY & m);
|
||||
// Assignment.
|
||||
|
||||
HepBoostY & set (double beta);
|
||||
inline HepBoostY (double beta);
|
||||
// Constructor from beta
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline double beta() const;
|
||||
inline double gamma() const;
|
||||
inline Hep3Vector boostVector() const;
|
||||
inline Hep3Vector getDirection() const;
|
||||
|
||||
inline double xx() const;
|
||||
inline double xy() const;
|
||||
inline double xz() const;
|
||||
inline double xt() const;
|
||||
inline double yx() const;
|
||||
inline double yy() const;
|
||||
inline double yz() const;
|
||||
inline double yt() const;
|
||||
inline double zx() const;
|
||||
inline double zy() const;
|
||||
inline double zz() const;
|
||||
inline double zt() const;
|
||||
inline double tx() const;
|
||||
inline double ty() const;
|
||||
inline double tz() const;
|
||||
inline double tt() const;
|
||||
// Elements of the matrix.
|
||||
|
||||
inline HepLorentzVector col1() const;
|
||||
inline HepLorentzVector col2() const;
|
||||
inline HepLorentzVector col3() const;
|
||||
inline HepLorentzVector col4() const;
|
||||
// orthosymplectic column vectors
|
||||
|
||||
inline HepLorentzVector row1() const;
|
||||
inline HepLorentzVector row2() const;
|
||||
inline HepLorentzVector row3() const;
|
||||
inline HepLorentzVector row4() const;
|
||||
// orthosymplectic row vectors
|
||||
|
||||
HepRep4x4 rep4x4() const;
|
||||
// 4x4 representation:
|
||||
|
||||
HepRep4x4Symmetric rep4x4Symmetric() const;
|
||||
// Symmetric 4x4 representation.
|
||||
|
||||
|
||||
// ---------- Decomposition:
|
||||
|
||||
void decompose (HepRotation & rotation, HepBoost & boost) const;
|
||||
void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
|
||||
// Find R and B such that L = R*B -- trivial, since R is identity
|
||||
|
||||
void decompose (HepBoost & boost, HepRotation & rotation) const;
|
||||
void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
|
||||
// Find R and B such that L = B*R -- trivial, since R is identity
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline int compare( const HepBoostY & b ) const;
|
||||
// Dictionary-order comparison, in order of beta.
|
||||
// Used in operator<, >, <=, >=
|
||||
|
||||
inline bool operator == (const HepBoostY & b) const;
|
||||
inline bool operator != (const HepBoostY & b) const;
|
||||
inline bool operator <= (const HepBoostY & b) const;
|
||||
inline bool operator >= (const HepBoostY & b) const;
|
||||
inline bool operator < (const HepBoostY & b) const;
|
||||
inline bool operator > (const HepBoostY & b) const;
|
||||
// Comparisons.
|
||||
|
||||
inline bool isIdentity() const;
|
||||
// Returns true if a null boost.
|
||||
|
||||
inline double distance2( const HepBoostY & b ) const;
|
||||
double distance2( const HepBoost & b ) const;
|
||||
// Defined as the distance2 between the vectors (gamma*betaVector)
|
||||
|
||||
double distance2( const HepRotation & r ) const;
|
||||
double distance2( const HepLorentzRotation & lt ) const;
|
||||
// Decompose lt = B*R; add norm2 to distance2 to between boosts.
|
||||
|
||||
inline double howNear( const HepBoostY & b ) const;
|
||||
inline double howNear( const HepBoost & b ) const;
|
||||
inline double howNear( const HepRotation & r ) const;
|
||||
inline double howNear( const HepLorentzRotation & lt ) const;
|
||||
|
||||
inline bool isNear( const HepBoostY & b,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
inline bool isNear( const HepBoost & b,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepRotation & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepLorentzRotation & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
inline double norm2() const;
|
||||
// distance2 (IDENTITY), which is beta^2 * gamma^2
|
||||
|
||||
void rectify();
|
||||
// sets according to the stored beta
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
|
||||
// Transform a Lorentz Vector.
|
||||
|
||||
inline HepLorentzVector operator* ( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a Lorentz Vector.
|
||||
|
||||
// ---------- Operations in the group of 4-Rotations
|
||||
|
||||
HepBoostY operator * (const HepBoostY & b) const;
|
||||
HepLorentzRotation operator * (const HepBoost & b) const;
|
||||
HepLorentzRotation operator * (const HepRotation & r) const;
|
||||
HepLorentzRotation operator * (const HepLorentzRotation & lt) const;
|
||||
// Product of two Lorentz Rotations (this) * lt - matrix multiplication
|
||||
// Notice that the product of two pure boosts in different directions
|
||||
// is no longer a pure boost.
|
||||
|
||||
inline HepBoostY inverse() const;
|
||||
// Return the inverse.
|
||||
|
||||
inline friend HepBoostY inverseOf ( const HepBoostY & b );
|
||||
// global methods to invert.
|
||||
|
||||
inline HepBoostY & invert();
|
||||
// Inverts the Boost matrix.
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
// Output form is BOOSTY (beta=..., gamma=...);
|
||||
|
||||
// ---------- Tolerance
|
||||
|
||||
static inline double getTolerance();
|
||||
static inline double setTolerance(double tol);
|
||||
|
||||
protected:
|
||||
|
||||
inline HepLorentzVector vectorMultiplication
|
||||
( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a Lorentz Vector.
|
||||
|
||||
HepLorentzRotation matrixMultiplication (const HepRep4x4 & m) const;
|
||||
HepLorentzRotation matrixMultiplication (const HepRep4x4Symmetric & m) const;
|
||||
|
||||
inline HepBoostY (double beta, double gamma);
|
||||
|
||||
double beta_;
|
||||
double gamma_;
|
||||
|
||||
}; // HepBoostY
|
||||
|
||||
inline
|
||||
std::ostream & operator <<
|
||||
( std::ostream & os, const HepBoostY& b ) {return b.print(os);}
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/BoostY.icc"
|
||||
|
||||
#endif /* HEP_BOOSTY_H */
|
||||
@@ -0,0 +1,199 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// HepBoostY class
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepBoostY::HepBoostY() : beta_(0.0), gamma_(1.0) {}
|
||||
|
||||
inline HepBoostY::HepBoostY(const HepBoostY & b) :
|
||||
beta_ (b.beta_),
|
||||
gamma_(b.gamma_) {}
|
||||
|
||||
inline HepBoostY & HepBoostY::operator = (const HepBoostY & b) {
|
||||
beta_ = b.beta_;
|
||||
gamma_ = b.gamma_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepBoostY::HepBoostY(double beta) { set(beta); }
|
||||
|
||||
// - Protected method:
|
||||
inline HepBoostY::HepBoostY( double beta, double gamma ) :
|
||||
beta_(beta), gamma_(gamma) {}
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline double HepBoostY::beta() const {
|
||||
return beta_;
|
||||
}
|
||||
|
||||
inline double HepBoostY::gamma() const {
|
||||
return gamma_;
|
||||
}
|
||||
|
||||
inline Hep3Vector HepBoostY::boostVector() const {
|
||||
return Hep3Vector( 0, beta_, 0 );
|
||||
}
|
||||
|
||||
inline Hep3Vector HepBoostY::getDirection() const {
|
||||
return Hep3Vector( 0.0, 1.0, 0.0 );
|
||||
}
|
||||
|
||||
inline double HepBoostY::xx() const { return 1.0;}
|
||||
inline double HepBoostY::xy() const { return 0.0;}
|
||||
inline double HepBoostY::xz() const { return 0.0;}
|
||||
inline double HepBoostY::xt() const { return 0.0;}
|
||||
inline double HepBoostY::yx() const { return 0.0;}
|
||||
inline double HepBoostY::yy() const { return gamma();}
|
||||
inline double HepBoostY::yz() const { return 0.0;}
|
||||
inline double HepBoostY::yt() const { return beta()*gamma();}
|
||||
inline double HepBoostY::zx() const { return 0.0;}
|
||||
inline double HepBoostY::zy() const { return 0.0;}
|
||||
inline double HepBoostY::zz() const { return 1.0;}
|
||||
inline double HepBoostY::zt() const { return 0.0;}
|
||||
inline double HepBoostY::tx() const { return 0.0;}
|
||||
inline double HepBoostY::ty() const { return beta()*gamma();}
|
||||
inline double HepBoostY::tz() const { return 0.0;}
|
||||
inline double HepBoostY::tt() const { return gamma();}
|
||||
|
||||
inline HepLorentzVector HepBoostY::col1() const {
|
||||
return HepLorentzVector ( 1, 0, 0, 0 );
|
||||
}
|
||||
inline HepLorentzVector HepBoostY::col2() const {
|
||||
return HepLorentzVector ( 0, gamma(), 0, beta()*gamma() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostY::col3() const {
|
||||
return HepLorentzVector ( 0, 0, 1, 0 );
|
||||
}
|
||||
inline HepLorentzVector HepBoostY::col4() const {
|
||||
return HepLorentzVector ( 0, beta()*gamma(), 0, gamma() );
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepBoostY::row1() const {
|
||||
return HepLorentzVector ( col1() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostY::row2() const {
|
||||
return HepLorentzVector ( col2() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostY::row3() const {
|
||||
return HepLorentzVector ( col3() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostY::row4() const {
|
||||
return HepLorentzVector ( col4() );
|
||||
}
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline int HepBoostY::compare( const HepBoostY & b ) const {
|
||||
if (beta() < b.beta()) {
|
||||
return -1;
|
||||
} else if (beta() > b.beta()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool HepBoostY::operator == ( const HepBoostY & b ) const {
|
||||
return beta_ == b.beta_;
|
||||
}
|
||||
inline bool HepBoostY::operator != ( const HepBoostY & b ) const {
|
||||
return beta_ != b.beta_;
|
||||
}
|
||||
inline bool HepBoostY::operator <= ( const HepBoostY & b ) const {
|
||||
return beta_ <= b.beta_;
|
||||
}
|
||||
inline bool HepBoostY::operator >= ( const HepBoostY & b ) const {
|
||||
return beta_ >= b.beta_;
|
||||
}
|
||||
inline bool HepBoostY::operator < ( const HepBoostY & b ) const {
|
||||
return beta_ < b.beta_;
|
||||
}
|
||||
inline bool HepBoostY::operator > ( const HepBoostY & b ) const {
|
||||
return beta_ > b.beta_;
|
||||
}
|
||||
|
||||
inline bool HepBoostY::isIdentity() const {
|
||||
return ( beta() == 0 );
|
||||
}
|
||||
|
||||
inline double HepBoostY::distance2( const HepBoostY & b ) const {
|
||||
double d = beta()*gamma() - b.beta()*b.gamma();
|
||||
return d*d;
|
||||
}
|
||||
|
||||
inline double HepBoostY::howNear(const HepBoostY & b) const {
|
||||
return std::sqrt(distance2(b)); }
|
||||
inline double HepBoostY::howNear(const HepBoost & b) const {
|
||||
return std::sqrt(distance2(b)); }
|
||||
inline double HepBoostY::howNear(const HepRotation & r) const {
|
||||
return std::sqrt(distance2(r)); }
|
||||
inline double HepBoostY::howNear(const HepLorentzRotation & lt) const {
|
||||
return std::sqrt(distance2(lt)); }
|
||||
|
||||
inline bool HepBoostY::isNear(const HepBoostY & b,
|
||||
double epsilon) const {
|
||||
return (distance2(b) <= epsilon*epsilon);
|
||||
}
|
||||
inline bool HepBoostY::isNear(const HepBoost & b,
|
||||
double epsilon) const {
|
||||
return (distance2(b) <= epsilon*epsilon);
|
||||
}
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
double HepBoostY::norm2() const {
|
||||
register double bg = beta_*gamma_;
|
||||
return bg*bg;
|
||||
}
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline HepLorentzVector
|
||||
HepBoostY::operator * (const HepLorentzVector & p) const {
|
||||
double bg = beta_*gamma_;
|
||||
return HepLorentzVector( p.x(),
|
||||
gamma_*p.y() + bg*p.t(),
|
||||
p.z(),
|
||||
gamma_*p.t() + bg*p.y());
|
||||
}
|
||||
|
||||
HepLorentzVector HepBoostY::operator() (const HepLorentzVector & w) const {
|
||||
return operator*(w);
|
||||
}
|
||||
|
||||
// ---------- Operations in the group of 4-Rotations
|
||||
|
||||
inline HepBoostY HepBoostY::inverse() const {
|
||||
return HepBoostY( -beta(), gamma() );
|
||||
}
|
||||
|
||||
inline HepBoostY inverseOf ( const HepBoostY & b ) {
|
||||
return HepBoostY( -b.beta(), b.gamma());
|
||||
}
|
||||
|
||||
inline HepBoostY & HepBoostY::invert() {
|
||||
beta_ = -beta_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---------- Tolerance:
|
||||
|
||||
inline double HepBoostY::getTolerance() {
|
||||
return Hep4RotationInterface::tolerance;
|
||||
}
|
||||
inline double HepBoostY::setTolerance(double tol) {
|
||||
return Hep4RotationInterface::setTolerance(tol);
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,221 @@
|
||||
// -*- C++ -*-
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definition of the HepBoostZ class for performing specialized
|
||||
// Lorentz transformations which are pure boosts in the Z direction, on
|
||||
// objects of the HepLorentzVector class.
|
||||
//
|
||||
// HepLorentzRotation is a concrete implementation of Hep4RotationInterface.
|
||||
//
|
||||
// .SS See Also
|
||||
// RotationInterfaces.h
|
||||
// LorentzVector.h LorentzRotation.h
|
||||
// Boost.h
|
||||
//
|
||||
// .SS Author
|
||||
// Mark Fischler
|
||||
|
||||
#ifndef HEP_BOOSTZ_H
|
||||
#define HEP_BOOSTZ_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "CLHEP/Vector/RotationInterfaces.h"
|
||||
#include "CLHEP/Vector/LorentzVector.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Declarations of classes and global methods
|
||||
class HepBoostZ;
|
||||
inline HepBoostZ inverseOf ( const HepBoostZ & b );
|
||||
class HepBoost;
|
||||
class HepRotation;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepBoostZ {
|
||||
|
||||
public:
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepBoostZ();
|
||||
// Default constructor. Gives a boost of 0.
|
||||
|
||||
inline HepBoostZ(const HepBoostZ & b);
|
||||
// Copy constructor.
|
||||
|
||||
inline HepBoostZ & operator = (const HepBoostZ & m);
|
||||
// Assignment.
|
||||
|
||||
HepBoostZ & set (double beta);
|
||||
inline HepBoostZ (double beta);
|
||||
// Constructor from beta
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline double beta() const;
|
||||
inline double gamma() const;
|
||||
inline Hep3Vector boostVector() const;
|
||||
inline Hep3Vector getDirection() const;
|
||||
|
||||
inline double xx() const;
|
||||
inline double xy() const;
|
||||
inline double xz() const;
|
||||
inline double xt() const;
|
||||
inline double yx() const;
|
||||
inline double yy() const;
|
||||
inline double yz() const;
|
||||
inline double yt() const;
|
||||
inline double zx() const;
|
||||
inline double zy() const;
|
||||
inline double zz() const;
|
||||
inline double zt() const;
|
||||
inline double tx() const;
|
||||
inline double ty() const;
|
||||
inline double tz() const;
|
||||
inline double tt() const;
|
||||
// Elements of the matrix.
|
||||
|
||||
inline HepLorentzVector col1() const;
|
||||
inline HepLorentzVector col2() const;
|
||||
inline HepLorentzVector col3() const;
|
||||
inline HepLorentzVector col4() const;
|
||||
// orthosymplectic column vectors
|
||||
|
||||
inline HepLorentzVector row1() const;
|
||||
inline HepLorentzVector row2() const;
|
||||
inline HepLorentzVector row3() const;
|
||||
inline HepLorentzVector row4() const;
|
||||
// orthosymplectic row vectors
|
||||
|
||||
HepRep4x4 rep4x4() const;
|
||||
// 4x4 representation:
|
||||
|
||||
HepRep4x4Symmetric rep4x4Symmetric() const;
|
||||
// Symmetric 4x4 representation.
|
||||
|
||||
// ---------- Decomposition:
|
||||
|
||||
void decompose (HepRotation & rotation, HepBoost & boost) const;
|
||||
void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
|
||||
// Find R and B such that L = R*B -- trivial, since R is identity
|
||||
|
||||
void decompose (HepBoost & boost, HepRotation & rotation) const;
|
||||
void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
|
||||
// Find R and B such that L = B*R -- trivial, since R is identity
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline int compare( const HepBoostZ & b ) const;
|
||||
// Dictionary-order comparison, in order of beta.
|
||||
// Used in operator<, >, <=, >=
|
||||
|
||||
inline bool operator == (const HepBoostZ & b) const;
|
||||
inline bool operator != (const HepBoostZ & b) const;
|
||||
inline bool operator <= (const HepBoostZ & b) const;
|
||||
inline bool operator >= (const HepBoostZ & b) const;
|
||||
inline bool operator < (const HepBoostZ & b) const;
|
||||
inline bool operator > (const HepBoostZ & b) const;
|
||||
// Comparisons.
|
||||
|
||||
inline bool isIdentity() const;
|
||||
// Returns true if a null boost.
|
||||
|
||||
inline double distance2( const HepBoostZ & b ) const;
|
||||
double distance2( const HepBoost & b ) const;
|
||||
// Defined as the distance2 between the vectors (gamma*betaVector)
|
||||
|
||||
double distance2( const HepRotation & r ) const;
|
||||
double distance2( const HepLorentzRotation & lt ) const;
|
||||
// Decompose lt = B*R; add norm2 to distance2 to between boosts.
|
||||
|
||||
inline double howNear( const HepBoostZ & b ) const;
|
||||
inline double howNear( const HepBoost & b ) const;
|
||||
inline double howNear( const HepRotation & r ) const;
|
||||
inline double howNear( const HepLorentzRotation & lt ) const;
|
||||
|
||||
inline bool isNear( const HepBoostZ & b,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
inline bool isNear( const HepBoost & b,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepRotation & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepLorentzRotation & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
inline double norm2() const;
|
||||
// distance2 (IDENTITY), which is beta^2 * gamma^2
|
||||
|
||||
void rectify();
|
||||
// sets according to the stored beta
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
|
||||
// Transform a Lorentz Vector.
|
||||
|
||||
inline HepLorentzVector operator* ( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a Lorentz Vector.
|
||||
|
||||
// ---------- Operations in the group of 4-Rotations
|
||||
|
||||
HepBoostZ operator * (const HepBoostZ & b) const;
|
||||
HepLorentzRotation operator * (const HepBoost & b) const;
|
||||
HepLorentzRotation operator * (const HepRotation & r) const;
|
||||
HepLorentzRotation operator * (const HepLorentzRotation & lt) const;
|
||||
// Product of two Lorentz Rotations (this) * lt - matrix multiplication
|
||||
// Notice that the product of two pure boosts in different directions
|
||||
// is no longer a pure boost.
|
||||
|
||||
inline HepBoostZ inverse() const;
|
||||
// Return the inverse.
|
||||
|
||||
inline friend HepBoostZ inverseOf ( const HepBoostZ & b );
|
||||
// global methods to invert.
|
||||
|
||||
inline HepBoostZ & invert();
|
||||
// Inverts the Boost matrix.
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
// Output form is BOOSTZ (beta=..., gamma=...);
|
||||
|
||||
// ---------- Tolerance
|
||||
|
||||
static inline double getTolerance();
|
||||
static inline double setTolerance(double tol);
|
||||
|
||||
protected:
|
||||
|
||||
inline HepLorentzVector vectorMultiplication
|
||||
( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a Lorentz Vector.
|
||||
|
||||
HepLorentzRotation matrixMultiplication (const HepRep4x4 & m) const;
|
||||
HepLorentzRotation matrixMultiplication (const HepRep4x4Symmetric & m) const;
|
||||
|
||||
inline HepBoostZ (double beta, double gamma);
|
||||
|
||||
double beta_;
|
||||
double gamma_;
|
||||
|
||||
}; // HepBoostZ
|
||||
|
||||
inline
|
||||
std::ostream & operator <<
|
||||
( std::ostream & os, const HepBoostZ& b ) {return b.print(os);}
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/BoostZ.icc"
|
||||
|
||||
#endif /* HEP_BOOSTZ_H */
|
||||
@@ -0,0 +1,199 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// HepBoostZ class
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepBoostZ::HepBoostZ() : beta_(0.0), gamma_(1.0) {}
|
||||
|
||||
inline HepBoostZ::HepBoostZ(const HepBoostZ & b) :
|
||||
beta_ (b.beta_),
|
||||
gamma_(b.gamma_) {}
|
||||
|
||||
inline HepBoostZ & HepBoostZ::operator = (const HepBoostZ & b) {
|
||||
beta_ = b.beta_;
|
||||
gamma_ = b.gamma_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepBoostZ::HepBoostZ(double beta) { set(beta); }
|
||||
|
||||
// - Protected method:
|
||||
inline HepBoostZ::HepBoostZ( double beta, double gamma ) :
|
||||
beta_(beta), gamma_(gamma) {}
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline double HepBoostZ::beta() const {
|
||||
return beta_;
|
||||
}
|
||||
|
||||
inline double HepBoostZ::gamma() const {
|
||||
return gamma_;
|
||||
}
|
||||
|
||||
inline Hep3Vector HepBoostZ::boostVector() const {
|
||||
return Hep3Vector( 0, 0, beta_ );
|
||||
}
|
||||
|
||||
inline Hep3Vector HepBoostZ::getDirection() const {
|
||||
return Hep3Vector( 0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
inline double HepBoostZ::xx() const { return 1.0;}
|
||||
inline double HepBoostZ::xy() const { return 0.0;}
|
||||
inline double HepBoostZ::xz() const { return 0.0;}
|
||||
inline double HepBoostZ::xt() const { return 0.0;}
|
||||
inline double HepBoostZ::yx() const { return 0.0;}
|
||||
inline double HepBoostZ::yy() const { return 1.0;}
|
||||
inline double HepBoostZ::yz() const { return 0.0;}
|
||||
inline double HepBoostZ::yt() const { return 0.0;}
|
||||
inline double HepBoostZ::zx() const { return 0.0;}
|
||||
inline double HepBoostZ::zy() const { return 0.0;}
|
||||
inline double HepBoostZ::zz() const { return gamma();}
|
||||
inline double HepBoostZ::zt() const { return beta()*gamma();}
|
||||
inline double HepBoostZ::tx() const { return 0.0;}
|
||||
inline double HepBoostZ::ty() const { return 0.0;}
|
||||
inline double HepBoostZ::tz() const { return beta()*gamma();}
|
||||
inline double HepBoostZ::tt() const { return gamma();}
|
||||
|
||||
inline HepLorentzVector HepBoostZ::col1() const {
|
||||
return HepLorentzVector ( 1, 0, 0, 0 );
|
||||
}
|
||||
inline HepLorentzVector HepBoostZ::col2() const {
|
||||
return HepLorentzVector ( 0, 1, 0, 0 );
|
||||
}
|
||||
inline HepLorentzVector HepBoostZ::col3() const {
|
||||
return HepLorentzVector ( 0, 0, gamma(), beta()*gamma() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostZ::col4() const {
|
||||
return HepLorentzVector ( 0, 0, beta()*gamma(), gamma() );
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepBoostZ::row1() const {
|
||||
return HepLorentzVector ( col1() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostZ::row2() const {
|
||||
return HepLorentzVector ( col2() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostZ::row3() const {
|
||||
return HepLorentzVector ( col3() );
|
||||
}
|
||||
inline HepLorentzVector HepBoostZ::row4() const {
|
||||
return HepLorentzVector ( col4() );
|
||||
}
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline int HepBoostZ::compare( const HepBoostZ & b ) const {
|
||||
if (beta() < b.beta()) {
|
||||
return -1;
|
||||
} else if (beta() > b.beta()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool HepBoostZ::operator == ( const HepBoostZ & b ) const {
|
||||
return beta_ == b.beta_;
|
||||
}
|
||||
inline bool HepBoostZ::operator != ( const HepBoostZ & b ) const {
|
||||
return beta_ != b.beta_;
|
||||
}
|
||||
inline bool HepBoostZ::operator <= ( const HepBoostZ & b ) const {
|
||||
return beta_ <= b.beta_;
|
||||
}
|
||||
inline bool HepBoostZ::operator >= ( const HepBoostZ & b ) const {
|
||||
return beta_ >= b.beta_;
|
||||
}
|
||||
inline bool HepBoostZ::operator < ( const HepBoostZ & b ) const {
|
||||
return beta_ < b.beta_;
|
||||
}
|
||||
inline bool HepBoostZ::operator > ( const HepBoostZ & b ) const {
|
||||
return beta_ > b.beta_;
|
||||
}
|
||||
|
||||
inline bool HepBoostZ::isIdentity() const {
|
||||
return ( beta() == 0 );
|
||||
}
|
||||
|
||||
inline double HepBoostZ::distance2( const HepBoostZ & b ) const {
|
||||
double d = beta()*gamma() - b.beta()*b.gamma();
|
||||
return d*d;
|
||||
}
|
||||
|
||||
inline double HepBoostZ::howNear(const HepBoostZ & b) const {
|
||||
return std::sqrt(distance2(b)); }
|
||||
inline double HepBoostZ::howNear(const HepBoost & b) const {
|
||||
return std::sqrt(distance2(b)); }
|
||||
inline double HepBoostZ::howNear(const HepRotation & r) const {
|
||||
return std::sqrt(distance2(r)); }
|
||||
inline double HepBoostZ::howNear(const HepLorentzRotation & lt) const {
|
||||
return std::sqrt(distance2(lt)); }
|
||||
|
||||
inline bool HepBoostZ::isNear(const HepBoostZ & b,
|
||||
double epsilon) const {
|
||||
return (distance2(b) <= epsilon*epsilon);
|
||||
}
|
||||
inline bool HepBoostZ::isNear(const HepBoost & b,
|
||||
double epsilon) const {
|
||||
return (distance2(b) <= epsilon*epsilon);
|
||||
}
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
double HepBoostZ::norm2() const {
|
||||
register double bg = beta_*gamma_;
|
||||
return bg*bg;
|
||||
}
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline HepLorentzVector
|
||||
HepBoostZ::operator * (const HepLorentzVector & p) const {
|
||||
double bg = beta_*gamma_;
|
||||
return HepLorentzVector( p.x(),
|
||||
p.y(),
|
||||
gamma_*p.z() + bg*p.t(),
|
||||
gamma_*p.t() + bg*p.z());
|
||||
}
|
||||
|
||||
HepLorentzVector HepBoostZ::operator() (const HepLorentzVector & w) const {
|
||||
return operator*(w);
|
||||
}
|
||||
|
||||
// ---------- Operations in the group of 4-Rotations
|
||||
|
||||
inline HepBoostZ HepBoostZ::inverse() const {
|
||||
return HepBoostZ( -beta(), gamma() );
|
||||
}
|
||||
|
||||
inline HepBoostZ & HepBoostZ::invert() {
|
||||
beta_ = -beta_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepBoostZ inverseOf ( const HepBoostZ & b ) {
|
||||
return HepBoostZ( -b.beta(), b.gamma());
|
||||
}
|
||||
|
||||
// ---------- Tolerance:
|
||||
|
||||
inline double HepBoostZ::getTolerance() {
|
||||
return Hep4RotationInterface::tolerance;
|
||||
}
|
||||
inline double HepBoostZ::setTolerance(double tol) {
|
||||
return Hep4RotationInterface::setTolerance(tol);
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,112 @@
|
||||
// -*- C++ -*-
|
||||
// CLASSDOC OFF
|
||||
// $Id:$
|
||||
// ---------------------------------------------------------------------------
|
||||
// CLASSDOC ON
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// EulerAngles.h EulerAngles class --
|
||||
// Support class for PhysicsVectors classes
|
||||
//
|
||||
// History:
|
||||
// 09-Jan-1998 WEB FixedTypes is now found in ZMutility
|
||||
// 12-Jan-1998 WEB PI is now found in ZMutility
|
||||
// 15-Jun-1998 WEB Added namespace support
|
||||
// 02-May-2000 WEB No global using
|
||||
// 26-Jul-2000 MF CLHEP version
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#ifndef HEP_EULERANGLES_H
|
||||
#define HEP_EULERANGLES_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Declarations of classes and global methods
|
||||
class HepEulerAngles;
|
||||
std::ostream & operator<<(std::ostream & os, const HepEulerAngles & aa);
|
||||
std::istream & operator>>(std::istream & is, HepEulerAngles & aa);
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepEulerAngles {
|
||||
|
||||
protected:
|
||||
typedef HepEulerAngles EA; // just an abbreviation
|
||||
static double tolerance; // to determine relative nearness
|
||||
|
||||
public:
|
||||
|
||||
// ---------- Constructors:
|
||||
inline HepEulerAngles();
|
||||
inline HepEulerAngles( double phi, double theta, double psi );
|
||||
|
||||
// ---------- Destructor, copy constructor, assignment:
|
||||
// use C++ defaults
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
public:
|
||||
inline double getPhi() const;
|
||||
inline double phi() const;
|
||||
inline EA & setPhi( double phi );
|
||||
|
||||
inline double getTheta() const;
|
||||
inline double theta() const;
|
||||
inline EA & setTheta( double theta );
|
||||
|
||||
inline double getPsi() const;
|
||||
inline double psi() const;
|
||||
inline EA & setPsi( double psi );
|
||||
|
||||
inline EA & set( double phi, double theta, double psi );
|
||||
|
||||
// ---------- Operations:
|
||||
|
||||
// comparisons:
|
||||
inline int compare ( const EA & ea ) const;
|
||||
|
||||
inline bool operator==( const EA & ea ) const;
|
||||
inline bool operator!=( const EA & ea ) const;
|
||||
inline bool operator< ( const EA & ea ) const;
|
||||
inline bool operator<=( const EA & ea ) const;
|
||||
inline bool operator> ( const EA & ea ) const;
|
||||
inline bool operator>=( const EA & ea ) const;
|
||||
|
||||
// relative comparison:
|
||||
inline static double getTolerance();
|
||||
inline static double setTolerance( double tol );
|
||||
|
||||
bool isNear ( const EA & ea, double epsilon = tolerance ) const;
|
||||
double howNear( const EA & ea ) const;
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
friend std::ostream & operator<<( std::ostream & os, const EA & ea );
|
||||
friend std::istream & operator>>( std::istream & is, EA & ea );
|
||||
|
||||
// ---------- Helper methods:
|
||||
|
||||
protected:
|
||||
double distance( const HepEulerAngles & ex ) const;
|
||||
|
||||
// ---------- Data members:
|
||||
protected:
|
||||
double phi_;
|
||||
double theta_;
|
||||
double psi_;
|
||||
|
||||
}; // HepEulerAngles
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/EulerAngles.icc"
|
||||
|
||||
#endif // EULERANGLES_H
|
||||
@@ -0,0 +1,124 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// EulerAngles.icc - Inline methods for EulerAngles class.
|
||||
//
|
||||
// History:
|
||||
// 9-Apr-1997 MF Split off from original angles.hh. Content-free.
|
||||
// 26-Jan-1998 WEB Fleshed out.
|
||||
// 12-Mar-1998 WEB Gave default constructor proper default values
|
||||
// 13-Mar-1998 WEB Simplified compare()
|
||||
// 17-Jun-1998 WEB Added namespace support
|
||||
// 27-Jul-2000 MF CLHEP version
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
inline HepEulerAngles::HepEulerAngles()
|
||||
: phi_( 0.0 ), theta_( 0.0 ), psi_( 0.0 )
|
||||
{} // HepEulerAngles::HepEulerAngles()
|
||||
|
||||
inline HepEulerAngles::HepEulerAngles (
|
||||
double phi, double theta, double psi )
|
||||
: phi_( phi ), theta_( theta ), psi_( psi )
|
||||
{} // HepEulerAngles::HepEulerAngles()
|
||||
|
||||
inline double HepEulerAngles::getPhi() const {
|
||||
return phi_;
|
||||
} // HepEulerAngles::getPhi()
|
||||
|
||||
inline double HepEulerAngles::phi() const {
|
||||
return phi_;
|
||||
} // HepEulerAngles::phi()
|
||||
|
||||
inline HepEulerAngles & HepEulerAngles::setPhi( double phi ) {
|
||||
phi_ = phi;
|
||||
return *this;
|
||||
} // HepEulerAngles::setPhi()
|
||||
|
||||
inline double HepEulerAngles::getTheta() const {
|
||||
return theta_;
|
||||
} // HepEulerAngles::getTheta()
|
||||
|
||||
inline double HepEulerAngles::theta() const {
|
||||
return theta_;
|
||||
} // HepEulerAngles::theta()
|
||||
|
||||
inline HepEulerAngles & HepEulerAngles::setTheta( double theta ) {
|
||||
theta_ = theta;
|
||||
return *this;
|
||||
} // HepEulerAngles::setTheta()
|
||||
|
||||
inline double HepEulerAngles::getPsi() const {
|
||||
return psi_;
|
||||
} // HepEulerAngles::getPsi()
|
||||
|
||||
inline double HepEulerAngles::psi() const {
|
||||
return psi_;
|
||||
} // HepEulerAngles::psi()
|
||||
|
||||
inline HepEulerAngles & HepEulerAngles::setPsi( double psi ) {
|
||||
psi_ = psi;
|
||||
return *this;
|
||||
} // HepEulerAngles::setPsi()
|
||||
|
||||
inline HepEulerAngles &
|
||||
HepEulerAngles::set( double phi, double theta, double psi ) {
|
||||
phi_ = phi, theta_ = theta, psi_ = psi;
|
||||
return *this;
|
||||
} // HepEulerAngles::set()
|
||||
|
||||
|
||||
inline int HepEulerAngles::compare( const HepEulerAngles & ea ) const {
|
||||
|
||||
return phi_ < ea.phi_ ? -1
|
||||
: phi_ > ea.phi_ ? +1
|
||||
: theta_ < ea.theta_ ? -1
|
||||
: theta_ > ea.theta_ ? +1
|
||||
: psi_ < ea.psi_ ? -1
|
||||
: psi_ > ea.psi_ ? +1
|
||||
: 0;
|
||||
|
||||
} // HepEulerAngles::compare()
|
||||
|
||||
|
||||
inline bool HepEulerAngles::operator==( const HepEulerAngles & ea ) const {
|
||||
return ( compare( ea ) == 0 );
|
||||
} // HepEulerAngles::operator==()
|
||||
|
||||
inline bool HepEulerAngles::operator!=( const HepEulerAngles & ea ) const {
|
||||
return ( compare( ea ) != 0 );
|
||||
} // HepEulerAngles::operator!=()
|
||||
|
||||
inline bool HepEulerAngles::operator<( const HepEulerAngles & ea ) const {
|
||||
return ( compare( ea ) < 0 );
|
||||
} // HepEulerAngles::operator<()
|
||||
|
||||
inline bool HepEulerAngles::operator<=( const HepEulerAngles & ea ) const {
|
||||
return ( compare( ea ) <= 0 );
|
||||
} // HepEulerAngles::operator<=()
|
||||
|
||||
inline bool HepEulerAngles::operator>( const HepEulerAngles & ea ) const {
|
||||
return ( compare( ea ) > 0 );
|
||||
} // HepEulerAngles::operator>()
|
||||
|
||||
inline bool HepEulerAngles::operator>=( const HepEulerAngles & ea ) const {
|
||||
return ( compare( ea ) >= 0 );
|
||||
} // HepEulerAngles::operator>=()
|
||||
|
||||
inline double HepEulerAngles::getTolerance() {
|
||||
return tolerance;
|
||||
} // HepEulerAngles::getTolerance()
|
||||
|
||||
inline double HepEulerAngles::setTolerance( double tol ) {
|
||||
double oldTolerance( tolerance );
|
||||
tolerance = tol;
|
||||
return oldTolerance;
|
||||
} // HepEulerAngles::setTolerance()
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,382 @@
|
||||
// -*- C++ -*-
|
||||
// CLASSDOC OFF
|
||||
// $Id:$
|
||||
// ---------------------------------------------------------------------------
|
||||
// CLASSDOC ON
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definition of the HepLorentzRotation class for performing
|
||||
// Lorentz transformations (rotations and boosts) on objects of the
|
||||
// HepLorentzVector class.
|
||||
//
|
||||
// HepLorentzRotation is a concrete implementation of Hep4RotationInterface.
|
||||
//
|
||||
// .SS See Also
|
||||
// RotationInterfaces.h
|
||||
// ThreeVector.h, LorentzVector.h
|
||||
// Rotation.h, Boost.h
|
||||
//
|
||||
// .SS Author
|
||||
// Leif Lonnblad, Mark Fischler
|
||||
|
||||
#ifndef HEP_LORENTZROTATION_H
|
||||
#define HEP_LORENTZROTATION_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "CLHEP/Vector/RotationInterfaces.h"
|
||||
#include "CLHEP/Vector/Rotation.h"
|
||||
#include "CLHEP/Vector/Boost.h"
|
||||
#include "CLHEP/Vector/LorentzVector.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Global methods
|
||||
|
||||
inline HepLorentzRotation inverseOf ( const HepLorentzRotation & lt );
|
||||
HepLorentzRotation operator * (const HepRotation & r,
|
||||
const HepLorentzRotation & lt);
|
||||
HepLorentzRotation operator * (const HepRotationX & r,
|
||||
const HepLorentzRotation & lt);
|
||||
HepLorentzRotation operator * (const HepRotationY & r,
|
||||
const HepLorentzRotation & lt);
|
||||
HepLorentzRotation operator * (const HepRotationZ & r,
|
||||
const HepLorentzRotation & lt);
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepLorentzRotation {
|
||||
|
||||
public:
|
||||
// ---------- Identity HepLorentzRotation:
|
||||
|
||||
DLL_API static const HepLorentzRotation IDENTITY;
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepLorentzRotation();
|
||||
// Default constructor. Gives a unit matrix.
|
||||
|
||||
inline HepLorentzRotation (const HepLorentzRotation & r);
|
||||
// Copy constructor.
|
||||
|
||||
inline HepLorentzRotation (const HepRotation & r);
|
||||
inline explicit HepLorentzRotation (const HepRotationX & r);
|
||||
inline explicit HepLorentzRotation (const HepRotationY & r);
|
||||
inline explicit HepLorentzRotation (const HepRotationZ & r);
|
||||
inline HepLorentzRotation (const HepBoost & b);
|
||||
inline explicit HepLorentzRotation (const HepBoostX & b);
|
||||
inline explicit HepLorentzRotation (const HepBoostY & b);
|
||||
inline explicit HepLorentzRotation (const HepBoostZ & b);
|
||||
// Constructors from special cases.
|
||||
|
||||
inline HepLorentzRotation & operator = (const HepLorentzRotation & m);
|
||||
inline HepLorentzRotation & operator = (const HepRotation & m);
|
||||
inline HepLorentzRotation & operator = (const HepBoost & m);
|
||||
// Assignment.
|
||||
|
||||
HepLorentzRotation & set (double bx, double by, double bz);
|
||||
inline HepLorentzRotation & set (const Hep3Vector & p);
|
||||
inline HepLorentzRotation & set (const HepRotation & r);
|
||||
inline HepLorentzRotation & set (const HepRotationX & r);
|
||||
inline HepLorentzRotation & set (const HepRotationY & r);
|
||||
inline HepLorentzRotation & set (const HepRotationZ & r);
|
||||
inline HepLorentzRotation & set (const HepBoost & boost);
|
||||
inline HepLorentzRotation & set (const HepBoostX & boost);
|
||||
inline HepLorentzRotation & set (const HepBoostY & boost);
|
||||
inline HepLorentzRotation & set (const HepBoostZ & boost);
|
||||
inline HepLorentzRotation (double bx, double by, double bz);
|
||||
inline HepLorentzRotation (const Hep3Vector & p);
|
||||
// Other Constructors giving a Lorentz-boost.
|
||||
|
||||
HepLorentzRotation & set( const HepBoost & B, const HepRotation & R );
|
||||
inline HepLorentzRotation ( const HepBoost & B, const HepRotation & R );
|
||||
// supply B and R: T = B R:
|
||||
|
||||
HepLorentzRotation & set( const HepRotation & R, const HepBoost & B );
|
||||
inline HepLorentzRotation ( const HepRotation & R, const HepBoost & B );
|
||||
// supply R and B: T = R B:
|
||||
|
||||
HepLorentzRotation ( const HepLorentzVector & col1,
|
||||
const HepLorentzVector & col2,
|
||||
const HepLorentzVector & col3,
|
||||
const HepLorentzVector & col4 );
|
||||
// Construct from four *orthosymplectic* LorentzVectors for the columns:
|
||||
// NOTE:
|
||||
// This constructor, and the two set methods below,
|
||||
// will check that the columns (or rows) form an orthosymplectic
|
||||
// matrix, and will adjust values so that this relation is
|
||||
// as exact as possible.
|
||||
// Orthosymplectic means the dot product USING THE METRIC
|
||||
// of two different coumns will be 0, and of a column with
|
||||
// itself will be one.
|
||||
|
||||
HepLorentzRotation & set( const HepLorentzVector & col1,
|
||||
const HepLorentzVector & col2,
|
||||
const HepLorentzVector & col3,
|
||||
const HepLorentzVector & col4 );
|
||||
// supply four *orthosymplectic* HepLorentzVectors for the columns
|
||||
|
||||
HepLorentzRotation & setRows( const HepLorentzVector & row1,
|
||||
const HepLorentzVector & row2,
|
||||
const HepLorentzVector & row3,
|
||||
const HepLorentzVector & row4 );
|
||||
// supply four *orthosymplectic* HepLorentzVectors for the columns
|
||||
|
||||
inline HepLorentzRotation & set( const HepRep4x4 & rep );
|
||||
inline HepLorentzRotation ( const HepRep4x4 & rep );
|
||||
// supply a HepRep4x4 structure (16 numbers)
|
||||
// WARNING:
|
||||
// This constructor and set method will assume the
|
||||
// HepRep4x4 supplied is in fact an orthosymplectic matrix.
|
||||
// No checking or correction is done. If you are
|
||||
// not certain the matrix is orthosymplectic, break it
|
||||
// into four HepLorentzVector columns and use the form
|
||||
// HepLorentzRotation (col1, col2, col3, col4)
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline double xx() const;
|
||||
inline double xy() const;
|
||||
inline double xz() const;
|
||||
inline double xt() const;
|
||||
inline double yx() const;
|
||||
inline double yy() const;
|
||||
inline double yz() const;
|
||||
inline double yt() const;
|
||||
inline double zx() const;
|
||||
inline double zy() const;
|
||||
inline double zz() const;
|
||||
inline double zt() const;
|
||||
inline double tx() const;
|
||||
inline double ty() const;
|
||||
inline double tz() const;
|
||||
inline double tt() const;
|
||||
// Elements of the matrix.
|
||||
|
||||
inline HepLorentzVector col1() const;
|
||||
inline HepLorentzVector col2() const;
|
||||
inline HepLorentzVector col3() const;
|
||||
inline HepLorentzVector col4() const;
|
||||
// orthosymplectic column vectors
|
||||
|
||||
inline HepLorentzVector row1() const;
|
||||
inline HepLorentzVector row2() const;
|
||||
inline HepLorentzVector row3() const;
|
||||
inline HepLorentzVector row4() const;
|
||||
// orthosymplectic row vectors
|
||||
|
||||
inline HepRep4x4 rep4x4() const;
|
||||
// 4x4 representation:
|
||||
|
||||
// ------------ Subscripting:
|
||||
|
||||
class HepLorentzRotation_row {
|
||||
public:
|
||||
inline HepLorentzRotation_row(const HepLorentzRotation &, int);
|
||||
inline double operator [] (int) const;
|
||||
private:
|
||||
const HepLorentzRotation & rr;
|
||||
int ii;
|
||||
};
|
||||
// Helper class for implemention of C-style subscripting r[i][j]
|
||||
|
||||
inline const HepLorentzRotation_row operator [] (int) const;
|
||||
// Returns object of the helper class for C-style subscripting r[i][j]
|
||||
|
||||
double operator () (int, int) const;
|
||||
// Fortran-style subscripting: returns (i,j) element of the matrix.
|
||||
|
||||
// ---------- Decomposition:
|
||||
|
||||
void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
|
||||
void decompose (HepBoost & boost, HepRotation & rotation) const;
|
||||
// Find B and R such that L = B*R
|
||||
|
||||
void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
|
||||
void decompose (HepRotation & rotation, HepBoost & boost) const;
|
||||
// Find R and B such that L = R*B
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
int compare( const HepLorentzRotation & m ) const;
|
||||
// Dictionary-order comparison, in order tt,tz,...zt,zz,zy,zx,yt,yz,...,xx
|
||||
// Used in operator<, >, <=, >=
|
||||
|
||||
inline bool operator == (const HepLorentzRotation &) const;
|
||||
inline bool operator != (const HepLorentzRotation &) const;
|
||||
inline bool operator <= (const HepLorentzRotation &) const;
|
||||
inline bool operator >= (const HepLorentzRotation &) const;
|
||||
inline bool operator < (const HepLorentzRotation &) const;
|
||||
inline bool operator > (const HepLorentzRotation &) const;
|
||||
|
||||
inline bool isIdentity() const;
|
||||
// Returns true if the Identity matrix.
|
||||
|
||||
double distance2( const HepBoost & b ) const;
|
||||
double distance2( const HepRotation & r ) const;
|
||||
double distance2( const HepLorentzRotation & lt ) const;
|
||||
// Decomposes L = B*R, returns the sum of distance2 for B and R.
|
||||
|
||||
double howNear( const HepBoost & b ) const;
|
||||
double howNear( const HepRotation & r) const;
|
||||
double howNear( const HepLorentzRotation & lt ) const;
|
||||
|
||||
bool isNear(const HepBoost & b,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear(const HepRotation & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear(const HepLorentzRotation & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
double norm2() const;
|
||||
// distance2 (IDENTITY), which involves decomposing into B and R and summing
|
||||
// norm2 for the individual B and R parts.
|
||||
|
||||
void rectify();
|
||||
// non-const but logically moot correction for accumulated roundoff errors
|
||||
// rectify averages the matrix with the orthotranspose of its actual
|
||||
// inverse (absent accumulated roundoff errors, the orthotranspose IS
|
||||
// the inverse)); this removes to first order those errors.
|
||||
// Then it formally decomposes that, extracts axis and delta for its
|
||||
// Rotation part, forms a LorentzRotation from a true HepRotation
|
||||
// with those values of axis and delta, times the true Boost
|
||||
// with that boost vector.
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline HepLorentzVector vectorMultiplication(const HepLorentzVector&) const;
|
||||
inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
|
||||
inline HepLorentzVector operator* ( const HepLorentzVector & p ) const;
|
||||
// Multiplication with a Lorentz Vector.
|
||||
|
||||
// ---------- Operations in the group of 4-Rotations
|
||||
|
||||
HepLorentzRotation matrixMultiplication(const HepRep4x4 & m) const;
|
||||
|
||||
inline HepLorentzRotation operator * (const HepBoost & b) const;
|
||||
inline HepLorentzRotation operator * (const HepRotation & r) const;
|
||||
inline HepLorentzRotation operator * (const HepLorentzRotation & lt) const;
|
||||
// Product of two Lorentz Rotations (this) * lt - matrix multiplication
|
||||
|
||||
inline HepLorentzRotation & operator *= (const HepBoost & b);
|
||||
inline HepLorentzRotation & operator *= (const HepRotation & r);
|
||||
inline HepLorentzRotation & operator *= (const HepLorentzRotation & lt);
|
||||
inline HepLorentzRotation & transform (const HepBoost & b);
|
||||
inline HepLorentzRotation & transform (const HepRotation & r);
|
||||
inline HepLorentzRotation & transform (const HepLorentzRotation & lt);
|
||||
// Matrix multiplication.
|
||||
// Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a;
|
||||
|
||||
// Here there is an opportunity for speedup by providing specialized forms
|
||||
// of lt * r and lt * b where r is a RotationX Y or Z or b is a BoostX Y or Z
|
||||
// These are, in fact, provided below for the transform() methods.
|
||||
|
||||
HepLorentzRotation & rotateX(double delta);
|
||||
// Rotation around the x-axis; equivalent to LT = RotationX(delta) * LT
|
||||
|
||||
HepLorentzRotation & rotateY(double delta);
|
||||
// Rotation around the y-axis; equivalent to LT = RotationY(delta) * LT
|
||||
|
||||
HepLorentzRotation & rotateZ(double delta);
|
||||
// Rotation around the z-axis; equivalent to LT = RotationZ(delta) * LT
|
||||
|
||||
inline HepLorentzRotation & rotate(double delta, const Hep3Vector& axis);
|
||||
inline HepLorentzRotation & rotate(double delta, const Hep3Vector *axis);
|
||||
// Rotation around specified vector - LT = Rotation(delta,axis)*LT
|
||||
|
||||
HepLorentzRotation & boostX(double beta);
|
||||
// Pure boost along the x-axis; equivalent to LT = BoostX(beta) * LT
|
||||
|
||||
HepLorentzRotation & boostY(double beta);
|
||||
// Pure boost along the y-axis; equivalent to LT = BoostX(beta) * LT
|
||||
|
||||
HepLorentzRotation & boostZ(double beta);
|
||||
// Pure boost along the z-axis; equivalent to LT = BoostX(beta) * LT
|
||||
|
||||
inline HepLorentzRotation & boost(double, double, double);
|
||||
inline HepLorentzRotation & boost(const Hep3Vector &);
|
||||
// Lorenz boost.
|
||||
|
||||
inline HepLorentzRotation inverse() const;
|
||||
// Return the inverse.
|
||||
|
||||
inline HepLorentzRotation & invert();
|
||||
// Inverts the LorentzRotation matrix.
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
// Aligned six-digit-accurate output of the transformation matrix.
|
||||
|
||||
// ---------- Tolerance
|
||||
|
||||
static inline double getTolerance();
|
||||
static inline double setTolerance(double tol);
|
||||
|
||||
friend HepLorentzRotation inverseOf ( const HepLorentzRotation & lt );
|
||||
|
||||
protected:
|
||||
|
||||
inline HepLorentzRotation
|
||||
(double mxx, double mxy, double mxz, double mxt,
|
||||
double myx, double myy, double myz, double myt,
|
||||
double mzx, double mzy, double mzz, double mzt,
|
||||
double mtx, double mty, double mtz, double mtt);
|
||||
// Protected constructor.
|
||||
// DOES NOT CHECK FOR VALIDITY AS A LORENTZ TRANSFORMATION.
|
||||
|
||||
inline void setBoost(double, double, double);
|
||||
// Set elements according to a boost vector.
|
||||
|
||||
double mxx, mxy, mxz, mxt,
|
||||
myx, myy, myz, myt,
|
||||
mzx, mzy, mzz, mzt,
|
||||
mtx, mty, mtz, mtt;
|
||||
// The matrix elements.
|
||||
|
||||
}; // HepLorentzRotation
|
||||
|
||||
inline std::ostream & operator<<
|
||||
( std::ostream & os, const HepLorentzRotation& lt )
|
||||
{return lt.print(os);}
|
||||
|
||||
inline bool operator==(const HepRotation &r, const HepLorentzRotation & lt)
|
||||
{ return lt==r; }
|
||||
inline bool operator!=(const HepRotation &r, const HepLorentzRotation & lt)
|
||||
{ return lt!=r; }
|
||||
inline bool operator<=(const HepRotation &r, const HepLorentzRotation & lt)
|
||||
{ return lt<=r; }
|
||||
inline bool operator>=(const HepRotation &r, const HepLorentzRotation & lt)
|
||||
{ return lt>=r; }
|
||||
inline bool operator<(const HepRotation &r, const HepLorentzRotation & lt)
|
||||
{ return lt<r; }
|
||||
inline bool operator>(const HepRotation &r, const HepLorentzRotation & lt)
|
||||
{ return lt>r; }
|
||||
|
||||
inline bool operator==(const HepBoost &b, const HepLorentzRotation & lt)
|
||||
{ return lt==b; }
|
||||
inline bool operator!=(const HepBoost &b, const HepLorentzRotation & lt)
|
||||
{ return lt!=b; }
|
||||
inline bool operator<=(const HepBoost &b, const HepLorentzRotation & lt)
|
||||
{ return lt<=b; }
|
||||
inline bool operator>=(const HepBoost &b, const HepLorentzRotation & lt)
|
||||
{ return lt>=b; }
|
||||
inline bool operator<(const HepBoost &b, const HepLorentzRotation & lt)
|
||||
{ return lt<b; }
|
||||
inline bool operator>(const HepBoost &b, const HepLorentzRotation & lt)
|
||||
{ return lt>b; }
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/LorentzRotation.icc"
|
||||
|
||||
#endif /* HEP_LORENTZROTATION_H */
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
// -*- C++ -*-
|
||||
// $Id:$
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// HepLorentzRotation class
|
||||
//
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepLorentzRotation::HepLorentzRotation() :
|
||||
mxx(1.0), mxy(0.0), mxz(0.0), mxt(0.0),
|
||||
myx(0.0), myy(1.0), myz(0.0), myt(0.0),
|
||||
mzx(0.0), mzy(0.0), mzz(1.0), mzt(0.0),
|
||||
mtx(0.0), mty(0.0), mtz(0.0), mtt(1.0) {}
|
||||
|
||||
inline HepLorentzRotation::HepLorentzRotation(const HepLorentzRotation & r) :
|
||||
mxx(r.mxx), mxy(r.mxy), mxz(r.mxz), mxt(r.mxt),
|
||||
myx(r.myx), myy(r.myy), myz(r.myz), myt(r.myt),
|
||||
mzx(r.mzx), mzy(r.mzy), mzz(r.mzz), mzt(r.mzt),
|
||||
mtx(r.mtx), mty(r.mty), mtz(r.mtz), mtt(r.mtt) {}
|
||||
|
||||
inline HepLorentzRotation::HepLorentzRotation(const HepRotation & r) {
|
||||
set (r.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation::HepLorentzRotation(const HepRotationX & r) {
|
||||
set (r.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation::HepLorentzRotation(const HepRotationY & r) {
|
||||
set (r.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation::HepLorentzRotation(const HepRotationZ & r) {
|
||||
set (r.rep4x4());
|
||||
}
|
||||
|
||||
inline HepLorentzRotation::HepLorentzRotation(const HepBoost & b) {
|
||||
set (b.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation::HepLorentzRotation(const HepBoostX & b) {
|
||||
set (b.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation::HepLorentzRotation(const HepBoostY & b) {
|
||||
set (b.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation::HepLorentzRotation(const HepBoostZ & b) {
|
||||
set (b.rep4x4());
|
||||
}
|
||||
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::operator = (const HepLorentzRotation & r) {
|
||||
mxx = r.mxx; mxy = r.mxy; mxz = r.mxz; mxt = r.mxt;
|
||||
myx = r.myx; myy = r.myy; myz = r.myz; myt = r.myt;
|
||||
mzx = r.mzx; mzy = r.mzy; mzz = r.mzz; mzt = r.mzt;
|
||||
mtx = r.mtx; mty = r.mty; mtz = r.mtz; mtt = r.mtt;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::operator = (const HepRotation & m) {
|
||||
return set (m.rep4x4());
|
||||
}
|
||||
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::operator = (const HepBoost & m) {
|
||||
return set (m.rep4x4());
|
||||
}
|
||||
|
||||
HepLorentzRotation & HepLorentzRotation::set (const Hep3Vector & p) {
|
||||
return set (p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
inline HepLorentzRotation & HepLorentzRotation::set (const HepRotation & r) {
|
||||
return set (r.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationX & r) {
|
||||
return set (r.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationY & r) {
|
||||
return set (r.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationZ & r) {
|
||||
return set (r.rep4x4());
|
||||
}
|
||||
|
||||
inline HepLorentzRotation & HepLorentzRotation::set (const HepBoost & boost) {
|
||||
return set (boost.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostX & boost) {
|
||||
return set (boost.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostY & boost) {
|
||||
return set (boost.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostZ & boost) {
|
||||
return set (boost.rep4x4());
|
||||
}
|
||||
|
||||
inline HepLorentzRotation::HepLorentzRotation(double bx,
|
||||
double by,
|
||||
double bz)
|
||||
{
|
||||
set(bx, by, bz);
|
||||
}
|
||||
|
||||
inline HepLorentzRotation::HepLorentzRotation(const Hep3Vector & p)
|
||||
{
|
||||
set(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
inline HepLorentzRotation::HepLorentzRotation(
|
||||
const HepBoost & B, const HepRotation & R)
|
||||
{
|
||||
set(B, R);
|
||||
}
|
||||
|
||||
inline HepLorentzRotation::HepLorentzRotation(
|
||||
const HepRotation & R, const HepBoost & B)
|
||||
{
|
||||
set(R, B);
|
||||
}
|
||||
|
||||
inline HepLorentzRotation & HepLorentzRotation::set( const HepRep4x4 & rep ) {
|
||||
mxx=rep.xx_; mxy=rep.xy_; mxz=rep.xz_; mxt=rep.xt_;
|
||||
myx=rep.yx_; myy=rep.yy_; myz=rep.yz_; myt=rep.yt_;
|
||||
mzx=rep.zx_; mzy=rep.zy_; mzz=rep.zz_; mzt=rep.zt_;
|
||||
mtx=rep.tx_; mty=rep.ty_; mtz=rep.tz_; mtt=rep.tt_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepLorentzRotation ::HepLorentzRotation ( const HepRep4x4 & rep ) :
|
||||
mxx(rep.xx_), mxy(rep.xy_), mxz(rep.xz_), mxt(rep.xt_),
|
||||
myx(rep.yx_), myy(rep.yy_), myz(rep.yz_), myt(rep.yt_),
|
||||
mzx(rep.zx_), mzy(rep.zy_), mzz(rep.zz_), mzt(rep.zt_),
|
||||
mtx(rep.tx_), mty(rep.ty_), mtz(rep.tz_), mtt(rep.tt_) {}
|
||||
|
||||
// - Protected methods
|
||||
|
||||
inline HepLorentzRotation::HepLorentzRotation(
|
||||
double rxx, double rxy, double rxz, double rxt,
|
||||
double ryx, double ryy, double ryz, double ryt,
|
||||
double rzx, double rzy, double rzz, double rzt,
|
||||
double rtx, double rty, double rtz, double rtt) :
|
||||
mxx(rxx), mxy(rxy), mxz(rxz), mxt(rxt),
|
||||
myx(ryx), myy(ryy), myz(ryz), myt(ryt),
|
||||
mzx(rzx), mzy(rzy), mzz(rzz), mzt(rzt),
|
||||
mtx(rtx), mty(rty), mtz(rtz), mtt(rtt) {}
|
||||
|
||||
inline void HepLorentzRotation::setBoost
|
||||
(double bx, double by, double bz) {
|
||||
set(bx, by, bz);
|
||||
}
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline double HepLorentzRotation::xx() const { return mxx; }
|
||||
inline double HepLorentzRotation::xy() const { return mxy; }
|
||||
inline double HepLorentzRotation::xz() const { return mxz; }
|
||||
inline double HepLorentzRotation::xt() const { return mxt; }
|
||||
inline double HepLorentzRotation::yx() const { return myx; }
|
||||
inline double HepLorentzRotation::yy() const { return myy; }
|
||||
inline double HepLorentzRotation::yz() const { return myz; }
|
||||
inline double HepLorentzRotation::yt() const { return myt; }
|
||||
inline double HepLorentzRotation::zx() const { return mzx; }
|
||||
inline double HepLorentzRotation::zy() const { return mzy; }
|
||||
inline double HepLorentzRotation::zz() const { return mzz; }
|
||||
inline double HepLorentzRotation::zt() const { return mzt; }
|
||||
inline double HepLorentzRotation::tx() const { return mtx; }
|
||||
inline double HepLorentzRotation::ty() const { return mty; }
|
||||
inline double HepLorentzRotation::tz() const { return mtz; }
|
||||
inline double HepLorentzRotation::tt() const { return mtt; }
|
||||
|
||||
inline HepLorentzVector HepLorentzRotation::col1() const {
|
||||
return HepLorentzVector ( mxx, myx, mzx, mtx );
|
||||
}
|
||||
inline HepLorentzVector HepLorentzRotation::col2() const {
|
||||
return HepLorentzVector ( mxy, myy, mzy, mty );
|
||||
}
|
||||
inline HepLorentzVector HepLorentzRotation::col3() const {
|
||||
return HepLorentzVector ( mxz, myz, mzz, mtz );
|
||||
}
|
||||
inline HepLorentzVector HepLorentzRotation::col4() const {
|
||||
return HepLorentzVector ( mxt, myt, mzt, mtt );
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepLorentzRotation::row1() const {
|
||||
return HepLorentzVector ( mxx, mxy, mxz, mxt );
|
||||
}
|
||||
inline HepLorentzVector HepLorentzRotation::row2() const {
|
||||
return HepLorentzVector ( myx, myy, myz, myt );
|
||||
}
|
||||
inline HepLorentzVector HepLorentzRotation::row3() const {
|
||||
return HepLorentzVector ( mzx, mzy, mzz, mzt );
|
||||
}
|
||||
inline HepLorentzVector HepLorentzRotation::row4() const {
|
||||
return HepLorentzVector ( mtx, mty, mtz, mtt );
|
||||
}
|
||||
|
||||
inline HepRep4x4 HepLorentzRotation::rep4x4() const {
|
||||
return HepRep4x4( mxx, mxy, mxz, mxt,
|
||||
myx, myy, myz, myt,
|
||||
mzx, mzy, mzz, mzt,
|
||||
mtx, mty, mtz, mtt );
|
||||
}
|
||||
|
||||
|
||||
// ------------ Subscripting:
|
||||
|
||||
inline HepLorentzRotation::HepLorentzRotation_row::HepLorentzRotation_row
|
||||
(const HepLorentzRotation & r, int i) : rr(r), ii(i) {}
|
||||
|
||||
inline double
|
||||
HepLorentzRotation::HepLorentzRotation_row::operator [] (int jj) const {
|
||||
return rr(ii,jj);
|
||||
}
|
||||
|
||||
inline const HepLorentzRotation::HepLorentzRotation_row
|
||||
HepLorentzRotation::operator [] (int i) const {
|
||||
return HepLorentzRotation_row(*this, i);
|
||||
}
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline bool
|
||||
HepLorentzRotation::operator == (const HepLorentzRotation & r) const {
|
||||
return (mxx == r.xx() && mxy == r.xy() && mxz == r.xz() && mxt == r.xt() &&
|
||||
myx == r.yx() && myy == r.yy() && myz == r.yz() && myt == r.yt() &&
|
||||
mzx == r.zx() && mzy == r.zy() && mzz == r.zz() && mzt == r.zt() &&
|
||||
mtx == r.tx() && mty == r.ty() && mtz == r.tz() && mtt == r.tt());
|
||||
}
|
||||
|
||||
inline bool
|
||||
HepLorentzRotation::operator != (const HepLorentzRotation & r) const {
|
||||
return ! operator==(r);
|
||||
}
|
||||
|
||||
inline bool
|
||||
HepLorentzRotation::operator < ( const HepLorentzRotation & r ) const
|
||||
{ return compare(r)< 0; }
|
||||
inline bool
|
||||
HepLorentzRotation::operator <= ( const HepLorentzRotation & r ) const
|
||||
{ return compare(r)<=0; }
|
||||
|
||||
inline bool
|
||||
HepLorentzRotation::operator >= ( const HepLorentzRotation & r ) const
|
||||
{ return compare(r)>=0; }
|
||||
inline bool
|
||||
HepLorentzRotation::operator > ( const HepLorentzRotation & r ) const
|
||||
{ return compare(r)> 0; }
|
||||
|
||||
inline bool HepLorentzRotation::isIdentity() const {
|
||||
return (mxx == 1.0 && mxy == 0.0 && mxz == 0.0 && mxt == 0.0 &&
|
||||
myx == 0.0 && myy == 1.0 && myz == 0.0 && myt == 0.0 &&
|
||||
mzx == 0.0 && mzy == 0.0 && mzz == 1.0 && mzt == 0.0 &&
|
||||
mtx == 0.0 && mty == 0.0 && mtz == 0.0 && mtt == 1.0);
|
||||
}
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline HepLorentzVector
|
||||
HepLorentzRotation::vectorMultiplication(const HepLorentzVector & p) const {
|
||||
register double x(p.x());
|
||||
register double y(p.y());
|
||||
register double z(p.z());
|
||||
register double t(p.t());
|
||||
return HepLorentzVector(mxx*x + mxy*y + mxz*z + mxt*t,
|
||||
myx*x + myy*y + myz*z + myt*t,
|
||||
mzx*x + mzy*y + mzz*z + mzt*t,
|
||||
mtx*x + mty*y + mtz*z + mtt*t);
|
||||
}
|
||||
|
||||
inline HepLorentzVector
|
||||
HepLorentzRotation::operator() (const HepLorentzVector & w) const {
|
||||
return vectorMultiplication(w);
|
||||
}
|
||||
|
||||
inline HepLorentzVector
|
||||
HepLorentzRotation::operator * (const HepLorentzVector & p) const {
|
||||
return vectorMultiplication(p);
|
||||
}
|
||||
|
||||
// ---------- Operations in the group of 4-Rotations
|
||||
|
||||
inline HepLorentzRotation
|
||||
HepLorentzRotation::operator * (const HepBoost & b) const {
|
||||
return matrixMultiplication(b.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation
|
||||
HepLorentzRotation::operator * (const HepRotation & r) const {
|
||||
return matrixMultiplication(r.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation
|
||||
HepLorentzRotation::operator * (const HepLorentzRotation & lt) const {
|
||||
return matrixMultiplication(lt.rep4x4());
|
||||
}
|
||||
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::operator *= (const HepBoost & b) {
|
||||
return *this = matrixMultiplication(b.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::operator *= (const HepRotation & r) {
|
||||
return *this = matrixMultiplication(r.rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::operator *= (const HepLorentzRotation & lt) {
|
||||
return *this = matrixMultiplication(lt.rep4x4());
|
||||
}
|
||||
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::transform (const HepBoost & b) {
|
||||
return *this = HepLorentzRotation(b).matrixMultiplication(rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::transform (const HepRotation & r) {
|
||||
return *this = HepLorentzRotation(r).matrixMultiplication(rep4x4());
|
||||
}
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::transform (const HepLorentzRotation & lt) {
|
||||
return *this = lt.matrixMultiplication(rep4x4());
|
||||
}
|
||||
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::rotate(double angle, const Hep3Vector & axis) {
|
||||
return transform(HepRotation().rotate(angle, axis));
|
||||
}
|
||||
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::rotate(double angle, const Hep3Vector * axis) {
|
||||
return transform(HepRotation().rotate(angle, axis));
|
||||
}
|
||||
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::boost(double bx, double by, double bz) {
|
||||
return transform(HepLorentzRotation(bx, by, bz));
|
||||
}
|
||||
|
||||
inline HepLorentzRotation &
|
||||
HepLorentzRotation::boost(const Hep3Vector & b) {
|
||||
return transform(HepLorentzRotation(b));
|
||||
}
|
||||
|
||||
inline HepLorentzRotation HepLorentzRotation::inverse() const {
|
||||
return HepLorentzRotation( mxx, myx, mzx, -mtx,
|
||||
mxy, myy, mzy, -mty,
|
||||
mxz, myz, mzz, -mtz,
|
||||
-mxt, -myt, -mzt, mtt );
|
||||
}
|
||||
|
||||
inline HepLorentzRotation & HepLorentzRotation::invert() {
|
||||
return *this = inverse();
|
||||
}
|
||||
|
||||
inline HepLorentzRotation inverseOf ( const HepLorentzRotation & lt ) {
|
||||
return HepLorentzRotation(
|
||||
HepRep4x4(
|
||||
lt.mxx, lt.myx, lt.mzx, -lt.mtx,
|
||||
lt.mxy, lt.myy, lt.mzy, -lt.mty,
|
||||
lt.mxz, lt.myz, lt.mzz, -lt.mtz,
|
||||
-lt.mxt, -lt.myt, -lt.mzt, lt.mtt ) );
|
||||
}
|
||||
|
||||
inline double HepLorentzRotation::getTolerance() {
|
||||
return Hep4RotationInterface::tolerance;
|
||||
}
|
||||
inline double HepLorentzRotation::setTolerance(double tol) {
|
||||
return Hep4RotationInterface::setTolerance(tol);
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,575 @@
|
||||
// -*- C++ -*-
|
||||
// CLASSDOC OFF
|
||||
// $Id:$
|
||||
// ---------------------------------------------------------------------------
|
||||
// CLASSDOC ON
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// HepLorentzVector is a Lorentz vector consisting of Hep3Vector and
|
||||
// double components. Lorentz transformations (rotations and boosts)
|
||||
// of these vectors are perfomed by multiplying with objects of
|
||||
// the HepLorenzRotation class.
|
||||
//
|
||||
// .SS See Also
|
||||
// ThreeVector.h, Rotation.h, LorentzRotation.h
|
||||
//
|
||||
// .SS Authors
|
||||
// Leif Lonnblad and Anders Nilsson. Modified by Evgueni Tcherniaev, Mark Fischler
|
||||
//
|
||||
|
||||
#ifndef HEP_LORENTZVECTOR_H
|
||||
#define HEP_LORENTZVECTOR_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include "CLHEP/Vector/ThreeVector.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Declarations of classes and global methods
|
||||
class HepLorentzVector;
|
||||
class HepLorentzRotation;
|
||||
class HepRotation;
|
||||
class HepAxisAngle;
|
||||
class HepEulerAngles;
|
||||
class Tcomponent;
|
||||
HepLorentzVector rotationXOf( const HepLorentzVector & vec, double delta );
|
||||
HepLorentzVector rotationYOf( const HepLorentzVector & vec, double delta );
|
||||
HepLorentzVector rotationZOf( const HepLorentzVector & vec, double delta );
|
||||
HepLorentzVector rotationOf
|
||||
( const HepLorentzVector & vec, const Hep3Vector & axis, double delta );
|
||||
HepLorentzVector rotationOf
|
||||
( const HepLorentzVector & vec, const HepAxisAngle & ax );
|
||||
HepLorentzVector rotationOf
|
||||
( const HepLorentzVector & vec, const HepEulerAngles & e );
|
||||
HepLorentzVector rotationOf
|
||||
( const HepLorentzVector & vec, double phi,
|
||||
double theta,
|
||||
double psi );
|
||||
inline
|
||||
HepLorentzVector boostXOf( const HepLorentzVector & vec, double beta );
|
||||
inline
|
||||
HepLorentzVector boostYOf( const HepLorentzVector & vec, double beta );
|
||||
inline
|
||||
HepLorentzVector boostZOf( const HepLorentzVector & vec, double beta );
|
||||
inline HepLorentzVector boostOf
|
||||
( const HepLorentzVector & vec, const Hep3Vector & betaVector );
|
||||
inline HepLorentzVector boostOf
|
||||
( const HepLorentzVector & vec, const Hep3Vector & axis, double beta );
|
||||
|
||||
enum ZMpvMetric_t { TimePositive, TimeNegative };
|
||||
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
|
||||
class HepLorentzVector {
|
||||
|
||||
public:
|
||||
|
||||
enum { X=0, Y=1, Z=2, T=3, NUM_COORDINATES=4, SIZE=NUM_COORDINATES };
|
||||
// Safe indexing of the coordinates when using with matrices, arrays, etc.
|
||||
// (BaBar)
|
||||
|
||||
inline HepLorentzVector(double x, double y,
|
||||
double z, double t);
|
||||
// Constructor giving the components x, y, z, t.
|
||||
|
||||
inline HepLorentzVector(double x, double y, double z);
|
||||
// Constructor giving the components x, y, z with t-component set to 0.0.
|
||||
|
||||
inline HepLorentzVector(double t);
|
||||
// Constructor giving the t-component with x, y and z set to 0.0.
|
||||
|
||||
inline HepLorentzVector();
|
||||
// Default constructor with x, y, z and t set to 0.0.
|
||||
|
||||
inline HepLorentzVector(const Hep3Vector & p, double e);
|
||||
inline HepLorentzVector(double e, const Hep3Vector & p);
|
||||
// Constructor giving a 3-Vector and a time component.
|
||||
|
||||
inline HepLorentzVector(const HepLorentzVector &);
|
||||
// Copy constructor.
|
||||
|
||||
inline ~HepLorentzVector();
|
||||
// The destructor.
|
||||
|
||||
inline operator const Hep3Vector & () const;
|
||||
inline operator Hep3Vector & ();
|
||||
// Conversion (cast) to Hep3Vector.
|
||||
|
||||
inline double x() const;
|
||||
inline double y() const;
|
||||
inline double z() const;
|
||||
inline double t() const;
|
||||
// Get position and time.
|
||||
|
||||
inline void setX(double);
|
||||
inline void setY(double);
|
||||
inline void setZ(double);
|
||||
inline void setT(double);
|
||||
// Set position and time.
|
||||
|
||||
inline double px() const;
|
||||
inline double py() const;
|
||||
inline double pz() const;
|
||||
inline double e() const;
|
||||
// Get momentum and energy.
|
||||
|
||||
inline void setPx(double);
|
||||
inline void setPy(double);
|
||||
inline void setPz(double);
|
||||
inline void setE(double);
|
||||
// Set momentum and energy.
|
||||
|
||||
inline Hep3Vector vect() const;
|
||||
// Get spatial component.
|
||||
|
||||
inline void setVect(const Hep3Vector &);
|
||||
// Set spatial component.
|
||||
|
||||
inline double theta() const;
|
||||
inline double cosTheta() const;
|
||||
inline double phi() const;
|
||||
inline double rho() const;
|
||||
// Get spatial vector components in spherical coordinate system.
|
||||
|
||||
inline void setTheta(double);
|
||||
inline void setPhi(double);
|
||||
inline void setRho(double);
|
||||
// Set spatial vector components in spherical coordinate system.
|
||||
|
||||
double operator () (int) const;
|
||||
inline double operator [] (int) const;
|
||||
// Get components by index.
|
||||
|
||||
double & operator () (int);
|
||||
inline double & operator [] (int);
|
||||
// Set components by index.
|
||||
|
||||
inline HepLorentzVector & operator = (const HepLorentzVector &);
|
||||
// Assignment.
|
||||
|
||||
inline HepLorentzVector operator + (const HepLorentzVector &) const;
|
||||
inline HepLorentzVector & operator += (const HepLorentzVector &);
|
||||
// Additions.
|
||||
|
||||
inline HepLorentzVector operator - (const HepLorentzVector &) const;
|
||||
inline HepLorentzVector & operator -= (const HepLorentzVector &);
|
||||
// Subtractions.
|
||||
|
||||
inline HepLorentzVector operator - () const;
|
||||
// Unary minus.
|
||||
|
||||
inline HepLorentzVector & operator *= (double);
|
||||
HepLorentzVector & operator /= (double);
|
||||
// Scaling with real numbers.
|
||||
|
||||
inline bool operator == (const HepLorentzVector &) const;
|
||||
inline bool operator != (const HepLorentzVector &) const;
|
||||
// Comparisons.
|
||||
|
||||
inline double perp2() const;
|
||||
// Transverse component of the spatial vector squared.
|
||||
|
||||
inline double perp() const;
|
||||
// Transverse component of the spatial vector (R in cylindrical system).
|
||||
|
||||
inline void setPerp(double);
|
||||
// Set the transverse component of the spatial vector.
|
||||
|
||||
inline double perp2(const Hep3Vector &) const;
|
||||
// Transverse component of the spatial vector w.r.t. given axis squared.
|
||||
|
||||
inline double perp(const Hep3Vector &) const;
|
||||
// Transverse component of the spatial vector w.r.t. given axis.
|
||||
|
||||
inline double angle(const Hep3Vector &) const;
|
||||
// Angle wrt. another vector.
|
||||
|
||||
inline double mag2() const;
|
||||
// Dot product of 4-vector with itself.
|
||||
// By default the metric is TimePositive, and mag2() is the same as m2().
|
||||
|
||||
inline double m2() const;
|
||||
// Invariant mass squared.
|
||||
|
||||
inline double mag() const;
|
||||
inline double m() const;
|
||||
// Invariant mass. If m2() is negative then -std::sqrt(-m2()) is returned.
|
||||
|
||||
inline double mt2() const;
|
||||
// Transverse mass squared.
|
||||
|
||||
inline double mt() const;
|
||||
// Transverse mass.
|
||||
|
||||
inline double et2() const;
|
||||
// Transverse energy squared.
|
||||
|
||||
inline double et() const;
|
||||
// Transverse energy.
|
||||
|
||||
inline double dot(const HepLorentzVector &) const;
|
||||
inline double operator * (const HepLorentzVector &) const;
|
||||
// Scalar product.
|
||||
|
||||
inline double invariantMass2( const HepLorentzVector & w ) const;
|
||||
// Invariant mass squared of pair of 4-vectors
|
||||
|
||||
double invariantMass ( const HepLorentzVector & w ) const;
|
||||
// Invariant mass of pair of 4-vectors
|
||||
|
||||
inline void setVectMag(const Hep3Vector & spatial, double magnitude);
|
||||
inline void setVectM(const Hep3Vector & spatial, double mass);
|
||||
// Copy spatial coordinates, and set energy = std::sqrt(mass^2 + spatial^2)
|
||||
|
||||
inline double plus() const;
|
||||
inline double minus() const;
|
||||
// Returns the positive/negative light-cone component t +/- z.
|
||||
|
||||
Hep3Vector boostVector() const;
|
||||
// Boost needed from rest4Vector in rest frame to form this 4-vector
|
||||
// Returns the spatial components divided by the time component.
|
||||
|
||||
HepLorentzVector & boost(double, double, double);
|
||||
inline HepLorentzVector & boost(const Hep3Vector &);
|
||||
// Lorentz boost.
|
||||
|
||||
HepLorentzVector & boostX( double beta );
|
||||
HepLorentzVector & boostY( double beta );
|
||||
HepLorentzVector & boostZ( double beta );
|
||||
// Boost along an axis, by magnitue beta (fraction of speed of light)
|
||||
|
||||
double rapidity() const;
|
||||
// Returns the rapidity, i.e. 0.5*ln((E+pz)/(E-pz))
|
||||
|
||||
inline double pseudoRapidity() const;
|
||||
// Returns the pseudo-rapidity, i.e. -ln(std::tan(theta/2))
|
||||
|
||||
inline bool isTimelike() const;
|
||||
// Test if the 4-vector is timelike
|
||||
|
||||
inline bool isSpacelike() const;
|
||||
// Test if the 4-vector is spacelike
|
||||
|
||||
inline bool isLightlike(double epsilon=tolerance) const;
|
||||
// Test for lightlike is within tolerance epsilon
|
||||
|
||||
HepLorentzVector & rotateX(double);
|
||||
// Rotate the spatial component around the x-axis.
|
||||
|
||||
HepLorentzVector & rotateY(double);
|
||||
// Rotate the spatial component around the y-axis.
|
||||
|
||||
HepLorentzVector & rotateZ(double);
|
||||
// Rotate the spatial component around the z-axis.
|
||||
|
||||
HepLorentzVector & rotateUz(const Hep3Vector &);
|
||||
// Rotates the reference frame from Uz to newUz (unit vector).
|
||||
|
||||
HepLorentzVector & rotate(double, const Hep3Vector &);
|
||||
// Rotate the spatial component around specified axis.
|
||||
|
||||
inline HepLorentzVector & operator *= (const HepRotation &);
|
||||
inline HepLorentzVector & transform(const HepRotation &);
|
||||
// Transformation with HepRotation.
|
||||
|
||||
HepLorentzVector & operator *= (const HepLorentzRotation &);
|
||||
HepLorentzVector & transform(const HepLorentzRotation &);
|
||||
// Transformation with HepLorenzRotation.
|
||||
|
||||
// = = = = = = = = = = = = = = = = = = = = = = = =
|
||||
//
|
||||
// Esoteric properties and operations on 4-vectors:
|
||||
//
|
||||
// 0 - Flexible metric convention and axial unit 4-vectors
|
||||
// 1 - Construct and set 4-vectors in various ways
|
||||
// 2 - Synonyms for accessing coordinates and properties
|
||||
// 2a - Setting space coordinates in different ways
|
||||
// 3 - Comparisions (dictionary, near-ness, and geometric)
|
||||
// 4 - Intrinsic properties
|
||||
// 4a - Releativistic kinematic properties
|
||||
// 4b - Methods combining two 4-vectors
|
||||
// 5 - Properties releative to z axis and to arbitrary directions
|
||||
// 7 - Rotations and Boosts
|
||||
//
|
||||
// = = = = = = = = = = = = = = = = = = = = = = = =
|
||||
|
||||
// 0 - Flexible metric convention
|
||||
|
||||
static ZMpvMetric_t setMetric( ZMpvMetric_t m );
|
||||
static ZMpvMetric_t getMetric();
|
||||
|
||||
// 1 - Construct and set 4-vectors in various ways
|
||||
|
||||
inline void set (double x, double y, double z, double t);
|
||||
inline void set (double x, double y, double z, Tcomponent t);
|
||||
inline HepLorentzVector(double x, double y, double z, Tcomponent t);
|
||||
// Form 4-vector by supplying cartesian coordinate components
|
||||
|
||||
inline void set (Tcomponent t, double x, double y, double z);
|
||||
inline HepLorentzVector(Tcomponent t, double x, double y, double z);
|
||||
// Deprecated because the 4-doubles form uses x,y,z,t, not t,x,y,z.
|
||||
|
||||
inline void set ( double t );
|
||||
|
||||
inline void set ( Tcomponent t );
|
||||
inline explicit HepLorentzVector( Tcomponent t );
|
||||
// Form 4-vector with zero space components, by supplying t component
|
||||
|
||||
inline void set ( const Hep3Vector & v );
|
||||
inline explicit HepLorentzVector( const Hep3Vector & v );
|
||||
// Form 4-vector with zero time component, by supplying space 3-vector
|
||||
|
||||
inline HepLorentzVector & operator=( const Hep3Vector & v );
|
||||
// Form 4-vector with zero time component, equal to space 3-vector
|
||||
|
||||
inline void set ( const Hep3Vector & v, double t );
|
||||
inline void set ( double t, const Hep3Vector & v );
|
||||
// Set using specified space vector and time component
|
||||
|
||||
// 2 - Synonyms for accessing coordinates and properties
|
||||
|
||||
inline double getX() const;
|
||||
inline double getY() const;
|
||||
inline double getZ() const;
|
||||
inline double getT() const;
|
||||
// Get position and time.
|
||||
|
||||
inline Hep3Vector v() const;
|
||||
inline Hep3Vector getV() const;
|
||||
// Get spatial component. Same as vect.
|
||||
|
||||
inline void setV(const Hep3Vector &);
|
||||
// Set spatial component. Same as setVect.
|
||||
|
||||
// 2a - Setting space coordinates in different ways
|
||||
|
||||
inline void setV( double x, double y, double z );
|
||||
|
||||
inline void setRThetaPhi( double r, double theta, double phi);
|
||||
inline void setREtaPhi( double r, double eta, double phi);
|
||||
inline void setRhoPhiZ( double rho, double phi, double z );
|
||||
|
||||
// 3 - Comparisions (dictionary, near-ness, and geometric)
|
||||
|
||||
int compare( const HepLorentzVector & w ) const;
|
||||
|
||||
bool operator >( const HepLorentzVector & w ) const;
|
||||
bool operator <( const HepLorentzVector & w ) const;
|
||||
bool operator>=( const HepLorentzVector & w ) const;
|
||||
bool operator<=( const HepLorentzVector & w ) const;
|
||||
|
||||
bool isNear ( const HepLorentzVector & w,
|
||||
double epsilon=tolerance ) const;
|
||||
double howNear( const HepLorentzVector & w ) const;
|
||||
// Is near using Euclidean measure t**2 + v**2
|
||||
|
||||
bool isNearCM ( const HepLorentzVector & w,
|
||||
double epsilon=tolerance ) const;
|
||||
double howNearCM( const HepLorentzVector & w ) const;
|
||||
// Is near in CM frame: Applicable only for two timelike HepLorentzVectors
|
||||
|
||||
// If w1 and w2 are already in their CM frame, then w1.isNearCM(w2)
|
||||
// is exactly equivalent to w1.isNear(w2).
|
||||
// If w1 and w2 have T components of zero, w1.isNear(w2) is exactly
|
||||
// equivalent to w1.getV().isNear(w2.v()).
|
||||
|
||||
bool isParallel( const HepLorentzVector & w,
|
||||
double epsilon=tolerance ) const;
|
||||
// Test for isParallel is within tolerance epsilon
|
||||
double howParallel (const HepLorentzVector & w) const;
|
||||
|
||||
static double getTolerance();
|
||||
static double setTolerance( double tol );
|
||||
// Set the tolerance for HepLorentzVectors to be considered near
|
||||
// The same tolerance is used for determining isLightlike, and isParallel
|
||||
|
||||
double deltaR(const HepLorentzVector & v) const;
|
||||
// std::sqrt ( (delta eta)^2 + (delta phi)^2 ) of space part
|
||||
|
||||
// 4 - Intrinsic properties
|
||||
|
||||
double howLightlike() const;
|
||||
// Close to zero for almost lightlike 4-vectors; up to 1.
|
||||
|
||||
inline double euclideanNorm2() const;
|
||||
// Sum of the squares of time and space components; not Lorentz invariant.
|
||||
|
||||
inline double euclideanNorm() const;
|
||||
// Length considering the metric as (+ + + +); not Lorentz invariant.
|
||||
|
||||
|
||||
// 4a - Relativistic kinematic properties
|
||||
|
||||
// All Relativistic kinematic properties are independent of the sense of metric
|
||||
|
||||
inline double restMass2() const;
|
||||
inline double invariantMass2() const;
|
||||
// Rest mass squared -- same as m2()
|
||||
|
||||
inline double restMass() const;
|
||||
inline double invariantMass() const;
|
||||
// Same as m(). If m2() is negative then -std::sqrt(-m2()) is returned.
|
||||
|
||||
// The following properties are rest-frame related,
|
||||
// and are applicable only to non-spacelike 4-vectors
|
||||
|
||||
HepLorentzVector rest4Vector() const;
|
||||
// This 4-vector, boosted into its own rest frame: (0, 0, 0, m())
|
||||
// The following relation holds by definition:
|
||||
// w.rest4Vector().boost(w.boostVector()) == w
|
||||
|
||||
// Beta and gamma of the boost vector
|
||||
double beta() const;
|
||||
// Relativistic beta of the boost vector
|
||||
|
||||
double gamma() const;
|
||||
// Relativistic gamma of the boost vector
|
||||
|
||||
inline double eta() const;
|
||||
// Pseudorapidity (of the space part)
|
||||
|
||||
inline double eta(const Hep3Vector & ref) const;
|
||||
// Pseudorapidity (of the space part) w.r.t. specified direction
|
||||
|
||||
double rapidity(const Hep3Vector & ref) const;
|
||||
// Rapidity in specified direction
|
||||
|
||||
double coLinearRapidity() const;
|
||||
// Rapidity, in the relativity textbook sense: atanh (|P|/E)
|
||||
|
||||
Hep3Vector findBoostToCM() const;
|
||||
// Boost needed to get to center-of-mass frame:
|
||||
// w.findBoostToCM() == - w.boostVector()
|
||||
// w.boost(w.findBoostToCM()) == w.rest4Vector()
|
||||
|
||||
Hep3Vector findBoostToCM( const HepLorentzVector & w ) const;
|
||||
// Boost needed to get to combined center-of-mass frame:
|
||||
// w1.findBoostToCM(w2) == w2.findBoostToCM(w1)
|
||||
// w.findBoostToCM(w) == w.findBoostToCM()
|
||||
|
||||
inline double et2(const Hep3Vector &) const;
|
||||
// Transverse energy w.r.t. given axis squared.
|
||||
|
||||
inline double et(const Hep3Vector &) const;
|
||||
// Transverse energy w.r.t. given axis.
|
||||
|
||||
// 4b - Methods combining two 4-vectors
|
||||
|
||||
inline double diff2( const HepLorentzVector & w ) const;
|
||||
// (this - w).dot(this-w); sign depends on metric choice
|
||||
|
||||
inline double delta2Euclidean ( const HepLorentzVector & w ) const;
|
||||
// Euclidean norm of differnce: (delta_T)^2 + (delta_V)^2
|
||||
|
||||
// 5 - Properties releative to z axis and to arbitrary directions
|
||||
|
||||
double plus( const Hep3Vector & ref ) const;
|
||||
// t + projection in reference direction
|
||||
|
||||
double minus( const Hep3Vector & ref ) const;
|
||||
// t - projection in reference direction
|
||||
|
||||
// 7 - Rotations and boosts
|
||||
|
||||
HepLorentzVector & rotate ( const Hep3Vector & axis, double delta );
|
||||
// Same as rotate (delta, axis)
|
||||
|
||||
HepLorentzVector & rotate ( const HepAxisAngle & ax );
|
||||
HepLorentzVector & rotate ( const HepEulerAngles & e );
|
||||
HepLorentzVector & rotate ( double phi,
|
||||
double theta,
|
||||
double psi );
|
||||
// Rotate using these HepEuler angles - see Goldstein page 107 for conventions
|
||||
|
||||
HepLorentzVector & boost ( const Hep3Vector & axis, double beta );
|
||||
// Normalizes the Hep3Vector to define a direction, and uses beta to
|
||||
// define the magnitude of the boost.
|
||||
|
||||
friend HepLorentzVector rotationXOf
|
||||
( const HepLorentzVector & vec, double delta );
|
||||
friend HepLorentzVector rotationYOf
|
||||
( const HepLorentzVector & vec, double delta );
|
||||
friend HepLorentzVector rotationZOf
|
||||
( const HepLorentzVector & vec, double delta );
|
||||
friend HepLorentzVector rotationOf
|
||||
( const HepLorentzVector & vec, const Hep3Vector & axis, double delta );
|
||||
friend HepLorentzVector rotationOf
|
||||
( const HepLorentzVector & vec, const HepAxisAngle & ax );
|
||||
friend HepLorentzVector rotationOf
|
||||
( const HepLorentzVector & vec, const HepEulerAngles & e );
|
||||
friend HepLorentzVector rotationOf
|
||||
( const HepLorentzVector & vec, double phi,
|
||||
double theta,
|
||||
double psi );
|
||||
|
||||
inline friend HepLorentzVector boostXOf
|
||||
( const HepLorentzVector & vec, double beta );
|
||||
inline friend HepLorentzVector boostYOf
|
||||
( const HepLorentzVector & vec, double beta );
|
||||
inline friend HepLorentzVector boostZOf
|
||||
( const HepLorentzVector & vec, double beta );
|
||||
inline friend HepLorentzVector boostOf
|
||||
( const HepLorentzVector & vec, const Hep3Vector & betaVector );
|
||||
inline friend HepLorentzVector boostOf
|
||||
( const HepLorentzVector & vec, const Hep3Vector & axis, double beta );
|
||||
|
||||
private:
|
||||
|
||||
Hep3Vector pp;
|
||||
double ee;
|
||||
|
||||
DLL_API static double tolerance;
|
||||
DLL_API static double metric;
|
||||
|
||||
}; // HepLorentzVector
|
||||
|
||||
// 8 - Axial Unit 4-vectors
|
||||
|
||||
static const HepLorentzVector X_HAT4 = HepLorentzVector( 1, 0, 0, 0 );
|
||||
static const HepLorentzVector Y_HAT4 = HepLorentzVector( 0, 1, 0, 0 );
|
||||
static const HepLorentzVector Z_HAT4 = HepLorentzVector( 0, 0, 1, 0 );
|
||||
static const HepLorentzVector T_HAT4 = HepLorentzVector( 0, 0, 0, 1 );
|
||||
|
||||
// Global methods
|
||||
|
||||
std::ostream & operator << (std::ostream &, const HepLorentzVector &);
|
||||
// Output to a stream.
|
||||
|
||||
std::istream & operator >> (std::istream &, HepLorentzVector &);
|
||||
// Input from a stream.
|
||||
|
||||
typedef HepLorentzVector HepLorentzVectorD;
|
||||
typedef HepLorentzVector HepLorentzVectorF;
|
||||
|
||||
inline HepLorentzVector operator * (const HepLorentzVector &, double a);
|
||||
inline HepLorentzVector operator * (double a, const HepLorentzVector &);
|
||||
// Scaling LorentzVector with a real number
|
||||
|
||||
HepLorentzVector operator / (const HepLorentzVector &, double a);
|
||||
// Dividing LorentzVector by a real number
|
||||
|
||||
// Tcomponent definition:
|
||||
|
||||
// Signature protection for 4-vector constructors taking 4 components
|
||||
class Tcomponent {
|
||||
private:
|
||||
double t_;
|
||||
public:
|
||||
explicit Tcomponent(double t) : t_(t) {}
|
||||
operator double() const { return t_; }
|
||||
}; // Tcomponent
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/LorentzVector.icc"
|
||||
|
||||
#endif /* HEP_LORENTZVECTOR_H */
|
||||
@@ -0,0 +1,434 @@
|
||||
// -*- C++ -*-
|
||||
// $Id:$
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// HepLorentzVector class.
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
inline double HepLorentzVector::x() const { return pp.x(); }
|
||||
inline double HepLorentzVector::y() const { return pp.y(); }
|
||||
inline double HepLorentzVector::z() const { return pp.z(); }
|
||||
inline double HepLorentzVector::t() const { return ee; }
|
||||
|
||||
inline HepLorentzVector::
|
||||
HepLorentzVector(double x, double y, double z, double t)
|
||||
: pp(x, y, z), ee(t) {}
|
||||
|
||||
inline HepLorentzVector:: HepLorentzVector(double x, double y, double z)
|
||||
: pp(x, y, z), ee(0) {}
|
||||
|
||||
inline HepLorentzVector:: HepLorentzVector(double t)
|
||||
: pp(0, 0, 0), ee(t) {}
|
||||
|
||||
inline HepLorentzVector:: HepLorentzVector()
|
||||
: pp(0, 0, 0), ee(0) {}
|
||||
|
||||
inline HepLorentzVector::HepLorentzVector(const Hep3Vector & p, double e)
|
||||
: pp(p), ee(e) {}
|
||||
|
||||
inline HepLorentzVector::HepLorentzVector(double e, const Hep3Vector & p)
|
||||
: pp(p), ee(e) {}
|
||||
|
||||
inline HepLorentzVector::HepLorentzVector(const HepLorentzVector & p)
|
||||
: pp(p.x(), p.y(), p.z()), ee(p.t()) {}
|
||||
|
||||
inline HepLorentzVector::~HepLorentzVector() {}
|
||||
|
||||
inline HepLorentzVector::operator const Hep3Vector & () const {return pp;}
|
||||
inline HepLorentzVector::operator Hep3Vector & () { return pp; }
|
||||
|
||||
inline void HepLorentzVector::setX(double a) { pp.setX(a); }
|
||||
inline void HepLorentzVector::setY(double a) { pp.setY(a); }
|
||||
inline void HepLorentzVector::setZ(double a) { pp.setZ(a); }
|
||||
inline void HepLorentzVector::setT(double a) { ee = a;}
|
||||
|
||||
inline double HepLorentzVector::px() const { return pp.x(); }
|
||||
inline double HepLorentzVector::py() const { return pp.y(); }
|
||||
inline double HepLorentzVector::pz() const { return pp.z(); }
|
||||
inline double HepLorentzVector::e() const { return ee; }
|
||||
|
||||
inline void HepLorentzVector::setPx(double a) { pp.setX(a); }
|
||||
inline void HepLorentzVector::setPy(double a) { pp.setY(a); }
|
||||
inline void HepLorentzVector::setPz(double a) { pp.setZ(a); }
|
||||
inline void HepLorentzVector::setE(double a) { ee = a;}
|
||||
|
||||
inline Hep3Vector HepLorentzVector::vect() const { return pp; }
|
||||
inline void HepLorentzVector::setVect(const Hep3Vector &p) { pp = p; }
|
||||
|
||||
inline double HepLorentzVector::theta() const { return pp.theta(); }
|
||||
inline double HepLorentzVector::cosTheta() const { return pp.cosTheta(); }
|
||||
inline double HepLorentzVector::phi() const { return pp.phi(); }
|
||||
inline double HepLorentzVector::rho() const { return pp.mag(); }
|
||||
|
||||
inline void HepLorentzVector::setTheta(double a) { pp.setTheta(a); }
|
||||
inline void HepLorentzVector::setPhi(double a) { pp.setPhi(a); }
|
||||
inline void HepLorentzVector::setRho(double a) { pp.setMag(a); }
|
||||
|
||||
double & HepLorentzVector::operator [] (int i) { return (*this)(i); }
|
||||
double HepLorentzVector::operator [] (int i) const { return (*this)(i); }
|
||||
|
||||
inline HepLorentzVector &
|
||||
HepLorentzVector::operator = (const HepLorentzVector & q) {
|
||||
pp = q.vect();
|
||||
ee = q.t();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepLorentzVector
|
||||
HepLorentzVector::operator + (const HepLorentzVector & q) const {
|
||||
return HepLorentzVector(x()+q.x(), y()+q.y(), z()+q.z(), t()+q.t());
|
||||
}
|
||||
|
||||
inline HepLorentzVector &
|
||||
HepLorentzVector::operator += (const HepLorentzVector & q) {
|
||||
pp += q.vect();
|
||||
ee += q.t();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepLorentzVector
|
||||
HepLorentzVector::operator - (const HepLorentzVector & q) const {
|
||||
return HepLorentzVector(x()-q.x(), y()-q.y(), z()-q.z(), t()-q.t());
|
||||
}
|
||||
|
||||
inline HepLorentzVector &
|
||||
HepLorentzVector::operator -= (const HepLorentzVector & q) {
|
||||
pp -= q.vect();
|
||||
ee -= q.t();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepLorentzVector::operator - () const {
|
||||
return HepLorentzVector(-x(), -y(), -z(), -t());
|
||||
}
|
||||
|
||||
inline HepLorentzVector& HepLorentzVector::operator *= (double a) {
|
||||
pp *= a;
|
||||
ee *= a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool
|
||||
HepLorentzVector::operator == (const HepLorentzVector & q) const {
|
||||
return (vect()==q.vect() && t()==q.t());
|
||||
}
|
||||
|
||||
inline bool
|
||||
HepLorentzVector::operator != (const HepLorentzVector & q) const {
|
||||
return (vect()!=q.vect() || t()!=q.t());
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::perp2() const { return pp.perp2(); }
|
||||
inline double HepLorentzVector::perp() const { return pp.perp(); }
|
||||
inline void HepLorentzVector::setPerp(double a) { pp.setPerp(a); }
|
||||
|
||||
inline double HepLorentzVector::perp2(const Hep3Vector &v) const {
|
||||
return pp.perp2(v);
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::perp(const Hep3Vector &v) const {
|
||||
return pp.perp(v);
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::angle(const Hep3Vector &v) const {
|
||||
return pp.angle(v);
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::mag2() const {
|
||||
return metric*(t()*t() - pp.mag2());
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::mag() const {
|
||||
double mm = m2();
|
||||
return mm < 0.0 ? -std::sqrt(-mm) : std::sqrt(mm);
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::m2() const {
|
||||
return t()*t() - pp.mag2();
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::m() const { return mag(); }
|
||||
|
||||
inline double HepLorentzVector::mt2() const {
|
||||
return e()*e() - pz()*pz();
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::mt() const {
|
||||
double mm = mt2();
|
||||
return mm < 0.0 ? -std::sqrt(-mm) : std::sqrt(mm);
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::et2() const {
|
||||
double pt2 = pp.perp2();
|
||||
return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+z()*z());
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::et() const {
|
||||
double etet = et2();
|
||||
return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::et2(const Hep3Vector & v) const {
|
||||
double pt2 = pp.perp2(v);
|
||||
double pv = pp.dot(v.unit());
|
||||
return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+pv*pv);
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::et(const Hep3Vector & v) const {
|
||||
double etet = et2(v);
|
||||
return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
|
||||
}
|
||||
|
||||
inline void
|
||||
HepLorentzVector::setVectMag(const Hep3Vector & spatial, double magnitude) {
|
||||
setVect(spatial);
|
||||
setT(std::sqrt(magnitude * magnitude + spatial * spatial));
|
||||
}
|
||||
|
||||
inline void
|
||||
HepLorentzVector::setVectM(const Hep3Vector & spatial, double mass) {
|
||||
setVectMag(spatial, mass);
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::dot(const HepLorentzVector & q) const {
|
||||
return metric*(t()*q.t() - z()*q.z() - y()*q.y() - x()*q.x());
|
||||
}
|
||||
|
||||
inline double
|
||||
HepLorentzVector::operator * (const HepLorentzVector & q) const {
|
||||
return dot(q);
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::plus() const {
|
||||
return t() + z();
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::minus() const {
|
||||
return t() - z();
|
||||
}
|
||||
|
||||
inline HepLorentzVector & HepLorentzVector::boost(const Hep3Vector & b) {
|
||||
return boost(b.x(), b.y(), b.z());
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::pseudoRapidity() const {
|
||||
return pp.pseudoRapidity();
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::eta() const {
|
||||
return pp.pseudoRapidity();
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::eta( const Hep3Vector & ref ) const {
|
||||
return pp.eta( ref );
|
||||
}
|
||||
|
||||
inline HepLorentzVector &
|
||||
HepLorentzVector::operator *= (const HepRotation & m) {
|
||||
pp.transform(m);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepLorentzVector &
|
||||
HepLorentzVector::transform(const HepRotation & m) {
|
||||
pp.transform(m);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepLorentzVector operator * (const HepLorentzVector & p, double a) {
|
||||
return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
|
||||
}
|
||||
|
||||
inline HepLorentzVector operator * (double a, const HepLorentzVector & p) {
|
||||
return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
|
||||
}
|
||||
|
||||
// The following were added when ZOOM PhysicsVectors was merged in:
|
||||
|
||||
inline HepLorentzVector::HepLorentzVector(
|
||||
double x, double y, double z, Tcomponent t ) :
|
||||
pp(x, y, z), ee(t) {}
|
||||
|
||||
inline void HepLorentzVector::set(
|
||||
double x, double y, double z, Tcomponent t ) {
|
||||
pp.set(x,y,z);
|
||||
ee = t;
|
||||
}
|
||||
|
||||
inline void HepLorentzVector::set(
|
||||
double x, double y, double z, double t ) {
|
||||
set (x,y,z,Tcomponent(t));
|
||||
}
|
||||
|
||||
inline HepLorentzVector::HepLorentzVector(
|
||||
Tcomponent t, double x, double y, double z ) :
|
||||
pp(x, y, z), ee(t) {}
|
||||
|
||||
inline void HepLorentzVector::set(
|
||||
Tcomponent t, double x, double y, double z ) {
|
||||
pp.set(x,y,z);
|
||||
ee = t;
|
||||
}
|
||||
|
||||
inline void HepLorentzVector::set( Tcomponent t ) {
|
||||
pp.set(0, 0, 0);
|
||||
ee = t;
|
||||
}
|
||||
|
||||
inline void HepLorentzVector::set( double t ) {
|
||||
pp.set(0, 0, 0);
|
||||
ee = t;
|
||||
}
|
||||
|
||||
inline HepLorentzVector::HepLorentzVector( Tcomponent t ) :
|
||||
pp(0, 0, 0), ee(t) {}
|
||||
|
||||
inline void HepLorentzVector::set( const Hep3Vector & v ) {
|
||||
pp = v;
|
||||
ee = 0;
|
||||
}
|
||||
|
||||
inline HepLorentzVector::HepLorentzVector( const Hep3Vector & v ) :
|
||||
pp(v), ee(0) {}
|
||||
|
||||
inline void HepLorentzVector::setV(const Hep3Vector & v) {
|
||||
pp = v;
|
||||
}
|
||||
|
||||
inline HepLorentzVector & HepLorentzVector::operator=(const Hep3Vector & v) {
|
||||
pp = v;
|
||||
ee = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::getX() const { return pp.x(); }
|
||||
inline double HepLorentzVector::getY() const { return pp.y(); }
|
||||
inline double HepLorentzVector::getZ() const { return pp.z(); }
|
||||
inline double HepLorentzVector::getT() const { return ee; }
|
||||
|
||||
inline Hep3Vector HepLorentzVector::getV() const { return pp; }
|
||||
inline Hep3Vector HepLorentzVector::v() const { return pp; }
|
||||
|
||||
inline void HepLorentzVector::set(double t, const Hep3Vector & v) {
|
||||
pp = v;
|
||||
ee = t;
|
||||
}
|
||||
|
||||
inline void HepLorentzVector::set(const Hep3Vector & v, double t) {
|
||||
pp = v;
|
||||
ee = t;
|
||||
}
|
||||
|
||||
inline void HepLorentzVector::setV( double x,
|
||||
double y,
|
||||
double z ) { pp.set(x, y, z); }
|
||||
|
||||
inline void HepLorentzVector::setRThetaPhi
|
||||
( double r, double theta, double phi )
|
||||
{ pp.setRThetaPhi( r, theta, phi ); }
|
||||
|
||||
inline void HepLorentzVector::setREtaPhi
|
||||
( double r, double eta, double phi )
|
||||
{ pp.setREtaPhi( r, eta, phi ); }
|
||||
|
||||
inline void HepLorentzVector::setRhoPhiZ
|
||||
( double rho, double phi, double z )
|
||||
{ pp.setRhoPhiZ ( rho, phi, z ); }
|
||||
|
||||
inline bool HepLorentzVector::isTimelike() const {
|
||||
return restMass2() > 0;
|
||||
}
|
||||
|
||||
inline bool HepLorentzVector::isSpacelike() const {
|
||||
return restMass2() < 0;
|
||||
}
|
||||
|
||||
inline bool HepLorentzVector::isLightlike(double epsilon) const {
|
||||
return std::fabs(restMass2()) < 2.0 * epsilon * ee * ee;
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::diff2( const HepLorentzVector & w ) const {
|
||||
return metric*( (ee-w.ee)*(ee-w.ee) - (pp-w.pp).mag2() );
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::delta2Euclidean
|
||||
( const HepLorentzVector & w ) const {
|
||||
return (ee-w.ee)*(ee-w.ee) + (pp-w.pp).mag2();
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::euclideanNorm2() const {
|
||||
return ee*ee + pp.mag2();
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::euclideanNorm() const {
|
||||
return std::sqrt(euclideanNorm2());
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::restMass2() const { return m2(); }
|
||||
inline double HepLorentzVector::invariantMass2() const { return m2(); }
|
||||
|
||||
inline double HepLorentzVector::restMass() const {
|
||||
// if( t() < 0.0 )
|
||||
// std::cerr << "HepLorentzVector::restMass() - "
|
||||
// << "E^2-p^2 < 0 for this particle. Magnitude returned."
|
||||
// << std::endl;
|
||||
return t() < 0.0 ? -m() : m();
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::invariantMass() const {
|
||||
// if( t() < 0.0 )
|
||||
// std::cerr << "HepLorentzVector::invariantMass() - "
|
||||
// << "E^2-p^2 < 0 for this particle. Magnitude returned."
|
||||
// << std::endl;
|
||||
return t() < 0.0 ? -m() : m();
|
||||
}
|
||||
|
||||
inline double HepLorentzVector::invariantMass2
|
||||
(const HepLorentzVector & w) const {
|
||||
return (*this + w).m2();
|
||||
} /* invariantMass2 */
|
||||
|
||||
//-*********
|
||||
// boostOf()
|
||||
//-*********
|
||||
|
||||
// Each of these is a shell over a boost method.
|
||||
|
||||
inline HepLorentzVector boostXOf
|
||||
(const HepLorentzVector & vec, double beta) {
|
||||
HepLorentzVector vv (vec);
|
||||
return vv.boostX (beta);
|
||||
}
|
||||
|
||||
inline HepLorentzVector boostYOf
|
||||
(const HepLorentzVector & vec, double beta) {
|
||||
HepLorentzVector vv (vec);
|
||||
return vv.boostY (beta);
|
||||
}
|
||||
|
||||
inline HepLorentzVector boostZOf
|
||||
(const HepLorentzVector & vec, double beta) {
|
||||
HepLorentzVector vv (vec);
|
||||
return vv.boostZ (beta);
|
||||
}
|
||||
|
||||
inline HepLorentzVector boostOf
|
||||
(const HepLorentzVector & vec, const Hep3Vector & betaVector ) {
|
||||
HepLorentzVector vv (vec);
|
||||
return vv.boost (betaVector);
|
||||
}
|
||||
|
||||
inline HepLorentzVector boostOf
|
||||
(const HepLorentzVector & vec, const Hep3Vector & axis, double beta) {
|
||||
HepLorentzVector vv (vec);
|
||||
return vv.boost (axis, beta);
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,417 @@
|
||||
// -*- C++ -*-
|
||||
// CLASSDOC OFF
|
||||
// $Id:$
|
||||
// ---------------------------------------------------------------------------
|
||||
// CLASSDOC ON
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definition of the HepRotation class for performing rotations
|
||||
// on objects of the Hep3Vector (and HepLorentzVector) class.
|
||||
//
|
||||
// HepRotation is a concrete implementation of Hep3RotationInterface.
|
||||
//
|
||||
// .SS See Also
|
||||
// RotationInterfaces.h
|
||||
// ThreeVector.h, LorentzVector.h, LorentzRotation.h
|
||||
//
|
||||
// .SS Author
|
||||
// Leif Lonnblad, Mark Fischler
|
||||
|
||||
#ifndef HEP_ROTATION_H
|
||||
#define HEP_ROTATION_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "CLHEP/Vector/RotationInterfaces.h"
|
||||
#include "CLHEP/Vector/RotationX.h"
|
||||
#include "CLHEP/Vector/RotationY.h"
|
||||
#include "CLHEP/Vector/RotationZ.h"
|
||||
#include "CLHEP/Vector/LorentzVector.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Declarations of classes and global methods
|
||||
class HepRotation;
|
||||
inline HepRotation inverseOf ( const HepRotation & r );
|
||||
inline HepRotation operator * (const HepRotationX & rx, const HepRotation & r);
|
||||
inline HepRotation operator * (const HepRotationY & ry, const HepRotation & r);
|
||||
inline HepRotation operator * (const HepRotationZ & rz, const HepRotation & r);
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepRotation {
|
||||
|
||||
public:
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepRotation();
|
||||
// Default constructor. Gives a unit matrix.
|
||||
|
||||
inline HepRotation(const HepRotation & m);
|
||||
// Copy constructor.
|
||||
|
||||
inline HepRotation(const HepRotationX & m);
|
||||
inline HepRotation(const HepRotationY & m);
|
||||
inline HepRotation(const HepRotationZ & m);
|
||||
// Construct from specialized rotation.
|
||||
|
||||
HepRotation & set( const Hep3Vector & axis, double delta );
|
||||
HepRotation ( const Hep3Vector & axis, double delta );
|
||||
// Construct from axis and angle.
|
||||
|
||||
HepRotation & set( const HepAxisAngle & ax );
|
||||
HepRotation ( const HepAxisAngle & ax );
|
||||
// Construct from AxisAngle structure.
|
||||
|
||||
HepRotation & set( double phi, double theta, double psi );
|
||||
HepRotation ( double phi, double theta, double psi );
|
||||
// Construct from three Euler angles (in radians).
|
||||
|
||||
HepRotation & set( const HepEulerAngles & e );
|
||||
HepRotation ( const HepEulerAngles & e );
|
||||
// Construct from EulerAngles structure.
|
||||
|
||||
HepRotation ( const Hep3Vector & colX,
|
||||
const Hep3Vector & colY,
|
||||
const Hep3Vector & colZ );
|
||||
// Construct from three *orthogonal* unit vector columns.
|
||||
// NOTE:
|
||||
// This constructor, and the two set methods below,
|
||||
// will check that the columns (or rows) form an orthonormal
|
||||
// matrix, and will adjust values so that this relation is
|
||||
// as exact as possible.
|
||||
|
||||
HepRotation & set( const Hep3Vector & colX,
|
||||
const Hep3Vector & colY,
|
||||
const Hep3Vector & colZ );
|
||||
// supply three *orthogonal* unit vectors for the columns.
|
||||
|
||||
HepRotation & setRows( const Hep3Vector & rowX,
|
||||
const Hep3Vector & rowY,
|
||||
const Hep3Vector & rowZ );
|
||||
// supply three *orthogonal* unit vectors for the rows.
|
||||
|
||||
inline HepRotation & set(const HepRotationX & r);
|
||||
inline HepRotation & set(const HepRotationY & r);
|
||||
inline HepRotation & set(const HepRotationZ & r);
|
||||
// set from specialized rotation.
|
||||
|
||||
inline HepRotation & operator = (const HepRotation & r);
|
||||
// Assignment.
|
||||
|
||||
inline HepRotation & operator = (const HepRotationX & r);
|
||||
inline HepRotation & operator = (const HepRotationY & r);
|
||||
inline HepRotation & operator = (const HepRotationZ & r);
|
||||
// Assignment from specialized rotation.
|
||||
|
||||
inline HepRotation &set( const HepRep3x3 & m );
|
||||
inline HepRotation ( const HepRep3x3 & m );
|
||||
// WARNING - NO CHECKING IS DONE!
|
||||
// Constructon directly from from a 3x3 representation,
|
||||
// which is required to be an orthogonal matrix.
|
||||
|
||||
inline ~HepRotation();
|
||||
// Trivial destructor.
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline Hep3Vector colX() const;
|
||||
inline Hep3Vector colY() const;
|
||||
inline Hep3Vector colZ() const;
|
||||
// orthogonal unit-length column vectors
|
||||
|
||||
inline Hep3Vector rowX() const;
|
||||
inline Hep3Vector rowY() const;
|
||||
inline Hep3Vector rowZ() const;
|
||||
// orthogonal unit-length row vectors
|
||||
|
||||
inline double xx() const;
|
||||
inline double xy() const;
|
||||
inline double xz() const;
|
||||
inline double yx() const;
|
||||
inline double yy() const;
|
||||
inline double yz() const;
|
||||
inline double zx() const;
|
||||
inline double zy() const;
|
||||
inline double zz() const;
|
||||
// Elements of the rotation matrix (Geant4).
|
||||
|
||||
inline HepRep3x3 rep3x3() const;
|
||||
// 3x3 representation:
|
||||
|
||||
// ------------ Subscripting:
|
||||
|
||||
class HepRotation_row {
|
||||
public:
|
||||
inline HepRotation_row(const HepRotation &, int);
|
||||
inline double operator [] (int) const;
|
||||
private:
|
||||
const HepRotation & rr;
|
||||
int ii;
|
||||
};
|
||||
// Helper class for implemention of C-style subscripting r[i][j]
|
||||
|
||||
inline const HepRotation_row operator [] (int) const;
|
||||
// Returns object of the helper class for C-style subscripting r[i][j]
|
||||
// i and j range from 0 to 2.
|
||||
|
||||
double operator () (int, int) const;
|
||||
// Fortran-style subscripting: returns (i,j) element of the rotation matrix.
|
||||
// Note: i and j still range from 0 to 2. [Rotation.cc]
|
||||
|
||||
// ------------ Euler angles:
|
||||
inline double getPhi () const;
|
||||
inline double getTheta() const;
|
||||
inline double getPsi () const;
|
||||
double phi () const;
|
||||
double theta() const;
|
||||
double psi () const;
|
||||
HepEulerAngles eulerAngles() const;
|
||||
|
||||
// ------------ axis & angle of rotation:
|
||||
inline double getDelta() const;
|
||||
inline Hep3Vector getAxis () const;
|
||||
double delta() const;
|
||||
Hep3Vector axis () const;
|
||||
HepAxisAngle axisAngle() const;
|
||||
void getAngleAxis(double & delta, Hep3Vector & axis) const;
|
||||
// Returns the rotation angle and rotation axis (Geant4). [Rotation.cc]
|
||||
|
||||
// ------------- Angles of rotated axes
|
||||
double phiX() const;
|
||||
double phiY() const;
|
||||
double phiZ() const;
|
||||
double thetaX() const;
|
||||
double thetaY() const;
|
||||
double thetaZ() const;
|
||||
// Return angles (RADS) made by rotated axes against original axes (Geant4).
|
||||
// [Rotation.cc]
|
||||
|
||||
// ---------- Other accessors treating pure rotation as a 4-rotation
|
||||
|
||||
inline HepLorentzVector col1() const;
|
||||
inline HepLorentzVector col2() const;
|
||||
inline HepLorentzVector col3() const;
|
||||
// orthosymplectic 4-vector columns - T component will be zero
|
||||
|
||||
inline HepLorentzVector col4() const;
|
||||
// Will be (0,0,0,1) for this pure Rotation.
|
||||
|
||||
inline HepLorentzVector row1() const;
|
||||
inline HepLorentzVector row2() const;
|
||||
inline HepLorentzVector row3() const;
|
||||
// orthosymplectic 4-vector rows - T component will be zero
|
||||
|
||||
inline HepLorentzVector row4() const;
|
||||
// Will be (0,0,0,1) for this pure Rotation.
|
||||
|
||||
inline double xt() const;
|
||||
inline double yt() const;
|
||||
inline double zt() const;
|
||||
inline double tx() const;
|
||||
inline double ty() const;
|
||||
inline double tz() const;
|
||||
// Will be zero for this pure Rotation
|
||||
|
||||
inline double tt() const;
|
||||
// Will be one for this pure Rotation
|
||||
|
||||
inline HepRep4x4 rep4x4() const;
|
||||
// 4x4 representation.
|
||||
|
||||
// --------- Mutators
|
||||
|
||||
void setPhi (double phi);
|
||||
// change Euler angle phi, leaving theta and psi unchanged.
|
||||
|
||||
void setTheta (double theta);
|
||||
// change Euler angle theta, leaving phi and psi unchanged.
|
||||
|
||||
void setPsi (double psi);
|
||||
// change Euler angle psi, leaving theta and phi unchanged.
|
||||
|
||||
void setAxis (const Hep3Vector & axis);
|
||||
// change rotation axis, leaving delta unchanged.
|
||||
|
||||
void setDelta (double delta);
|
||||
// change angle of rotation, leaving rotation axis unchanged.
|
||||
|
||||
// ---------- Decomposition:
|
||||
|
||||
void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
|
||||
void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
|
||||
// These are trivial, as the boost vector is 0. [RotationP.cc]
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
bool isIdentity() const;
|
||||
// Returns true if the identity matrix (Geant4). [Rotation.cc]
|
||||
|
||||
int compare( const HepRotation & r ) const;
|
||||
// Dictionary-order comparison, in order zz, zy, zx, yz, ... xx
|
||||
// Used in operator<, >, <=, >=
|
||||
|
||||
inline bool operator== ( const HepRotation & r ) const;
|
||||
inline bool operator!= ( const HepRotation & r ) const;
|
||||
inline bool operator< ( const HepRotation & r ) const;
|
||||
inline bool operator> ( const HepRotation & r ) const;
|
||||
inline bool operator<= ( const HepRotation & r ) const;
|
||||
inline bool operator>= ( const HepRotation & r ) const;
|
||||
|
||||
double distance2( const HepRotation & r ) const;
|
||||
// 3 - Tr ( this/r ) -- This works with RotationX, Y or Z also
|
||||
|
||||
double howNear( const HepRotation & r ) const;
|
||||
bool isNear( const HepRotation & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
double distance2( const HepBoost & lt ) const;
|
||||
// 3 - Tr ( this ) + |b|^2 / (1-|b|^2)
|
||||
double distance2( const HepLorentzRotation & lt ) const;
|
||||
// 3 - Tr ( this/r ) + |b|^2 / (1-|b|^2) where b is the boost vector of lt
|
||||
|
||||
double howNear( const HepBoost & lt ) const;
|
||||
double howNear( const HepLorentzRotation & lt ) const;
|
||||
bool isNear( const HepBoost & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepLorentzRotation & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
double norm2() const;
|
||||
// distance2 (IDENTITY), which is 3 - Tr ( *this )
|
||||
|
||||
void rectify();
|
||||
// non-const but logically moot correction for accumulated roundoff errors
|
||||
// rectify averages the matrix with the transpose of its actual
|
||||
// inverse (absent accumulated roundoff errors, the transpose IS
|
||||
// the inverse)); this removes to first order those errors.
|
||||
// Then it formally extracts axis and delta, and forms a true
|
||||
// HepRotation with those values of axis and delta.
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline Hep3Vector operator() (const Hep3Vector & p) const;
|
||||
// Rotate a Hep3Vector.
|
||||
|
||||
inline Hep3Vector operator * (const Hep3Vector & p) const;
|
||||
// Multiplication with a Hep3Vector.
|
||||
|
||||
inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
|
||||
// Rotate (the space part of) a HepLorentzVector.
|
||||
|
||||
inline HepLorentzVector operator* ( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a HepLorentzVector.
|
||||
|
||||
// ---------- Operations in the group of Rotations
|
||||
|
||||
inline HepRotation operator * (const HepRotation & r) const;
|
||||
// Product of two rotations (this) * r - matrix multiplication
|
||||
|
||||
inline HepRotation operator * (const HepRotationX & rx) const;
|
||||
inline HepRotation operator * (const HepRotationY & ry) const;
|
||||
inline HepRotation operator * (const HepRotationZ & rz) const;
|
||||
// Product of two rotations (this) * r - faster when specialized type
|
||||
|
||||
inline HepRotation & operator *= (const HepRotation & r);
|
||||
inline HepRotation & transform (const HepRotation & r);
|
||||
// Matrix multiplication.
|
||||
// Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a;
|
||||
|
||||
inline HepRotation & operator *= (const HepRotationX & r);
|
||||
inline HepRotation & operator *= (const HepRotationY & r);
|
||||
inline HepRotation & operator *= (const HepRotationZ & r);
|
||||
inline HepRotation & transform (const HepRotationX & r);
|
||||
inline HepRotation & transform (const HepRotationY & r);
|
||||
inline HepRotation & transform (const HepRotationZ & r);
|
||||
// Matrix multiplication by specialized matrices
|
||||
|
||||
HepRotation & rotateX(double delta);
|
||||
// Rotation around the x-axis; equivalent to R = RotationX(delta) * R
|
||||
|
||||
HepRotation & rotateY(double delta);
|
||||
// Rotation around the y-axis; equivalent to R = RotationY(delta) * R
|
||||
|
||||
HepRotation & rotateZ(double delta);
|
||||
// Rotation around the z-axis; equivalent to R = RotationZ(delta) * R
|
||||
|
||||
HepRotation & rotate(double delta, const Hep3Vector & axis);
|
||||
inline HepRotation & rotate(double delta, const Hep3Vector * axis);
|
||||
// Rotation around a specified vector.
|
||||
// r.rotate(d,a) is equivalent to r = Rotation(d,a) * r
|
||||
|
||||
HepRotation & rotateAxes(const Hep3Vector & newX,
|
||||
const Hep3Vector & newY,
|
||||
const Hep3Vector & newZ);
|
||||
// Rotation of local axes defined by 3 orthonormal vectors (Geant4).
|
||||
// Equivalent to r = Rotation (newX, newY, newZ) * r
|
||||
|
||||
inline HepRotation inverse() const;
|
||||
// Returns the inverse.
|
||||
|
||||
inline HepRotation & invert();
|
||||
// Inverts the Rotation matrix.
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
// Aligned six-digit-accurate output of the rotation matrix. [RotationIO.cc]
|
||||
|
||||
// ---------- Identity Rotation:
|
||||
|
||||
DLL_API static const HepRotation IDENTITY;
|
||||
|
||||
// ---------- Tolerance
|
||||
|
||||
static inline double getTolerance();
|
||||
static inline double setTolerance(double tol);
|
||||
|
||||
protected:
|
||||
|
||||
inline HepRotation(double mxx, double mxy, double mxz,
|
||||
double myx, double myy, double myz,
|
||||
double mzx, double mzy, double mzz);
|
||||
// Protected constructor.
|
||||
// DOES NOT CHECK FOR VALIDITY AS A ROTATION.
|
||||
|
||||
friend HepRotation operator* (const HepRotationX & rx, const HepRotation & r);
|
||||
friend HepRotation operator* (const HepRotationY & ry, const HepRotation & r);
|
||||
friend HepRotation operator* (const HepRotationZ & rz, const HepRotation & r);
|
||||
|
||||
double rxx, rxy, rxz,
|
||||
ryx, ryy, ryz,
|
||||
rzx, rzy, rzz;
|
||||
// The matrix elements.
|
||||
|
||||
private:
|
||||
bool
|
||||
setCols ( const Hep3Vector & u1, // Vectors assume to be of unit length
|
||||
const Hep3Vector & u2,
|
||||
const Hep3Vector & u3,
|
||||
double u1u2,
|
||||
Hep3Vector & v1, // Returned vectors
|
||||
Hep3Vector & v2,
|
||||
Hep3Vector & v3 ) const;
|
||||
void setArbitrarily (const Hep3Vector & colX, // assumed to be of unit length
|
||||
Hep3Vector & v1,
|
||||
Hep3Vector & v2,
|
||||
Hep3Vector & v3) const;
|
||||
}; // HepRotation
|
||||
|
||||
inline
|
||||
std::ostream & operator <<
|
||||
( std::ostream & os, const HepRotation & r ) {return r.print(os);}
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/Rotation.icc"
|
||||
|
||||
#endif /* HEP_ROTATION_H */
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
// -*- C++ -*-
|
||||
// $Id:$
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// HepRotation class
|
||||
//
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Put commonly used accessors as early as possible to avoid inlining misses:
|
||||
|
||||
inline double HepRotation::xx() const { return rxx; }
|
||||
inline double HepRotation::xy() const { return rxy; }
|
||||
inline double HepRotation::xz() const { return rxz; }
|
||||
inline double HepRotation::yx() const { return ryx; }
|
||||
inline double HepRotation::yy() const { return ryy; }
|
||||
inline double HepRotation::yz() const { return ryz; }
|
||||
inline double HepRotation::zx() const { return rzx; }
|
||||
inline double HepRotation::zy() const { return rzy; }
|
||||
inline double HepRotation::zz() const { return rzz; }
|
||||
|
||||
inline HepRep3x3 HepRotation::rep3x3() const {
|
||||
return HepRep3x3 ( rxx, rxy, rxz,
|
||||
ryx, ryy, ryz,
|
||||
rzx, rzy, rzz );
|
||||
}
|
||||
|
||||
inline double HepRotation::xt() const { return 0.0; }
|
||||
inline double HepRotation::yt() const { return 0.0; }
|
||||
inline double HepRotation::zt() const { return 0.0; }
|
||||
inline double HepRotation::tx() const { return 0.0; }
|
||||
inline double HepRotation::ty() const { return 0.0; }
|
||||
inline double HepRotation::tz() const { return 0.0; }
|
||||
inline double HepRotation::tt() const { return 1.0; }
|
||||
|
||||
inline HepRep4x4 HepRotation::rep4x4() const {
|
||||
return HepRep4x4 ( rxx, rxy, rxz, 0.0,
|
||||
ryx, ryy, ryz, 0.0,
|
||||
rzx, rzy, rzz, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
// Ctors etc:
|
||||
|
||||
inline HepRotation::HepRotation() : rxx(1.0), rxy(0.0), rxz(0.0),
|
||||
ryx(0.0), ryy(1.0), ryz(0.0),
|
||||
rzx(0.0), rzy(0.0), rzz(1.0) {}
|
||||
|
||||
inline HepRotation::HepRotation(const HepRotation & m) :
|
||||
rxx(m.rxx), rxy(m.rxy), rxz(m.rxz),
|
||||
ryx(m.ryx), ryy(m.ryy), ryz(m.ryz),
|
||||
rzx(m.rzx), rzy(m.rzy), rzz(m.rzz) {}
|
||||
|
||||
inline HepRotation::HepRotation
|
||||
(double mxx, double mxy, double mxz,
|
||||
double myx, double myy, double myz,
|
||||
double mzx, double mzy, double mzz) :
|
||||
rxx(mxx), rxy(mxy), rxz(mxz),
|
||||
ryx(myx), ryy(myy), ryz(myz),
|
||||
rzx(mzx), rzy(mzy), rzz(mzz) {}
|
||||
|
||||
inline HepRotation::HepRotation ( const HepRep3x3 & m ) :
|
||||
rxx(m.xx_), rxy(m.xy_), rxz(m.xz_),
|
||||
ryx(m.yx_), ryy(m.yy_), ryz(m.yz_),
|
||||
rzx(m.zx_), rzy(m.zy_), rzz(m.zz_) {}
|
||||
|
||||
inline HepRotation::HepRotation(const HepRotationX & rx) :
|
||||
rxx(1.0), rxy(0.0), rxz(0.0),
|
||||
ryx(0.0), ryy(rx.yy()), ryz(rx.yz()),
|
||||
rzx(0.0), rzy(rx.zy()), rzz(rx.zz()) {}
|
||||
|
||||
inline HepRotation::HepRotation(const HepRotationY & ry) :
|
||||
rxx(ry.xx()), rxy(0.0), rxz(ry.xz()),
|
||||
ryx(0.0), ryy(1.0), ryz(0.0),
|
||||
rzx(ry.zx()), rzy(0.0), rzz(ry.zz()) {}
|
||||
|
||||
inline HepRotation::HepRotation(const HepRotationZ & rz) :
|
||||
rxx(rz.xx()), rxy(rz.xy()), rxz(0.0),
|
||||
ryx(rz.yx()), ryy(rz.yy()), ryz(0.0),
|
||||
rzx(0.0), rzy(0.0), rzz(1.0) {}
|
||||
|
||||
inline HepRotation::~HepRotation() {}
|
||||
|
||||
// More accessors:
|
||||
|
||||
inline HepRotation::HepRotation_row::HepRotation_row
|
||||
(const HepRotation & r, int i) : rr(r), ii(i) {}
|
||||
|
||||
inline double HepRotation::HepRotation_row::operator [] (int jj) const {
|
||||
return rr(ii,jj);
|
||||
}
|
||||
|
||||
inline
|
||||
const HepRotation::HepRotation_row HepRotation::operator [] (int i) const {
|
||||
return HepRotation_row(*this, i);
|
||||
}
|
||||
|
||||
inline Hep3Vector HepRotation::colX() const
|
||||
{ return Hep3Vector ( rxx, ryx, rzx ); }
|
||||
inline Hep3Vector HepRotation::colY() const
|
||||
{ return Hep3Vector ( rxy, ryy, rzy ); }
|
||||
inline Hep3Vector HepRotation::colZ() const
|
||||
{ return Hep3Vector ( rxz, ryz, rzz ); }
|
||||
|
||||
inline Hep3Vector HepRotation::rowX() const
|
||||
{ return Hep3Vector ( rxx, rxy, rxz ); }
|
||||
inline Hep3Vector HepRotation::rowY() const
|
||||
{ return Hep3Vector ( ryx, ryy, ryz ); }
|
||||
inline Hep3Vector HepRotation::rowZ() const
|
||||
{ return Hep3Vector ( rzx, rzy, rzz ); }
|
||||
|
||||
inline HepLorentzVector HepRotation::col1() const
|
||||
{ return HepLorentzVector (colX(), 0); }
|
||||
inline HepLorentzVector HepRotation::col2() const
|
||||
{ return HepLorentzVector (colY(), 0); }
|
||||
inline HepLorentzVector HepRotation::col3() const
|
||||
{ return HepLorentzVector (colZ(), 0); }
|
||||
inline HepLorentzVector HepRotation::col4() const
|
||||
{ return HepLorentzVector (0,0,0,1); }
|
||||
inline HepLorentzVector HepRotation::row1() const
|
||||
{ return HepLorentzVector (rowX(), 0); }
|
||||
inline HepLorentzVector HepRotation::row2() const
|
||||
{ return HepLorentzVector (rowY(), 0); }
|
||||
inline HepLorentzVector HepRotation::row3() const
|
||||
{ return HepLorentzVector (rowZ(), 0); }
|
||||
inline HepLorentzVector HepRotation::row4() const
|
||||
{ return HepLorentzVector (0,0,0,1); }
|
||||
|
||||
inline double HepRotation::getPhi () const { return phi(); }
|
||||
inline double HepRotation::getTheta() const { return theta(); }
|
||||
inline double HepRotation::getPsi () const { return psi(); }
|
||||
inline double HepRotation::getDelta() const { return delta(); }
|
||||
inline Hep3Vector HepRotation::getAxis () const { return axis(); }
|
||||
|
||||
inline HepRotation & HepRotation::operator = (const HepRotation & m) {
|
||||
rxx = m.rxx;
|
||||
rxy = m.rxy;
|
||||
rxz = m.rxz;
|
||||
ryx = m.ryx;
|
||||
ryy = m.ryy;
|
||||
ryz = m.ryz;
|
||||
rzx = m.rzx;
|
||||
rzy = m.rzy;
|
||||
rzz = m.rzz;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepRotation & HepRotation::set(const HepRep3x3 & m) {
|
||||
rxx = m.xx_;
|
||||
rxy = m.xy_;
|
||||
rxz = m.xz_;
|
||||
ryx = m.yx_;
|
||||
ryy = m.yy_;
|
||||
ryz = m.yz_;
|
||||
rzx = m.zx_;
|
||||
rzy = m.zy_;
|
||||
rzz = m.zz_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepRotation & HepRotation::set(const HepRotationX & r) {
|
||||
return (set (r.rep3x3()));
|
||||
}
|
||||
inline HepRotation & HepRotation::set(const HepRotationY & r) {
|
||||
return (set (r.rep3x3()));
|
||||
}
|
||||
inline HepRotation & HepRotation::set(const HepRotationZ & r) {
|
||||
return (set (r.rep3x3()));
|
||||
}
|
||||
|
||||
inline HepRotation & HepRotation::operator= (const HepRotationX & r) {
|
||||
return (set (r.rep3x3()));
|
||||
}
|
||||
inline HepRotation & HepRotation::operator= (const HepRotationY & r) {
|
||||
return (set (r.rep3x3()));
|
||||
}
|
||||
inline HepRotation & HepRotation::operator= (const HepRotationZ & r) {
|
||||
return (set (r.rep3x3()));
|
||||
}
|
||||
|
||||
inline Hep3Vector HepRotation::operator * (const Hep3Vector & p) const {
|
||||
return Hep3Vector(rxx*p.x() + rxy*p.y() + rxz*p.z(),
|
||||
ryx*p.x() + ryy*p.y() + ryz*p.z(),
|
||||
rzx*p.x() + rzy*p.y() + rzz*p.z());
|
||||
// This is identical to the code in the CLHEP 1.6 version
|
||||
}
|
||||
|
||||
inline Hep3Vector HepRotation::operator () (const Hep3Vector & p) const {
|
||||
register double x = p.x();
|
||||
register double y = p.y();
|
||||
register double z = p.z();
|
||||
return Hep3Vector(rxx*x + rxy*y + rxz*z,
|
||||
ryx*x + ryy*y + ryz*z,
|
||||
rzx*x + rzy*y + rzz*z);
|
||||
}
|
||||
|
||||
inline HepLorentzVector
|
||||
HepRotation::operator () (const HepLorentzVector & w) const {
|
||||
return HepLorentzVector( operator() (w.vect()), w.t() );
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepRotation::operator *
|
||||
(const HepLorentzVector & p) const {
|
||||
return operator()(p);
|
||||
}
|
||||
|
||||
inline HepRotation HepRotation::operator* (const HepRotation & r) const {
|
||||
return HepRotation(rxx*r.rxx + rxy*r.ryx + rxz*r.rzx,
|
||||
rxx*r.rxy + rxy*r.ryy + rxz*r.rzy,
|
||||
rxx*r.rxz + rxy*r.ryz + rxz*r.rzz,
|
||||
ryx*r.rxx + ryy*r.ryx + ryz*r.rzx,
|
||||
ryx*r.rxy + ryy*r.ryy + ryz*r.rzy,
|
||||
ryx*r.rxz + ryy*r.ryz + ryz*r.rzz,
|
||||
rzx*r.rxx + rzy*r.ryx + rzz*r.rzx,
|
||||
rzx*r.rxy + rzy*r.ryy + rzz*r.rzy,
|
||||
rzx*r.rxz + rzy*r.ryz + rzz*r.rzz );
|
||||
}
|
||||
|
||||
inline HepRotation HepRotation::operator * (const HepRotationX & rx) const {
|
||||
double yy = rx.yy();
|
||||
double yz = rx.yz();
|
||||
double zy = -yz;
|
||||
double zz = yy;
|
||||
return HepRotation(
|
||||
rxx, rxy*yy + rxz*zy, rxy*yz + rxz*zz,
|
||||
ryx, ryy*yy + ryz*zy, ryy*yz + ryz*zz,
|
||||
rzx, rzy*yy + rzz*zy, rzy*yz + rzz*zz );
|
||||
}
|
||||
|
||||
inline HepRotation HepRotation::operator * (const HepRotationY & ry) const {
|
||||
double xx = ry.xx();
|
||||
double xz = ry.xz();
|
||||
double zx = -xz;
|
||||
double zz = xx;
|
||||
return HepRotation(
|
||||
rxx*xx + rxz*zx, rxy, rxx*xz + rxz*zz,
|
||||
ryx*xx + ryz*zx, ryy, ryx*xz + ryz*zz,
|
||||
rzx*xx + rzz*zx, rzy, rzx*xz + rzz*zz );
|
||||
}
|
||||
|
||||
inline HepRotation HepRotation::operator * (const HepRotationZ & rz) const {
|
||||
double xx = rz.xx();
|
||||
double xy = rz.xy();
|
||||
double yx = -xy;
|
||||
double yy = xx;
|
||||
return HepRotation(
|
||||
rxx*xx + rxy*yx, rxx*xy + rxy*yy, rxz,
|
||||
ryx*xx + ryy*yx, ryx*xy + ryy*yy, ryz,
|
||||
rzx*xx + rzy*yx, rzx*xy + rzy*yy, rzz );
|
||||
}
|
||||
|
||||
|
||||
inline HepRotation & HepRotation::operator *= (const HepRotation & r) {
|
||||
return *this = (*this) * (r);
|
||||
}
|
||||
|
||||
inline HepRotation & HepRotation::operator *= (const HepRotationX & r) {
|
||||
return *this = (*this) * (r); }
|
||||
inline HepRotation & HepRotation::operator *= (const HepRotationY & r) {
|
||||
return *this = (*this) * (r); }
|
||||
inline HepRotation & HepRotation::operator *= (const HepRotationZ & r) {
|
||||
return *this = (*this) * (r); }
|
||||
|
||||
inline HepRotation & HepRotation::transform(const HepRotation & r) {
|
||||
return *this = r * (*this);
|
||||
}
|
||||
|
||||
inline HepRotation & HepRotation::transform(const HepRotationX & r) {
|
||||
return *this = r * (*this); }
|
||||
inline HepRotation & HepRotation::transform(const HepRotationY & r) {
|
||||
return *this = r * (*this); }
|
||||
inline HepRotation & HepRotation::transform(const HepRotationZ & r) {
|
||||
return *this = r * (*this); }
|
||||
|
||||
inline HepRotation HepRotation::inverse() const {
|
||||
return HepRotation( rxx, ryx, rzx,
|
||||
rxy, ryy, rzy,
|
||||
rxz, ryz, rzz );
|
||||
}
|
||||
|
||||
inline HepRotation inverseOf (const HepRotation & r) {
|
||||
return r.inverse();
|
||||
}
|
||||
|
||||
inline HepRotation & HepRotation::invert() {
|
||||
return *this=inverse();
|
||||
}
|
||||
|
||||
inline HepRotation & HepRotation::rotate
|
||||
(double delta, const Hep3Vector * p) {
|
||||
return rotate(delta, *p);
|
||||
}
|
||||
|
||||
inline bool HepRotation::operator== ( const HepRotation & r ) const {
|
||||
return ( rxx==r.rxx && rxy==r.rxy && rxz==r.rxz &&
|
||||
ryx==r.ryx && ryy==r.ryy && ryz==r.ryz &&
|
||||
rzx==r.rzx && rzy==r.rzy && rzz==r.rzz );
|
||||
}
|
||||
inline bool HepRotation::operator!= ( const HepRotation & r ) const {
|
||||
return ! operator==(r);
|
||||
}
|
||||
inline bool HepRotation::operator< ( const HepRotation & r ) const
|
||||
{ return compare(r)< 0; }
|
||||
inline bool HepRotation::operator<=( const HepRotation & r ) const
|
||||
{ return compare(r)<=0; }
|
||||
inline bool HepRotation::operator>=( const HepRotation & r ) const
|
||||
{ return compare(r)>=0; }
|
||||
inline bool HepRotation::operator> ( const HepRotation & r ) const
|
||||
{ return compare(r)> 0; }
|
||||
|
||||
inline double HepRotation::getTolerance() {
|
||||
return Hep4RotationInterface::tolerance;
|
||||
}
|
||||
inline double HepRotation::setTolerance(double tol) {
|
||||
return Hep4RotationInterface::setTolerance(tol);
|
||||
}
|
||||
|
||||
inline HepRotation operator * (const HepRotationX & rx, const HepRotation & r){
|
||||
HepRep3x3 m = r.rep3x3();
|
||||
double c = rx.yy();
|
||||
double s = rx.zy();
|
||||
return HepRotation ( m.xx_, m.xy_, m.xz_,
|
||||
c*m.yx_-s*m.zx_, c*m.yy_-s*m.zy_, c*m.yz_-s*m.zz_,
|
||||
s*m.yx_+c*m.zx_, s*m.yy_+c*m.zy_, s*m.yz_+c*m.zz_ );
|
||||
}
|
||||
|
||||
inline HepRotation operator * (const HepRotationY & ry, const HepRotation & r){
|
||||
HepRep3x3 m = r.rep3x3();
|
||||
double c = ry.xx();
|
||||
double s = ry.xz();
|
||||
return HepRotation ( c*m.xx_+s*m.zx_, c*m.xy_+s*m.zy_, c*m.xz_+s*m.zz_,
|
||||
m.yx_, m.yy_, m.yz_,
|
||||
-s*m.xx_+c*m.zx_,-s*m.xy_+c*m.zy_,-s*m.xz_+c*m.zz_ );
|
||||
}
|
||||
|
||||
inline HepRotation operator * (const HepRotationZ & rz, const HepRotation & r){
|
||||
HepRep3x3 m = r.rep3x3();
|
||||
double c = rz.xx();
|
||||
double s = rz.yx();
|
||||
return HepRotation ( c*m.xx_-s*m.yx_, c*m.xy_-s*m.yy_, c*m.xz_-s*m.yz_,
|
||||
s*m.xx_+c*m.yx_, s*m.xy_+c*m.yy_, s*m.xz_+c*m.yz_,
|
||||
m.zx_, m.zy_, m.zz_ );
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,399 @@
|
||||
// -*- C++ -*-
|
||||
// CLASSDOC OFF
|
||||
// ---------------------------------------------------------------------------
|
||||
// CLASSDOC ON
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This contains the definition of two abstract interface classes:
|
||||
// Hep4RotationInterface
|
||||
// Hep3RotationInterface.
|
||||
// However, these are mostly for defining methods which should be present in
|
||||
// any 4- or 3-rotation class, however specialized. The actual classes do
|
||||
// not inherit from these. The virtual function overhead turns out
|
||||
// to be too steep for that to be practical.
|
||||
//
|
||||
// It may be desirable in the future to turn these classes into constraints
|
||||
// in the Stroustrup sense, so as to enforce this interface, still without
|
||||
// inheritance. However, they do contain an important static:
|
||||
// static double tolerance to set criteria for relative nearness.
|
||||
//
|
||||
// This file also defines structs
|
||||
// HepRep3x3;
|
||||
// HepRep4x4;
|
||||
// HepRep4x4Symmetric;
|
||||
// which are used by various Rotation classes.
|
||||
//
|
||||
// Hep4RotationInterface
|
||||
// contains all the methods to get attributes of either a
|
||||
// HepLorentzRotation or a HepRotation -- any information
|
||||
// that pertains to a LorentzRotation can also be defined
|
||||
// for a HepRotation.(For example, the 4x4 representation
|
||||
// would just have 0's in the space-time entries and 1 in
|
||||
// the time-time entry.)
|
||||
//
|
||||
// Hep3RotationInterface
|
||||
// inherits from Hep4RotationInterface, and adds methods
|
||||
// which are well-defined only in the case of a Rotation.
|
||||
// For example, a 3x3 representation is an attribute only
|
||||
// if the generic LorentzRotation involves no boost.
|
||||
//
|
||||
// In terms of classes in the ZOOM PhysicsVectors package,
|
||||
// Hep4RotationInterface <--> LorentzTransformationInterface
|
||||
// Hep3RotationInterface <--> RotationInterface
|
||||
//
|
||||
// Hep4RotationInterface defines the required methods for:
|
||||
// HepLorentzRotation
|
||||
// HepBoost
|
||||
// HepBoostX
|
||||
// HepBoostY
|
||||
// HepBoostZ
|
||||
//
|
||||
// Hep3RotationInterface defines the required methods for:
|
||||
// HepRotation
|
||||
// HepRotationX
|
||||
// HepRotationY
|
||||
// HepRotationZ
|
||||
//
|
||||
// .SS See Also
|
||||
// Rotation.h, LorentzRotation.h
|
||||
//
|
||||
// .SS Author
|
||||
// Mark Fischler
|
||||
//
|
||||
|
||||
#ifndef HEP_ROTATION_INTERFACES_H
|
||||
#define HEP_ROTATION_INTERFACES_H
|
||||
|
||||
#include "CLHEP/Vector/ThreeVector.h"
|
||||
#include "CLHEP/Vector/LorentzVector.h"
|
||||
#include "CLHEP/Vector/AxisAngle.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
struct HepRep3x3;
|
||||
struct HepRep4x4;
|
||||
struct HepRep4x4Symmetric;
|
||||
|
||||
class HepRotation;
|
||||
class HepRotationX;
|
||||
class HepRotationY;
|
||||
class HepRotationZ;
|
||||
class HepLorentzRotation;
|
||||
class HepBoost;
|
||||
class HepBoostX;
|
||||
class HepBoostY;
|
||||
class HepBoostZ;
|
||||
|
||||
//-******************************
|
||||
//
|
||||
// Hep4RotationInterface
|
||||
//
|
||||
//-******************************
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class Hep4RotationInterface {
|
||||
|
||||
// All attributes of shared by HepLorentzRotation, HepBoost,
|
||||
// HepBoostX, HepBoostY, HepBoostZ. HepRotation, HepRotationX,
|
||||
// HepRotationY, HepRotationZ also share this attribute interface.
|
||||
|
||||
friend class HepRotation;
|
||||
friend class HepRotationX;
|
||||
friend class HepRotationY;
|
||||
friend class HepRotationZ;
|
||||
friend class HepLorentzRotation;
|
||||
friend class HepBoost;
|
||||
friend class HepBoostX;
|
||||
friend class HepBoostY;
|
||||
friend class HepBoostZ;
|
||||
|
||||
public:
|
||||
|
||||
DLL_API static double tolerance; // to determine relative nearness
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
#ifdef ONLY_IN_CONCRETE_CLASSES
|
||||
// orthosymplectic 4-vectors:
|
||||
HepLorentzVector col1() const;
|
||||
HepLorentzVector col2() const;
|
||||
HepLorentzVector col3() const;
|
||||
HepLorentzVector col4() const;
|
||||
HepLorentzVector row1() const;
|
||||
HepLorentzVector row2() const;
|
||||
HepLorentzVector row3() const;
|
||||
HepLorentzVector row4() const;
|
||||
|
||||
// individual elements:
|
||||
double xx() const ;
|
||||
double xy() const ;
|
||||
double xz() const ;
|
||||
double xt() const ;
|
||||
double yx() const ;
|
||||
double yy() const ;
|
||||
double yz() const ;
|
||||
double yt() const ;
|
||||
double zx() const ;
|
||||
double zy() const ;
|
||||
double zz() const ;
|
||||
double zt() const ;
|
||||
double tx() const ;
|
||||
double ty() const ;
|
||||
double tz() const ;
|
||||
double tt() const ;
|
||||
|
||||
// 4x4 representation:
|
||||
//HepRep4x4 rep4x4() const; JMM Declared here but not defined anywhere!
|
||||
|
||||
// ---------- Operations:
|
||||
// comparisons:
|
||||
|
||||
inline int compare( const Hep4RotationInterface & lt ) const;
|
||||
// Dictionary-order comparisons, utilizing the decompose(b,r) method
|
||||
|
||||
// decomposition:
|
||||
|
||||
void decompose (HepAxisAngle & rotation, Hep3Vector & boost)const;
|
||||
// Decompose as T= R * B, where R is pure rotation, B is pure boost.
|
||||
|
||||
void decompose (Hep3Vector & boost, HepAxisAngle & rotation)const;
|
||||
// Decompose as T= B * R, where R is pure rotation, B is pure boost.
|
||||
|
||||
bool operator == (const Hep4RotationInterface & r) const;
|
||||
bool operator != (const Hep4RotationInterface & r) const;
|
||||
|
||||
// relative comparison:
|
||||
|
||||
double norm2() const ;
|
||||
double distance2( const Hep4RotationInterface & lt ) const ;
|
||||
double howNear( const Hep4RotationInterface & lt ) const ;
|
||||
bool isNear (const Hep4RotationInterface & lt,
|
||||
double epsilon=tolerance) const ;
|
||||
|
||||
void rectify() ;
|
||||
// non-const but logically const correction for accumulated roundoff errors
|
||||
|
||||
// ---------- Apply LorentzTransformations:
|
||||
|
||||
HepLorentzVector operator* ( const HepLorentzVector & w ) const ;
|
||||
HepLorentzVector operator()( const HepLorentzVector & w ) const ;
|
||||
// Apply to a 4-vector
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
|
||||
#endif /* ONLY_IN_CONCRETE_CLASSES */
|
||||
|
||||
static double getTolerance();
|
||||
static double setTolerance( double tol );
|
||||
|
||||
enum { ToleranceTicks = 100 };
|
||||
|
||||
protected:
|
||||
|
||||
~Hep4RotationInterface() {} // protect destructor to forbid instatiation
|
||||
|
||||
}; // Hep4RotationInterface
|
||||
|
||||
|
||||
//-******************************
|
||||
//
|
||||
// Hep3RotationInterface
|
||||
//
|
||||
//-******************************
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class Hep3RotationInterface : public Hep4RotationInterface {
|
||||
|
||||
// All attributes of HepRotation, HepRotationX, HepRotationY, HepRotationZ
|
||||
// beyond those available by virtue of being a Hep3RotationInterface.
|
||||
|
||||
friend class HepRotation;
|
||||
friend class HepRotationX;
|
||||
friend class HepRotationY;
|
||||
friend class HepRotationZ;
|
||||
|
||||
public:
|
||||
|
||||
#ifdef ONLY_IN_CONCRETE_CLASSES
|
||||
|
||||
// Euler angles:
|
||||
double getPhi () const ;
|
||||
double getTheta() const ;
|
||||
double getPsi () const ;
|
||||
double phi () const ;
|
||||
double theta() const ;
|
||||
double psi () const ;
|
||||
HepEulerAngles eulerAngles() const ;
|
||||
|
||||
// axis & angle of rotation:
|
||||
double getDelta() const ;
|
||||
Hep3Vector getAxis () const ;
|
||||
double delta() const ;
|
||||
Hep3Vector axis () const ;
|
||||
HepAxisAngle axisAngle() const ;
|
||||
|
||||
// orthogonal unit-length vectors:
|
||||
Hep3Vector rowX() const;
|
||||
Hep3Vector rowY() const;
|
||||
Hep3Vector rowZ() const;
|
||||
|
||||
Hep3Vector colX() const;
|
||||
Hep3Vector colY() const;
|
||||
Hep3Vector colZ() const;
|
||||
|
||||
//HepRep3x3 rep3x3() const; JMM Declared here but not defined anywhere!
|
||||
// 3x3 representation
|
||||
|
||||
// orthosymplectic 4-vectors treating this as a 4-rotation:
|
||||
HepLorentzVector col1() const;
|
||||
HepLorentzVector col2() const;
|
||||
HepLorentzVector col3() const;
|
||||
HepLorentzVector col4() const;
|
||||
HepLorentzVector row1() const;
|
||||
HepLorentzVector row2() const;
|
||||
HepLorentzVector row3() const;
|
||||
HepLorentzVector row4() const;
|
||||
|
||||
// individual elements treating this as a 4-rotation:
|
||||
double xt() const;
|
||||
double yt() const;
|
||||
double zt() const;
|
||||
double tx() const;
|
||||
double ty() const;
|
||||
double tz() const;
|
||||
double tt() const;
|
||||
|
||||
// ---------- Operations in the Rotation group
|
||||
|
||||
HepRotation operator * ( const Hep3RotationInterface & r ) const ;
|
||||
|
||||
// ---------- Application
|
||||
|
||||
HepLorentzVector operator* ( const HepLorentzVector & w ) const ;
|
||||
HepLorentzVector operator()( const HepLorentzVector & w ) const ;
|
||||
// apply to HepLorentzVector
|
||||
|
||||
Hep3Vector operator* ( const Hep3Vector & v ) const ;
|
||||
Hep3Vector operator()( const Hep3Vector & v ) const ;
|
||||
// apply to Hep3Vector
|
||||
|
||||
// ---------- I/O and a helper method
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
|
||||
#endif /* ONLY_IN_CONCRETE_CLASSES */
|
||||
|
||||
private:
|
||||
|
||||
~Hep3RotationInterface() {} // private destructor to forbid instatiation
|
||||
|
||||
}; // Hep3RotationInterface
|
||||
|
||||
//-***************************
|
||||
// 3x3 and 4x4 representations
|
||||
//-***************************
|
||||
|
||||
struct HepRep3x3 {
|
||||
|
||||
// ----- Constructors:
|
||||
|
||||
inline HepRep3x3();
|
||||
|
||||
inline HepRep3x3( double xx, double xy, double xz
|
||||
, double yx, double yy, double yz
|
||||
, double zx, double zy, double zz
|
||||
);
|
||||
|
||||
inline HepRep3x3( const double * array );
|
||||
// construct from an array of doubles, holding the rotation matrix
|
||||
// in ROW order (xx, xy, ...)
|
||||
|
||||
inline void setToIdentity();
|
||||
|
||||
// ----- The data members are public:
|
||||
double xx_, xy_, xz_,
|
||||
yx_, yy_, yz_,
|
||||
zx_, zy_, zz_;
|
||||
|
||||
inline void getArray ( double * array ) const;
|
||||
// fill array with the NINE doubles xx, xy, xz ... zz
|
||||
|
||||
}; // HepRep3x3
|
||||
|
||||
struct HepRep4x4 {
|
||||
|
||||
// ----- Constructors:
|
||||
inline HepRep4x4();
|
||||
|
||||
inline HepRep4x4( double xx, double xy, double xz, double xt
|
||||
, double yx, double yy, double yz, double yt
|
||||
, double zx, double zy, double zz, double zt
|
||||
, double tx, double ty, double tz, double tt
|
||||
);
|
||||
|
||||
inline HepRep4x4( const HepRep4x4Symmetric & rep );
|
||||
|
||||
inline HepRep4x4( const double * array );
|
||||
// construct from an array of doubles, holding the transformation matrix
|
||||
// in ROW order xx, xy, ...
|
||||
|
||||
inline void setToIdentity();
|
||||
|
||||
// ----- The data members are public:
|
||||
double xx_, xy_, xz_, xt_,
|
||||
yx_, yy_, yz_, yt_,
|
||||
zx_, zy_, zz_, zt_,
|
||||
tx_, ty_, tz_, tt_;
|
||||
|
||||
inline void getArray ( double * array ) const;
|
||||
// fill array with the SIXTEEN doubles xx, xy, xz ... tz, tt
|
||||
|
||||
inline bool operator==(HepRep4x4 const & r) const;
|
||||
inline bool operator!=(HepRep4x4 const & r) const;
|
||||
|
||||
|
||||
}; // HepRep4x4
|
||||
|
||||
struct HepRep4x4Symmetric {
|
||||
|
||||
// ----- Constructors:
|
||||
|
||||
inline HepRep4x4Symmetric();
|
||||
|
||||
inline HepRep4x4Symmetric
|
||||
( double xx, double xy, double xz, double xt
|
||||
, double yy, double yz, double yt
|
||||
, double zz, double zt
|
||||
, double tt );
|
||||
|
||||
inline HepRep4x4Symmetric( const double * array );
|
||||
// construct from an array of doubles, holding the transformation matrix
|
||||
// elements in this order: xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
|
||||
|
||||
inline void setToIdentity();
|
||||
|
||||
// ----- The data members are public:
|
||||
double xx_, xy_, xz_, xt_,
|
||||
yy_, yz_, yt_,
|
||||
zz_, zt_,
|
||||
tt_;
|
||||
|
||||
inline void getArray ( double * array ) const;
|
||||
// fill array with the TEN doubles xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
|
||||
|
||||
};
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/RotationInterfaces.icc"
|
||||
|
||||
#endif // ROTATION_INTERFACES_H
|
||||
@@ -0,0 +1,153 @@
|
||||
// -*- C++ -*-
|
||||
// $Id:$
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This contains the definitions of the inline member functions of the
|
||||
// Hep4RotationInterface and Hep3RotationInterface classes, and of the
|
||||
// HepRep3x3 and HepRep4x4 structs.
|
||||
//
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
//-*********
|
||||
// HepRep3x3
|
||||
//-*********
|
||||
|
||||
inline HepRep3x3::HepRep3x3() :
|
||||
xx_(1.0), xy_(0.0), xz_(0.0)
|
||||
, yx_(0.0), yy_(1.0), yz_(0.0)
|
||||
, zx_(0.0), zy_(0.0), zz_(1.0)
|
||||
{}
|
||||
|
||||
inline HepRep3x3::HepRep3x3( double xx, double xy, double xz
|
||||
, double yx, double yy, double yz
|
||||
, double zx, double zy, double zz
|
||||
) :
|
||||
xx_(xx), xy_(xy), xz_(xz)
|
||||
, yx_(yx), yy_(yy), yz_(yz)
|
||||
, zx_(zx), zy_(zy), zz_(zz)
|
||||
{}
|
||||
|
||||
inline HepRep3x3::HepRep3x3( const double * array ) {
|
||||
const double * a = array;
|
||||
double * r = &xx_;
|
||||
for ( int i = 0; i < 9; i++ ) { *r++ = *a++; }
|
||||
}
|
||||
|
||||
inline void HepRep3x3::setToIdentity() {
|
||||
xx_ = 1.0; xy_ = 0.0; xz_ = 0.0;
|
||||
yx_ = 0.0; yy_ = 1.0; yz_ = 0.0;
|
||||
zx_ = 0.0; zy_ = 0.0; zz_ = 1.0;
|
||||
}
|
||||
|
||||
inline void HepRep3x3::getArray( double * array ) const {
|
||||
double * a = array;
|
||||
const double * r = &xx_;
|
||||
for ( int i = 0; i < 9; i++ ) { *a++ = *r++; }
|
||||
}
|
||||
|
||||
|
||||
//-*********
|
||||
// HepRep4x4
|
||||
//-*********
|
||||
|
||||
inline HepRep4x4::HepRep4x4() :
|
||||
xx_(1.0), xy_(0.0), xz_(0.0), xt_(0.0)
|
||||
, yx_(0.0), yy_(1.0), yz_(0.0), yt_(0.0)
|
||||
, zx_(0.0), zy_(0.0), zz_(1.0), zt_(0.0)
|
||||
, tx_(0.0), ty_(0.0), tz_(0.0), tt_(1.0)
|
||||
{}
|
||||
|
||||
inline HepRep4x4::HepRep4x4(
|
||||
double xx, double xy, double xz, double xt
|
||||
, double yx, double yy, double yz, double yt
|
||||
, double zx, double zy, double zz, double zt
|
||||
, double tx, double ty, double tz, double tt
|
||||
) :
|
||||
xx_(xx), xy_(xy), xz_(xz), xt_(xt)
|
||||
, yx_(yx), yy_(yy), yz_(yz), yt_(yt)
|
||||
, zx_(zx), zy_(zy), zz_(zz), zt_(zt)
|
||||
, tx_(tx), ty_(ty), tz_(tz), tt_(tt)
|
||||
{}
|
||||
|
||||
inline HepRep4x4::HepRep4x4( const HepRep4x4Symmetric & rep ) :
|
||||
xx_(rep.xx_), xy_(rep.xy_), xz_(rep.xz_), xt_(rep.xt_)
|
||||
, yx_(rep.xy_), yy_(rep.yy_), yz_(rep.yz_), yt_(rep.yt_)
|
||||
, zx_(rep.xz_), zy_(rep.yz_), zz_(rep.zz_), zt_(rep.zt_)
|
||||
, tx_(rep.xt_), ty_(rep.yt_), tz_(rep.zt_), tt_(rep.tt_)
|
||||
{}
|
||||
|
||||
inline HepRep4x4::HepRep4x4( const double * array ) {
|
||||
const double * a = array;
|
||||
double * r = &xx_;
|
||||
for ( int i = 0; i < 16; i++ ) { *r++ = *a++; }
|
||||
}
|
||||
|
||||
inline void HepRep4x4::setToIdentity() {
|
||||
xx_ = 1.0; xy_ = 0.0; xz_ = 0.0; xt_ = 0.0;
|
||||
yx_ = 0.0; yy_ = 1.0; yz_ = 0.0; yt_ = 0.0;
|
||||
zx_ = 0.0; zy_ = 0.0; zz_ = 1.0; zt_ = 0.0;
|
||||
tx_ = 0.0; ty_ = 0.0; tz_ = 0.0; tt_ = 1.0;
|
||||
}
|
||||
|
||||
inline void HepRep4x4::getArray( double * array ) const {
|
||||
double * a = array;
|
||||
const double * r = &xx_;
|
||||
for ( int i = 0; i < 16; i++ ) { *a++ = *r++; }
|
||||
}
|
||||
|
||||
inline bool HepRep4x4::operator == (const HepRep4x4 & r) const {
|
||||
return( xx_ == r.xx_ && xy_ == r.xy_ && xz_ == r.xz_ && xt_ == r.xt_ &&
|
||||
yx_ == r.yx_ && yy_ == r.yy_ && yz_ == r.yz_ && yt_ == r.yt_ &&
|
||||
zx_ == r.zx_ && zy_ == r.zy_ && zz_ == r.zz_ && zt_ == r.zt_ &&
|
||||
tx_ == r.tx_ && ty_ == r.ty_ && tz_ == r.tz_ && tt_ == r.tt_ );
|
||||
}
|
||||
|
||||
inline bool HepRep4x4::operator != (const HepRep4x4 & r) const {
|
||||
return !(operator== (r));
|
||||
}
|
||||
|
||||
//-******************
|
||||
// HepRep4x4Symmetric
|
||||
//-******************
|
||||
|
||||
inline HepRep4x4Symmetric::HepRep4x4Symmetric() :
|
||||
xx_(1.0), xy_(0.0), xz_(0.0), xt_(0.0)
|
||||
, yy_(1.0), yz_(0.0), yt_(0.0)
|
||||
, zz_(1.0), zt_(0.0)
|
||||
, tt_(1.0)
|
||||
{}
|
||||
|
||||
inline HepRep4x4Symmetric::HepRep4x4Symmetric
|
||||
( double xx, double xy, double xz, double xt
|
||||
, double yy, double yz, double yt
|
||||
, double zz, double zt
|
||||
, double tt ) :
|
||||
xx_(xx), xy_(xy), xz_(xz), xt_(xt)
|
||||
, yy_(yy), yz_(yz), yt_(yt)
|
||||
, zz_(zz), zt_(zt)
|
||||
, tt_(tt)
|
||||
{}
|
||||
|
||||
inline HepRep4x4Symmetric::HepRep4x4Symmetric( const double * array ) {
|
||||
const double * a = array;
|
||||
double * r = &xx_;
|
||||
for ( int i = 0; i < 10; i++ ) { *r++ = *a++; }
|
||||
}
|
||||
|
||||
inline void HepRep4x4Symmetric::setToIdentity() {
|
||||
xx_ = 1.0; xy_ = 0.0; xz_ = 0.0; xt_ = 0.0;
|
||||
yy_ = 1.0; yz_ = 0.0; yt_ = 0.0;
|
||||
zz_ = 1.0; zt_ = 0.0;
|
||||
tt_ = 1.0;
|
||||
}
|
||||
|
||||
inline void HepRep4x4Symmetric::getArray( double * array ) const {
|
||||
double * a = array;
|
||||
const double * r = &xx_;
|
||||
for ( int i = 0; i < 10; i++ ) { *a++ = *r++; }
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,284 @@
|
||||
// -*- C++ -*-
|
||||
// CLASSDOC OFF
|
||||
// ---------------------------------------------------------------------------
|
||||
// CLASSDOC ON
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definition of the HepRotationX class for performing rotations
|
||||
// around the X axis on objects of the Hep3Vector (and HepLorentzVector) class.
|
||||
//
|
||||
// HepRotationX is a concrete implementation of Hep3RotationInterface.
|
||||
//
|
||||
// .SS See Also
|
||||
// RotationInterfaces.h
|
||||
// ThreeVector.h, LorentzVector.h, LorentzRotation.h
|
||||
//
|
||||
// .SS Author
|
||||
// Mark Fischler
|
||||
|
||||
#ifndef HEP_ROTATIONX_H
|
||||
#define HEP_ROTATIONX_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "CLHEP/Vector/RotationInterfaces.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
class HepRotationX;
|
||||
|
||||
class HepRotation;
|
||||
class HepBoost;
|
||||
|
||||
inline HepRotationX inverseOf(const HepRotationX & r);
|
||||
// Returns the inverse of a RotationX.
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepRotationX {
|
||||
|
||||
public:
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepRotationX();
|
||||
// Default constructor. Gives an identity rotation.
|
||||
|
||||
HepRotationX(double delta);
|
||||
// supply angle of rotation
|
||||
|
||||
inline HepRotationX(const HepRotationX & orig);
|
||||
// Copy constructor.
|
||||
|
||||
inline HepRotationX & operator = (const HepRotationX & r);
|
||||
// Assignment from a Rotation, which must be RotationX
|
||||
|
||||
HepRotationX & set ( double delta );
|
||||
// set angle of rotation
|
||||
|
||||
inline ~HepRotationX();
|
||||
// Trivial destructor.
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline Hep3Vector colX() const;
|
||||
inline Hep3Vector colY() const;
|
||||
inline Hep3Vector colZ() const;
|
||||
// orthogonal unit-length column vectors
|
||||
|
||||
inline Hep3Vector rowX() const;
|
||||
inline Hep3Vector rowY() const;
|
||||
inline Hep3Vector rowZ() const;
|
||||
// orthogonal unit-length row vectors
|
||||
|
||||
inline double xx() const;
|
||||
inline double xy() const;
|
||||
inline double xz() const;
|
||||
inline double yx() const;
|
||||
inline double yy() const;
|
||||
inline double yz() const;
|
||||
inline double zx() const;
|
||||
inline double zy() const;
|
||||
inline double zz() const;
|
||||
// Elements of the rotation matrix (Geant4).
|
||||
|
||||
inline HepRep3x3 rep3x3() const;
|
||||
// 3x3 representation:
|
||||
|
||||
// ------------ Euler angles:
|
||||
inline double getPhi () const;
|
||||
inline double getTheta() const;
|
||||
inline double getPsi () const;
|
||||
double phi () const;
|
||||
double theta() const;
|
||||
double psi () const;
|
||||
HepEulerAngles eulerAngles() const;
|
||||
|
||||
// ------------ axis & angle of rotation:
|
||||
inline double getDelta() const;
|
||||
inline Hep3Vector getAxis () const;
|
||||
inline double delta() const;
|
||||
inline Hep3Vector axis () const;
|
||||
inline HepAxisAngle axisAngle() const;
|
||||
inline void getAngleAxis(double & delta, Hep3Vector & axis) const;
|
||||
// Returns the rotation angle and rotation axis (Geant4).
|
||||
|
||||
// ------------- Angles of rotated axes
|
||||
double phiX() const;
|
||||
double phiY() const;
|
||||
double phiZ() const;
|
||||
double thetaX() const;
|
||||
double thetaY() const;
|
||||
double thetaZ() const;
|
||||
// Return angles (RADS) made by rotated axes against original axes (Geant4).
|
||||
|
||||
// ---------- Other accessors treating pure rotation as a 4-rotation
|
||||
|
||||
inline HepLorentzVector col1() const;
|
||||
inline HepLorentzVector col2() const;
|
||||
inline HepLorentzVector col3() const;
|
||||
// orthosymplectic 4-vector columns - T component will be zero
|
||||
|
||||
inline HepLorentzVector col4() const;
|
||||
// Will be (0,0,0,1) for this pure Rotation.
|
||||
|
||||
inline HepLorentzVector row1() const;
|
||||
inline HepLorentzVector row2() const;
|
||||
inline HepLorentzVector row3() const;
|
||||
// orthosymplectic 4-vector rows - T component will be zero
|
||||
|
||||
inline HepLorentzVector row4() const;
|
||||
// Will be (0,0,0,1) for this pure Rotation.
|
||||
|
||||
inline double xt() const;
|
||||
inline double yt() const;
|
||||
inline double zt() const;
|
||||
inline double tx() const;
|
||||
inline double ty() const;
|
||||
inline double tz() const;
|
||||
// Will be zero for this pure Rotation
|
||||
|
||||
inline double tt() const;
|
||||
// Will be one for this pure Rotation
|
||||
|
||||
inline HepRep4x4 rep4x4() const;
|
||||
// 4x4 representation.
|
||||
|
||||
// --------- Mutators
|
||||
|
||||
void setDelta (double delta);
|
||||
// change angle of rotation, leaving rotation axis unchanged.
|
||||
|
||||
// ---------- Decomposition:
|
||||
|
||||
void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
|
||||
void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
|
||||
void decompose (HepRotation & rotation, HepBoost & boost) const;
|
||||
void decompose (HepBoost & boost, HepRotation & rotation) const;
|
||||
// These are trivial, as the boost vector is 0.
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline bool isIdentity() const;
|
||||
// Returns true if the identity matrix (Geant4).
|
||||
|
||||
inline int compare( const HepRotationX & r ) const;
|
||||
// Dictionary-order comparison, in order of delta
|
||||
// Used in operator<, >, <=, >=
|
||||
|
||||
inline bool operator== ( const HepRotationX & r ) const;
|
||||
inline bool operator!= ( const HepRotationX & r ) const;
|
||||
inline bool operator< ( const HepRotationX & r ) const;
|
||||
inline bool operator> ( const HepRotationX & r ) const;
|
||||
inline bool operator<= ( const HepRotationX & r ) const;
|
||||
inline bool operator>= ( const HepRotationX & r ) const;
|
||||
|
||||
double distance2( const HepRotationX & r ) const;
|
||||
// 3 - Tr ( this/r )
|
||||
|
||||
double distance2( const HepRotation & r ) const;
|
||||
// 3 - Tr ( this/r ) -- This works with RotationY or Z also
|
||||
|
||||
double howNear( const HepRotationX & r ) const;
|
||||
double howNear( const HepRotation & r ) const;
|
||||
bool isNear( const HepRotationX & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepRotation & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
double distance2( const HepBoost & lt ) const;
|
||||
// 3 - Tr ( this ) + |b|^2 / (1-|b|^2)
|
||||
double distance2( const HepLorentzRotation & lt ) const;
|
||||
// 3 - Tr ( this/r ) + |b|^2 / (1-|b|^2) where b is the boost vector of lt
|
||||
|
||||
double howNear( const HepBoost & lt ) const;
|
||||
double howNear( const HepLorentzRotation & lt ) const;
|
||||
bool isNear( const HepBoost & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepLorentzRotation & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
double norm2() const;
|
||||
// distance2 (IDENTITY), which is 3 - Tr ( *this )
|
||||
|
||||
inline void rectify();
|
||||
// non-const but logically moot correction for accumulated roundoff errors
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline Hep3Vector operator() (const Hep3Vector & p) const;
|
||||
// Rotate a Hep3Vector.
|
||||
|
||||
inline Hep3Vector operator * (const Hep3Vector & p) const;
|
||||
// Multiplication with a Hep3Vector.
|
||||
|
||||
inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
|
||||
// Rotate (the space part of) a HepLorentzVector.
|
||||
|
||||
inline HepLorentzVector operator* ( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a HepLorentzVector.
|
||||
|
||||
// ---------- Operations in the group of Rotations
|
||||
|
||||
inline HepRotationX operator * (const HepRotationX & rx) const;
|
||||
// Product of two X rotations: (this) * rx is known to be RotationX.
|
||||
|
||||
inline HepRotationX & operator *= (const HepRotationX & r);
|
||||
inline HepRotationX & transform (const HepRotationX & r);
|
||||
// Matrix multiplication.
|
||||
// Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a;
|
||||
// However, in this special case, they commute: Both just add deltas.
|
||||
|
||||
inline HepRotationX inverse() const;
|
||||
// Returns the inverse.
|
||||
|
||||
friend HepRotationX inverseOf(const HepRotationX & r);
|
||||
// Returns the inverse of a RotationX.
|
||||
|
||||
inline HepRotationX & invert();
|
||||
// Inverts the Rotation matrix (be negating delta).
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
// Output, identifying type of rotation and delta.
|
||||
|
||||
// ---------- Tolerance
|
||||
|
||||
static inline double getTolerance();
|
||||
static inline double setTolerance(double tol);
|
||||
|
||||
protected:
|
||||
|
||||
double d;
|
||||
// The angle of rotation.
|
||||
|
||||
double s;
|
||||
double c;
|
||||
// Cache the trig functions, for rapid operations.
|
||||
|
||||
inline HepRotationX ( double dd, double ss, double cc );
|
||||
// Unchecked load-the-data-members
|
||||
|
||||
static inline double proper (double delta);
|
||||
// Put an angle into the range of (-PI, PI]. Useful helper method.
|
||||
|
||||
}; // HepRotationX
|
||||
// ---------- Free-function operations in the group of Rotations
|
||||
|
||||
inline
|
||||
std::ostream & operator <<
|
||||
( std::ostream & os, const HepRotationX & r ) {return r.print(os);}
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/RotationX.icc"
|
||||
|
||||
#endif /* HEP_ROTATIONX_H */
|
||||
@@ -0,0 +1,208 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// HepRotationX class
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
#include "CLHEP/Units/PhysicalConstants.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
inline double HepRotationX::yy() const { return c; }
|
||||
inline double HepRotationX::yz() const { return -s; }
|
||||
inline double HepRotationX::zy() const { return s; }
|
||||
inline double HepRotationX::zz() const { return c; }
|
||||
|
||||
inline double HepRotationX::xx() const { return 1.0; }
|
||||
inline double HepRotationX::xy() const { return 0.0; }
|
||||
inline double HepRotationX::xz() const { return 0.0; }
|
||||
inline double HepRotationX::yx() const { return 0.0; }
|
||||
inline double HepRotationX::zx() const { return 0.0; }
|
||||
|
||||
inline HepRep3x3 HepRotationX::rep3x3() const {
|
||||
return HepRep3x3 ( 1.0, 0.0, 0.0,
|
||||
0.0, c, -s,
|
||||
0.0, s, c );
|
||||
}
|
||||
|
||||
inline HepRotationX::HepRotationX() : d(0.0), s(0.0), c(1.0) {}
|
||||
|
||||
inline HepRotationX::HepRotationX(const HepRotationX & orig) :
|
||||
d(orig.d), s(orig.s), c(orig.c)
|
||||
{}
|
||||
|
||||
inline HepRotationX::HepRotationX(double dd, double ss, double cc) :
|
||||
d(dd), s(ss), c(cc)
|
||||
{}
|
||||
|
||||
inline HepRotationX & HepRotationX::operator= (const HepRotationX & orig) {
|
||||
d = orig.d;
|
||||
s = orig.s;
|
||||
c = orig.c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepRotationX::~HepRotationX() {}
|
||||
|
||||
inline Hep3Vector HepRotationX::colX() const
|
||||
{ return Hep3Vector ( 1.0, 0.0, 0.0 ); }
|
||||
inline Hep3Vector HepRotationX::colY() const
|
||||
{ return Hep3Vector ( 0.0, c, s ); }
|
||||
inline Hep3Vector HepRotationX::colZ() const
|
||||
{ return Hep3Vector ( 0.0, -s, c ); }
|
||||
|
||||
inline Hep3Vector HepRotationX::rowX() const
|
||||
{ return Hep3Vector ( 1.0, 0.0, 0.0 ); }
|
||||
inline Hep3Vector HepRotationX::rowY() const
|
||||
{ return Hep3Vector ( 0.0, c, -s ); }
|
||||
inline Hep3Vector HepRotationX::rowZ() const
|
||||
{ return Hep3Vector ( 0.0, s, c ); }
|
||||
|
||||
inline double HepRotationX::getPhi () const { return phi(); }
|
||||
inline double HepRotationX::getTheta() const { return theta(); }
|
||||
inline double HepRotationX::getPsi () const { return psi(); }
|
||||
inline double HepRotationX::getDelta() const { return d; }
|
||||
inline Hep3Vector HepRotationX::getAxis () const { return axis(); }
|
||||
|
||||
inline double HepRotationX::delta() const { return d; }
|
||||
inline Hep3Vector HepRotationX::axis() const { return Hep3Vector(1,0,0); }
|
||||
|
||||
inline HepAxisAngle HepRotationX::axisAngle() const {
|
||||
return HepAxisAngle ( axis(), delta() );
|
||||
}
|
||||
|
||||
inline void HepRotationX::getAngleAxis
|
||||
(double & delta, Hep3Vector & axis) const {
|
||||
delta = d;
|
||||
axis = getAxis();
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepRotationX::col1() const
|
||||
{ return HepLorentzVector (colX(), 0); }
|
||||
inline HepLorentzVector HepRotationX::col2() const
|
||||
{ return HepLorentzVector (colY(), 0); }
|
||||
inline HepLorentzVector HepRotationX::col3() const
|
||||
{ return HepLorentzVector (colZ(), 0); }
|
||||
inline HepLorentzVector HepRotationX::col4() const
|
||||
{ return HepLorentzVector (0,0,0,1); }
|
||||
inline HepLorentzVector HepRotationX::row1() const
|
||||
{ return HepLorentzVector (rowX(), 0); }
|
||||
inline HepLorentzVector HepRotationX::row2() const
|
||||
{ return HepLorentzVector (rowY(), 0); }
|
||||
inline HepLorentzVector HepRotationX::row3() const
|
||||
{ return HepLorentzVector (rowZ(), 0); }
|
||||
inline HepLorentzVector HepRotationX::row4() const
|
||||
{ return HepLorentzVector (0,0,0,1); }
|
||||
inline double HepRotationX::xt() const { return 0.0; }
|
||||
inline double HepRotationX::yt() const { return 0.0; }
|
||||
inline double HepRotationX::zt() const { return 0.0; }
|
||||
inline double HepRotationX::tx() const { return 0.0; }
|
||||
inline double HepRotationX::ty() const { return 0.0; }
|
||||
inline double HepRotationX::tz() const { return 0.0; }
|
||||
inline double HepRotationX::tt() const { return 1.0; }
|
||||
|
||||
inline HepRep4x4 HepRotationX::rep4x4() const {
|
||||
return HepRep4x4 ( 1.0, 0.0, 0.0, 0.0,
|
||||
0.0, c, -s, 0.0,
|
||||
0.0, s, c, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
inline bool HepRotationX::isIdentity() const {
|
||||
return ( d==0 );
|
||||
}
|
||||
|
||||
inline int HepRotationX::compare ( const HepRotationX & r ) const {
|
||||
if (d > r.d) return 1; else if (d < r.d) return -1; else return 0;
|
||||
}
|
||||
|
||||
inline bool HepRotationX::operator==(const HepRotationX & r) const
|
||||
{ return (d==r.d); }
|
||||
inline bool HepRotationX::operator!=(const HepRotationX & r) const
|
||||
{ return (d!=r.d); }
|
||||
inline bool HepRotationX::operator>=(const HepRotationX & r) const
|
||||
{ return (d>=r.d); }
|
||||
inline bool HepRotationX::operator<=(const HepRotationX & r) const
|
||||
{ return (d<=r.d); }
|
||||
inline bool HepRotationX::operator> (const HepRotationX & r) const
|
||||
{ return (d> r.d); }
|
||||
inline bool HepRotationX::operator< (const HepRotationX & r) const
|
||||
{ return (d< r.d); }
|
||||
|
||||
inline void HepRotationX::rectify() {
|
||||
d = proper(d); // Just in case!
|
||||
s = std::sin(d);
|
||||
c = std::cos(d);
|
||||
}
|
||||
|
||||
inline Hep3Vector HepRotationX::operator() (const Hep3Vector & p) const {
|
||||
double x = p.x();
|
||||
double y = p.y();
|
||||
double z = p.z();
|
||||
return Hep3Vector( x,
|
||||
y * c - z * s,
|
||||
z * c + y * s );
|
||||
}
|
||||
|
||||
inline Hep3Vector HepRotationX::operator * (const Hep3Vector & p) const {
|
||||
return operator()(p);
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepRotationX::operator()
|
||||
( const HepLorentzVector & w ) const {
|
||||
return HepLorentzVector( operator() (w.vect()) , w.t() );
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepRotationX::operator *
|
||||
(const HepLorentzVector & p) const {
|
||||
return operator()(p);
|
||||
}
|
||||
|
||||
inline HepRotationX & HepRotationX::operator *= (const HepRotationX & m) {
|
||||
return *this = (*this) * (m);
|
||||
}
|
||||
|
||||
inline HepRotationX & HepRotationX::transform(const HepRotationX & m) {
|
||||
return *this = m * (*this);
|
||||
}
|
||||
|
||||
inline double HepRotationX::proper( double delta ) {
|
||||
// -PI < d <= PI
|
||||
if ( std::fabs(delta) < CLHEP::pi ) {
|
||||
return delta;
|
||||
} else {
|
||||
register double x = delta / (CLHEP::twopi);
|
||||
return (CLHEP::twopi) * ( x + std::floor(.5-x) );
|
||||
}
|
||||
} // proper()
|
||||
|
||||
inline HepRotationX HepRotationX::operator * ( const HepRotationX & rx ) const {
|
||||
return HepRotationX ( HepRotationX::proper(d+rx.d),
|
||||
s*rx.c + c*rx.s,
|
||||
c*rx.c - s*rx.s );
|
||||
}
|
||||
|
||||
inline HepRotationX HepRotationX::inverse() const {
|
||||
return HepRotationX( proper(-d), -s, c );
|
||||
}
|
||||
|
||||
inline HepRotationX inverseOf(const HepRotationX & r) {
|
||||
return r.inverse();
|
||||
}
|
||||
|
||||
inline HepRotationX & HepRotationX::invert() {
|
||||
return *this=inverse();
|
||||
}
|
||||
|
||||
inline double HepRotationX::getTolerance() {
|
||||
return Hep4RotationInterface::tolerance;
|
||||
}
|
||||
inline double HepRotationX::setTolerance(double tol) {
|
||||
return Hep4RotationInterface::setTolerance(tol);
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,285 @@
|
||||
// -*- C++ -*-
|
||||
// CLASSDOC OFF
|
||||
// ---------------------------------------------------------------------------
|
||||
// CLASSDOC ON
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definition of the HepRotationY class for performing rotations
|
||||
// around the X axis on objects of the Hep3Vector (and HepLorentzVector) class.
|
||||
//
|
||||
// HepRotationY is a concrete implementation of Hep3RotationInterface.
|
||||
//
|
||||
// .SS See Also
|
||||
// RotationInterfaces.h
|
||||
// ThreeVector.h, LorentzVector.h, LorentzRotation.h
|
||||
//
|
||||
// .SS Author
|
||||
// Mark Fischler
|
||||
|
||||
#ifndef HEP_ROTATIONY_H
|
||||
#define HEP_ROTATIONY_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "CLHEP/Vector/RotationInterfaces.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
class HepRotationY;
|
||||
class HepRotation;
|
||||
class HepBoost;
|
||||
|
||||
inline HepRotationY inverseOf(const HepRotationY & r);
|
||||
// Returns the inverse of a RotationY.
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepRotationY {
|
||||
|
||||
public:
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepRotationY();
|
||||
// Default constructor. Gives an identity rotation.
|
||||
|
||||
HepRotationY(double delta);
|
||||
// supply angle of rotation
|
||||
|
||||
inline HepRotationY(const HepRotationY & orig);
|
||||
// Copy constructor.
|
||||
|
||||
inline HepRotationY & operator = (const HepRotationY & r);
|
||||
// Assignment from a Rotation, which must be RotationY
|
||||
|
||||
HepRotationY & set ( double delta );
|
||||
// set angle of rotation
|
||||
|
||||
inline ~HepRotationY();
|
||||
// Trivial destructor.
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline Hep3Vector colX() const;
|
||||
inline Hep3Vector colY() const;
|
||||
inline Hep3Vector colZ() const;
|
||||
// orthogonal unit-length column vectors
|
||||
|
||||
inline Hep3Vector rowX() const;
|
||||
inline Hep3Vector rowY() const;
|
||||
inline Hep3Vector rowZ() const;
|
||||
// orthogonal unit-length row vectors
|
||||
|
||||
inline double xx() const;
|
||||
inline double xy() const;
|
||||
inline double xz() const;
|
||||
inline double yx() const;
|
||||
inline double yy() const;
|
||||
inline double yz() const;
|
||||
inline double zx() const;
|
||||
inline double zy() const;
|
||||
inline double zz() const;
|
||||
// Elements of the rotation matrix (Geant4).
|
||||
|
||||
inline HepRep3x3 rep3x3() const;
|
||||
// 3x3 representation:
|
||||
|
||||
// ------------ Euler angles:
|
||||
inline double getPhi () const;
|
||||
inline double getTheta() const;
|
||||
inline double getPsi () const;
|
||||
double phi () const;
|
||||
double theta() const;
|
||||
double psi () const;
|
||||
HepEulerAngles eulerAngles() const;
|
||||
|
||||
// ------------ axis & angle of rotation:
|
||||
inline double getDelta() const;
|
||||
inline Hep3Vector getAxis () const;
|
||||
inline double delta() const;
|
||||
inline Hep3Vector axis () const;
|
||||
inline HepAxisAngle axisAngle() const;
|
||||
inline void getAngleAxis(double & delta, Hep3Vector & axis) const;
|
||||
// Returns the rotation angle and rotation axis (Geant4).
|
||||
|
||||
// ------------- Angles of rotated axes
|
||||
double phiX() const;
|
||||
double phiY() const;
|
||||
double phiZ() const;
|
||||
double thetaX() const;
|
||||
double thetaY() const;
|
||||
double thetaZ() const;
|
||||
// Return angles (RADS) made by rotated axes against original axes (Geant4).
|
||||
|
||||
// ---------- Other accessors treating pure rotation as a 4-rotation
|
||||
|
||||
inline HepLorentzVector col1() const;
|
||||
inline HepLorentzVector col2() const;
|
||||
inline HepLorentzVector col3() const;
|
||||
// orthosymplectic 4-vector columns - T component will be zero
|
||||
|
||||
inline HepLorentzVector col4() const;
|
||||
// Will be (0,0,0,1) for this pure Rotation.
|
||||
|
||||
inline HepLorentzVector row1() const;
|
||||
inline HepLorentzVector row2() const;
|
||||
inline HepLorentzVector row3() const;
|
||||
// orthosymplectic 4-vector rows - T component will be zero
|
||||
|
||||
inline HepLorentzVector row4() const;
|
||||
// Will be (0,0,0,1) for this pure Rotation.
|
||||
|
||||
inline double xt() const;
|
||||
inline double yt() const;
|
||||
inline double zt() const;
|
||||
inline double tx() const;
|
||||
inline double ty() const;
|
||||
inline double tz() const;
|
||||
// Will be zero for this pure Rotation
|
||||
|
||||
inline double tt() const;
|
||||
// Will be one for this pure Rotation
|
||||
|
||||
inline HepRep4x4 rep4x4() const;
|
||||
// 4x4 representation.
|
||||
|
||||
// --------- Mutators
|
||||
|
||||
void setDelta (double delta);
|
||||
// change angle of rotation, leaving rotation axis unchanged.
|
||||
|
||||
// ---------- Decomposition:
|
||||
|
||||
void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
|
||||
void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
|
||||
void decompose (HepRotation & rotation, HepBoost & boost) const;
|
||||
void decompose (HepBoost & boost, HepRotation & rotation) const;
|
||||
// These are trivial, as the boost vector is 0.
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline bool isIdentity() const;
|
||||
// Returns true if the identity matrix (Geant4).
|
||||
|
||||
inline int compare( const HepRotationY & r ) const;
|
||||
// Dictionary-order comparison, in order of delta
|
||||
// Used in operator<, >, <=, >=
|
||||
|
||||
inline bool operator== ( const HepRotationY & r ) const;
|
||||
inline bool operator!= ( const HepRotationY & r ) const;
|
||||
inline bool operator< ( const HepRotationY & r ) const;
|
||||
inline bool operator> ( const HepRotationY & r ) const;
|
||||
inline bool operator<= ( const HepRotationY & r ) const;
|
||||
inline bool operator>= ( const HepRotationY & r ) const;
|
||||
|
||||
double distance2( const HepRotationY & r ) const;
|
||||
// 3 - Tr ( this/r )
|
||||
|
||||
double distance2( const HepRotation & r ) const;
|
||||
// 3 - Tr ( this/r ) -- This works with RotationY or Z also
|
||||
|
||||
double howNear( const HepRotationY & r ) const;
|
||||
double howNear( const HepRotation & r ) const;
|
||||
bool isNear( const HepRotationY & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepRotation & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
double distance2( const HepBoost & lt ) const;
|
||||
// 3 - Tr ( this ) + |b|^2 / (1-|b|^2)
|
||||
double distance2( const HepLorentzRotation & lt ) const;
|
||||
// 3 - Tr ( this/r ) + |b|^2 / (1-|b|^2) where b is the boost vector of lt
|
||||
|
||||
double howNear( const HepBoost & lt ) const;
|
||||
double howNear( const HepLorentzRotation & lt ) const;
|
||||
bool isNear( const HepBoost & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepLorentzRotation & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
double norm2() const;
|
||||
// distance2 (IDENTITY), which is 3 - Tr ( *this )
|
||||
|
||||
inline void rectify();
|
||||
// non-const but logically moot correction for accumulated roundoff errors
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline Hep3Vector operator() (const Hep3Vector & p) const;
|
||||
// Rotate a Hep3Vector.
|
||||
|
||||
inline Hep3Vector operator * (const Hep3Vector & p) const;
|
||||
// Multiplication with a Hep3Vector.
|
||||
|
||||
inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
|
||||
// Rotate (the space part of) a HepLorentzVector.
|
||||
|
||||
inline HepLorentzVector operator* ( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a HepLorentzVector.
|
||||
|
||||
// ---------- Operations in the group of Rotations
|
||||
|
||||
inline HepRotationY operator * (const HepRotationY & ry) const;
|
||||
// Product of two Y rotations (this) * ry is known to be RotationY.
|
||||
|
||||
inline HepRotationY & operator *= (const HepRotationY & r);
|
||||
inline HepRotationY & transform (const HepRotationY & r);
|
||||
// Matrix multiplication.
|
||||
// Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a;
|
||||
// However, in this special case, they commute: Both just add deltas.
|
||||
|
||||
inline HepRotationY inverse() const;
|
||||
// Returns the inverse.
|
||||
|
||||
friend HepRotationY inverseOf(const HepRotationY & r);
|
||||
// Returns the inverse of a RotationY.
|
||||
|
||||
inline HepRotationY & invert();
|
||||
// Inverts the Rotation matrix (be negating delta).
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
// Output, identifying type of rotation and delta.
|
||||
|
||||
// ---------- Tolerance
|
||||
|
||||
static inline double getTolerance();
|
||||
static inline double setTolerance(double tol);
|
||||
|
||||
protected:
|
||||
|
||||
double d;
|
||||
// The angle of rotation.
|
||||
|
||||
double s;
|
||||
double c;
|
||||
// Cache the trig functions, for rapid operations.
|
||||
|
||||
inline HepRotationY ( double dd, double ss, double cc );
|
||||
// Unchecked load-the-data-members
|
||||
|
||||
static inline double proper (double delta);
|
||||
// Put an angle into the range of (-PI, PI]. Useful helper method.
|
||||
|
||||
}; // HepRotationY
|
||||
|
||||
// ---------- Free-function operations in the group of Rotations
|
||||
|
||||
inline
|
||||
std::ostream & operator <<
|
||||
( std::ostream & os, const HepRotationY & r ) {return r.print(os);}
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/RotationY.icc"
|
||||
|
||||
#endif /* HEP_ROTATIONY_H */
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// HepRotationY class
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
#include "CLHEP/Units/PhysicalConstants.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
inline double HepRotationY::xx() const { return c; }
|
||||
inline double HepRotationY::xz() const { return s; }
|
||||
inline double HepRotationY::zx() const { return -s; }
|
||||
inline double HepRotationY::zz() const { return c; }
|
||||
|
||||
inline double HepRotationY::yy() const { return 1.0; }
|
||||
inline double HepRotationY::yx() const { return 0.0; }
|
||||
inline double HepRotationY::yz() const { return 0.0; }
|
||||
inline double HepRotationY::xy() const { return 0.0; }
|
||||
inline double HepRotationY::zy() const { return 0.0; }
|
||||
|
||||
inline HepRep3x3 HepRotationY::rep3x3() const {
|
||||
return HepRep3x3 ( c , 0.0, s,
|
||||
0.0, 1.0, 0.0,
|
||||
-s , 0.0, c );
|
||||
}
|
||||
|
||||
inline HepRotationY::HepRotationY() : d(0.0), s(0.0), c(1.0) {}
|
||||
|
||||
inline HepRotationY::HepRotationY(const HepRotationY & orig) :
|
||||
d(orig.d), s(orig.s), c(orig.c)
|
||||
{}
|
||||
|
||||
inline HepRotationY::HepRotationY(double dd, double ss, double cc) :
|
||||
d(dd), s(ss), c(cc)
|
||||
{}
|
||||
|
||||
inline HepRotationY & HepRotationY::operator= (const HepRotationY & orig) {
|
||||
d = orig.d;
|
||||
s = orig.s;
|
||||
c = orig.c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepRotationY::~HepRotationY() {}
|
||||
|
||||
inline Hep3Vector HepRotationY::colX() const
|
||||
{ return Hep3Vector ( c, 0.0, -s ); }
|
||||
inline Hep3Vector HepRotationY::colY() const
|
||||
{ return Hep3Vector ( 0.0, 1.0, 0.0 ); }
|
||||
inline Hep3Vector HepRotationY::colZ() const
|
||||
{ return Hep3Vector ( s, 0.0, c ); }
|
||||
|
||||
inline Hep3Vector HepRotationY::rowX() const
|
||||
{ return Hep3Vector ( c, 0.0, s ); }
|
||||
inline Hep3Vector HepRotationY::rowY() const
|
||||
{ return Hep3Vector ( 0.0, 1.0, 0.0 ); }
|
||||
inline Hep3Vector HepRotationY::rowZ() const
|
||||
{ return Hep3Vector ( -s, 0.0, c ); }
|
||||
|
||||
inline double HepRotationY::getPhi () const { return phi(); }
|
||||
inline double HepRotationY::getTheta() const { return theta(); }
|
||||
inline double HepRotationY::getPsi () const { return psi(); }
|
||||
inline double HepRotationY::getDelta() const { return d; }
|
||||
inline Hep3Vector HepRotationY::getAxis () const { return axis(); }
|
||||
|
||||
inline double HepRotationY::delta() const { return d; }
|
||||
inline Hep3Vector HepRotationY::axis() const { return Hep3Vector(0,1,0); }
|
||||
|
||||
inline HepAxisAngle HepRotationY::axisAngle() const {
|
||||
return HepAxisAngle ( axis(), delta() );
|
||||
}
|
||||
|
||||
inline void HepRotationY::getAngleAxis
|
||||
(double & delta, Hep3Vector & axis) const {
|
||||
delta = d;
|
||||
axis = getAxis();
|
||||
}
|
||||
|
||||
inline bool HepRotationY::isIdentity() const {
|
||||
return ( d==0 );
|
||||
}
|
||||
|
||||
inline int HepRotationY::compare ( const HepRotationY & r ) const {
|
||||
if (d > r.d) return 1; else if (d < r.d) return -1; else return 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool HepRotationY::operator==(const HepRotationY & r) const
|
||||
{ return (d==r.d); }
|
||||
inline bool HepRotationY::operator!=(const HepRotationY & r) const
|
||||
{ return (d!=r.d); }
|
||||
inline bool HepRotationY::operator>=(const HepRotationY & r) const
|
||||
{ return (d>=r.d); }
|
||||
inline bool HepRotationY::operator<=(const HepRotationY & r) const
|
||||
{ return (d<=r.d); }
|
||||
inline bool HepRotationY::operator> (const HepRotationY & r) const
|
||||
{ return (d> r.d); }
|
||||
inline bool HepRotationY::operator< (const HepRotationY & r) const
|
||||
{ return (d< r.d); }
|
||||
|
||||
inline void HepRotationY::rectify() {
|
||||
d = proper(d); // Just in case!
|
||||
s = std::sin(d);
|
||||
c = std::cos(d);
|
||||
}
|
||||
|
||||
inline Hep3Vector HepRotationY::operator() (const Hep3Vector & p) const {
|
||||
double x = p.x();
|
||||
double y = p.y();
|
||||
double z = p.z();
|
||||
return Hep3Vector( x * c + z * s,
|
||||
y,
|
||||
z * c - x * s );
|
||||
}
|
||||
|
||||
inline Hep3Vector HepRotationY::operator * (const Hep3Vector & p) const {
|
||||
return operator()(p);
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepRotationY::operator()
|
||||
( const HepLorentzVector & w ) const {
|
||||
return HepLorentzVector( operator() (w.vect()) , w.t() );
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepRotationY::operator *
|
||||
(const HepLorentzVector & p) const {
|
||||
return operator()(p);
|
||||
}
|
||||
|
||||
inline HepRotationY & HepRotationY::operator *= (const HepRotationY & m) {
|
||||
return *this = (*this) * (m);
|
||||
}
|
||||
|
||||
inline HepRotationY & HepRotationY::transform(const HepRotationY & m) {
|
||||
return *this = m * (*this);
|
||||
}
|
||||
|
||||
inline double HepRotationY::proper( double delta ) {
|
||||
// -PI < d <= PI
|
||||
if ( std::fabs(delta) < CLHEP::pi ) {
|
||||
return delta;
|
||||
} else {
|
||||
register double x = delta / (CLHEP::twopi);
|
||||
return (CLHEP::twopi) * ( x + std::floor(.5-x) );
|
||||
}
|
||||
} // proper()
|
||||
|
||||
inline HepRotationY HepRotationY::operator * ( const HepRotationY & ry ) const {
|
||||
return HepRotationY ( HepRotationY::proper(d+ry.d),
|
||||
s*ry.c + c*ry.s,
|
||||
c*ry.c - s*ry.s );
|
||||
}
|
||||
|
||||
inline HepRotationY HepRotationY::inverse() const {
|
||||
return HepRotationY( proper(-d), -s, c );
|
||||
}
|
||||
|
||||
inline HepRotationY inverseOf(const HepRotationY & r) {
|
||||
return r.inverse();
|
||||
}
|
||||
|
||||
inline HepRotationY & HepRotationY::invert() {
|
||||
return *this=inverse();
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepRotationY::col1() const
|
||||
{ return HepLorentzVector (colX(), 0); }
|
||||
inline HepLorentzVector HepRotationY::col2() const
|
||||
{ return HepLorentzVector (colY(), 0); }
|
||||
inline HepLorentzVector HepRotationY::col3() const
|
||||
{ return HepLorentzVector (colZ(), 0); }
|
||||
inline HepLorentzVector HepRotationY::col4() const
|
||||
{ return HepLorentzVector (0,0,0,1); }
|
||||
inline HepLorentzVector HepRotationY::row1() const
|
||||
{ return HepLorentzVector (rowX(), 0); }
|
||||
inline HepLorentzVector HepRotationY::row2() const
|
||||
{ return HepLorentzVector (rowY(), 0); }
|
||||
inline HepLorentzVector HepRotationY::row3() const
|
||||
{ return HepLorentzVector (rowZ(), 0); }
|
||||
inline HepLorentzVector HepRotationY::row4() const
|
||||
{ return HepLorentzVector (0,0,0,1); }
|
||||
inline double HepRotationY::xt() const { return 0.0; }
|
||||
inline double HepRotationY::yt() const { return 0.0; }
|
||||
inline double HepRotationY::zt() const { return 0.0; }
|
||||
inline double HepRotationY::tx() const { return 0.0; }
|
||||
inline double HepRotationY::ty() const { return 0.0; }
|
||||
inline double HepRotationY::tz() const { return 0.0; }
|
||||
inline double HepRotationY::tt() const { return 1.0; }
|
||||
|
||||
inline HepRep4x4 HepRotationY::rep4x4() const {
|
||||
return HepRep4x4 ( c , 0.0, s, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
-s , 0.0, c, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
inline double HepRotationY::getTolerance() {
|
||||
return Hep4RotationInterface::tolerance;
|
||||
}
|
||||
inline double HepRotationY::setTolerance(double tol) {
|
||||
return Hep4RotationInterface::setTolerance(tol);
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,287 @@
|
||||
// -*- C++ -*-
|
||||
// CLASSDOC OFF
|
||||
// ---------------------------------------------------------------------------
|
||||
// CLASSDOC ON
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definition of the HepRotationZ class for performing rotations
|
||||
// around the X axis on objects of the Hep3Vector (and HepLorentzVector) class.
|
||||
//
|
||||
// HepRotationZ is a concrete implementation of Hep3RotationInterface.
|
||||
//
|
||||
// .SS See Also
|
||||
// RotationInterfaces.h
|
||||
// ThreeVector.h, LorentzVector.h, LorentzRotation.h
|
||||
//
|
||||
// .SS Author
|
||||
// Mark Fischler
|
||||
|
||||
#ifndef HEP_ROTATIONZ_H
|
||||
#define HEP_ROTATIONZ_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "CLHEP/Vector/RotationInterfaces.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
class HepRotationZ;
|
||||
class HepRotation;
|
||||
class HepBoost;
|
||||
|
||||
inline HepRotationZ inverseOf(const HepRotationZ & r);
|
||||
// Returns the inverse of a RotationZ.
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class HepRotationZ {
|
||||
|
||||
public:
|
||||
|
||||
// ---------- Constructors and Assignment:
|
||||
|
||||
inline HepRotationZ();
|
||||
// Default constructor. Gives an identity rotation.
|
||||
|
||||
HepRotationZ(double delta);
|
||||
// supply angle of rotation
|
||||
|
||||
inline HepRotationZ(const HepRotationZ & orig);
|
||||
// Copy constructor.
|
||||
|
||||
inline HepRotationZ & operator = (const HepRotationZ & r);
|
||||
// Assignment from a Rotation, which must be RotationZ
|
||||
|
||||
HepRotationZ & set ( double delta );
|
||||
// set angle of rotation
|
||||
|
||||
inline ~HepRotationZ();
|
||||
// Trivial destructor.
|
||||
|
||||
// ---------- Accessors:
|
||||
|
||||
inline Hep3Vector colX() const;
|
||||
inline Hep3Vector colY() const;
|
||||
inline Hep3Vector colZ() const;
|
||||
// orthogonal unit-length column vectors
|
||||
|
||||
inline Hep3Vector rowX() const;
|
||||
inline Hep3Vector rowY() const;
|
||||
inline Hep3Vector rowZ() const;
|
||||
// orthogonal unit-length row vectors
|
||||
|
||||
inline double xx() const;
|
||||
inline double xy() const;
|
||||
inline double xz() const;
|
||||
inline double yx() const;
|
||||
inline double yy() const;
|
||||
inline double yz() const;
|
||||
inline double zx() const;
|
||||
inline double zy() const;
|
||||
inline double zz() const;
|
||||
// Elements of the rotation matrix (Geant4).
|
||||
|
||||
inline HepRep3x3 rep3x3() const;
|
||||
// 3x3 representation:
|
||||
|
||||
// ------------ Euler angles:
|
||||
inline double getPhi () const;
|
||||
inline double getTheta() const;
|
||||
inline double getPsi () const;
|
||||
double phi () const;
|
||||
double theta() const;
|
||||
double psi () const;
|
||||
HepEulerAngles eulerAngles() const;
|
||||
|
||||
// ------------ axis & angle of rotation:
|
||||
inline double getDelta() const;
|
||||
inline Hep3Vector getAxis () const;
|
||||
inline double delta() const;
|
||||
inline Hep3Vector axis () const;
|
||||
inline HepAxisAngle axisAngle() const;
|
||||
inline void getAngleAxis(double & delta, Hep3Vector & axis) const;
|
||||
// Returns the rotation angle and rotation axis (Geant4).
|
||||
|
||||
// ------------- Angles of rotated axes
|
||||
double phiX() const;
|
||||
double phiY() const;
|
||||
double phiZ() const;
|
||||
double thetaX() const;
|
||||
double thetaY() const;
|
||||
double thetaZ() const;
|
||||
// Return angles (RADS) made by rotated axes against original axes (Geant4).
|
||||
|
||||
// ---------- Other accessors treating pure rotation as a 4-rotation
|
||||
|
||||
inline HepLorentzVector col1() const;
|
||||
inline HepLorentzVector col2() const;
|
||||
inline HepLorentzVector col3() const;
|
||||
// orthosymplectic 4-vector columns - T component will be zero
|
||||
|
||||
inline HepLorentzVector col4() const;
|
||||
// Will be (0,0,0,1) for this pure Rotation.
|
||||
|
||||
inline HepLorentzVector row1() const;
|
||||
inline HepLorentzVector row2() const;
|
||||
inline HepLorentzVector row3() const;
|
||||
// orthosymplectic 4-vector rows - T component will be zero
|
||||
|
||||
inline HepLorentzVector row4() const;
|
||||
// Will be (0,0,0,1) for this pure Rotation.
|
||||
|
||||
inline double xt() const;
|
||||
inline double yt() const;
|
||||
inline double zt() const;
|
||||
inline double tx() const;
|
||||
inline double ty() const;
|
||||
inline double tz() const;
|
||||
// Will be zero for this pure Rotation
|
||||
|
||||
inline double tt() const;
|
||||
// Will be one for this pure Rotation
|
||||
|
||||
inline HepRep4x4 rep4x4() const;
|
||||
// 4x4 representation.
|
||||
|
||||
// --------- Mutators
|
||||
|
||||
void setDelta (double delta);
|
||||
// change angle of rotation, leaving rotation axis unchanged.
|
||||
|
||||
// ---------- Decomposition:
|
||||
|
||||
void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
|
||||
void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
|
||||
void decompose (HepRotation & rotation, HepBoost & boost) const;
|
||||
void decompose (HepBoost & boost, HepRotation & rotation) const;
|
||||
// These are trivial, as the boost vector is 0.
|
||||
|
||||
// ---------- Comparisons:
|
||||
|
||||
inline bool isIdentity() const;
|
||||
// Returns true if the identity matrix (Geant4).
|
||||
|
||||
inline int compare( const HepRotationZ & r ) const;
|
||||
// Dictionary-order comparison, in order of delta
|
||||
// Used in operator<, >, <=, >=
|
||||
|
||||
inline bool operator== ( const HepRotationZ & r ) const;
|
||||
inline bool operator!= ( const HepRotationZ & r ) const;
|
||||
inline bool operator< ( const HepRotationZ & r ) const;
|
||||
inline bool operator> ( const HepRotationZ & r ) const;
|
||||
inline bool operator<= ( const HepRotationZ & r ) const;
|
||||
inline bool operator>= ( const HepRotationZ & r ) const;
|
||||
|
||||
double distance2( const HepRotationZ & r ) const;
|
||||
// 3 - Tr ( this/r )
|
||||
|
||||
double distance2( const HepRotation & r ) const;
|
||||
// 3 - Tr ( this/r ) -- This works with RotationY or Z also
|
||||
|
||||
double howNear( const HepRotationZ & r ) const;
|
||||
double howNear( const HepRotation & r ) const;
|
||||
bool isNear( const HepRotationZ & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepRotation & r,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
double distance2( const HepBoost & lt ) const;
|
||||
// 3 - Tr ( this ) + |b|^2 / (1-|b|^2)
|
||||
double distance2( const HepLorentzRotation & lt ) const;
|
||||
// 3 - Tr ( this/r ) + |b|^2 / (1-|b|^2) where b is the boost vector of lt
|
||||
|
||||
double howNear( const HepBoost & lt ) const;
|
||||
double howNear( const HepLorentzRotation & lt ) const;
|
||||
bool isNear( const HepBoost & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
bool isNear( const HepLorentzRotation & lt,
|
||||
double epsilon=Hep4RotationInterface::tolerance) const;
|
||||
|
||||
// ---------- Properties:
|
||||
|
||||
double norm2() const;
|
||||
// distance2 (IDENTITY), which is 3 - Tr ( *this )
|
||||
|
||||
inline void rectify();
|
||||
// non-const but logically moot correction for accumulated roundoff errors
|
||||
|
||||
// ---------- Application:
|
||||
|
||||
inline Hep3Vector operator() (const Hep3Vector & p) const;
|
||||
// Rotate a Hep3Vector.
|
||||
|
||||
inline Hep3Vector operator * (const Hep3Vector & p) const;
|
||||
// Multiplication with a Hep3Vector.
|
||||
|
||||
inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
|
||||
// Rotate (the space part of) a HepLorentzVector.
|
||||
|
||||
inline HepLorentzVector operator* ( const HepLorentzVector & w ) const;
|
||||
// Multiplication with a HepLorentzVector.
|
||||
|
||||
// ---------- Operations in the group of Rotations
|
||||
|
||||
inline HepRotationZ operator * (const HepRotationZ & rz) const;
|
||||
// Product of two Z rotations: (this) * rz is known to be RotationZ.
|
||||
|
||||
// Product of two rotations (this) * b - matrix multiplication
|
||||
|
||||
inline HepRotationZ & operator *= (const HepRotationZ & r);
|
||||
inline HepRotationZ & transform (const HepRotationZ & r);
|
||||
// Matrix multiplication.
|
||||
// Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a;
|
||||
// However, in this special case, they commute: Both just add deltas.
|
||||
|
||||
inline HepRotationZ inverse() const;
|
||||
// Returns the inverse.
|
||||
|
||||
friend HepRotationZ inverseOf(const HepRotationZ & r);
|
||||
// Returns the inverse of a RotationZ.
|
||||
|
||||
inline HepRotationZ & invert();
|
||||
// Inverts the Rotation matrix (be negating delta).
|
||||
|
||||
// ---------- I/O:
|
||||
|
||||
std::ostream & print( std::ostream & os ) const;
|
||||
// Output, identifying type of rotation and delta.
|
||||
|
||||
// ---------- Tolerance
|
||||
|
||||
static inline double getTolerance();
|
||||
static inline double setTolerance(double tol);
|
||||
|
||||
protected:
|
||||
|
||||
double d;
|
||||
// The angle of rotation.
|
||||
|
||||
double s;
|
||||
double c;
|
||||
// Cache the trig functions, for rapid operations.
|
||||
|
||||
inline HepRotationZ ( double dd, double ss, double cc );
|
||||
// Unchecked load-the-data-members
|
||||
|
||||
static inline double proper (double delta);
|
||||
// Put an angle into the range of (-PI, PI]. Useful helper method.
|
||||
|
||||
}; // HepRotationZ
|
||||
|
||||
inline
|
||||
std::ostream & operator <<
|
||||
( std::ostream & os, const HepRotationZ & r ) {return r.print(os);}
|
||||
|
||||
// ---------- Free-function operations in the group of Rotations
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/RotationZ.icc"
|
||||
|
||||
#endif /* HEP_ROTATIONZ_H */
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// HepRotationZ class
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
#include "CLHEP/Units/PhysicalConstants.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
inline double HepRotationZ::xx() const { return c; }
|
||||
inline double HepRotationZ::xy() const { return -s; }
|
||||
inline double HepRotationZ::yx() const { return s; }
|
||||
inline double HepRotationZ::yy() const { return c; }
|
||||
|
||||
inline double HepRotationZ::zz() const { return 1.0; }
|
||||
inline double HepRotationZ::zy() const { return 0.0; }
|
||||
inline double HepRotationZ::zx() const { return 0.0; }
|
||||
inline double HepRotationZ::yz() const { return 0.0; }
|
||||
inline double HepRotationZ::xz() const { return 0.0; }
|
||||
|
||||
inline HepRep3x3 HepRotationZ::rep3x3() const {
|
||||
return HepRep3x3 ( c, -s, 0.0,
|
||||
s, c, 0.0,
|
||||
0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
inline HepRotationZ::HepRotationZ() : d(0.0), s(0.0), c(1.0) {}
|
||||
|
||||
inline HepRotationZ::HepRotationZ(const HepRotationZ & orig) :
|
||||
d(orig.d), s(orig.s), c(orig.c)
|
||||
{}
|
||||
|
||||
inline HepRotationZ::HepRotationZ(double dd, double ss, double cc) :
|
||||
d(dd), s(ss), c(cc)
|
||||
{}
|
||||
|
||||
inline HepRotationZ & HepRotationZ::operator= (const HepRotationZ & orig) {
|
||||
d = orig.d;
|
||||
s = orig.s;
|
||||
c = orig.c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline HepRotationZ::~HepRotationZ() {}
|
||||
|
||||
inline Hep3Vector HepRotationZ::colX() const
|
||||
{ return Hep3Vector ( c, s, 0.0 ); }
|
||||
inline Hep3Vector HepRotationZ::colY() const
|
||||
{ return Hep3Vector ( -s, c, 0.0 ); }
|
||||
inline Hep3Vector HepRotationZ::colZ() const
|
||||
{ return Hep3Vector ( 0.0, 0.0, 1.0 ); }
|
||||
|
||||
inline Hep3Vector HepRotationZ::rowX() const
|
||||
{ return Hep3Vector ( c, -s, 0.0 ); }
|
||||
inline Hep3Vector HepRotationZ::rowY() const
|
||||
{ return Hep3Vector ( s, c, 0.0 ); }
|
||||
inline Hep3Vector HepRotationZ::rowZ() const
|
||||
{ return Hep3Vector ( 0.0, 0.0, 1.0 ); }
|
||||
|
||||
inline double HepRotationZ::getPhi () const { return phi(); }
|
||||
inline double HepRotationZ::getTheta() const { return theta(); }
|
||||
inline double HepRotationZ::getPsi () const { return psi(); }
|
||||
inline double HepRotationZ::getDelta() const { return d; }
|
||||
inline Hep3Vector HepRotationZ::getAxis () const { return axis(); }
|
||||
|
||||
inline double HepRotationZ::delta() const { return d; }
|
||||
inline Hep3Vector HepRotationZ::axis() const { return Hep3Vector(0,0,1); }
|
||||
|
||||
inline HepAxisAngle HepRotationZ::axisAngle() const {
|
||||
return HepAxisAngle ( axis(), delta() );
|
||||
}
|
||||
|
||||
inline void HepRotationZ::getAngleAxis
|
||||
(double & delta, Hep3Vector & axis) const {
|
||||
delta = d;
|
||||
axis = getAxis();
|
||||
}
|
||||
|
||||
inline bool HepRotationZ::isIdentity() const {
|
||||
return ( d==0 );
|
||||
}
|
||||
|
||||
inline int HepRotationZ::compare ( const HepRotationZ & r ) const {
|
||||
if (d > r.d) return 1; else if (d < r.d) return -1; else return 0;
|
||||
}
|
||||
|
||||
inline bool HepRotationZ::operator==(const HepRotationZ & r) const
|
||||
{ return (d==r.d); }
|
||||
inline bool HepRotationZ::operator!=(const HepRotationZ & r) const
|
||||
{ return (d!=r.d); }
|
||||
inline bool HepRotationZ::operator>=(const HepRotationZ & r) const
|
||||
{ return (d>=r.d); }
|
||||
inline bool HepRotationZ::operator<=(const HepRotationZ & r) const
|
||||
{ return (d<=r.d); }
|
||||
inline bool HepRotationZ::operator> (const HepRotationZ & r) const
|
||||
{ return (d> r.d); }
|
||||
inline bool HepRotationZ::operator< (const HepRotationZ & r) const
|
||||
{ return (d< r.d); }
|
||||
|
||||
inline void HepRotationZ::rectify() {
|
||||
d = proper(d); // Just in case!
|
||||
s = std::sin(d);
|
||||
c = std::cos(d);
|
||||
}
|
||||
|
||||
inline Hep3Vector HepRotationZ::operator() (const Hep3Vector & p) const {
|
||||
double x = p.x();
|
||||
double y = p.y();
|
||||
double z = p.z();
|
||||
return Hep3Vector( x * c - y * s,
|
||||
x * s + y * c,
|
||||
z );
|
||||
}
|
||||
|
||||
inline Hep3Vector HepRotationZ::operator * (const Hep3Vector & p) const {
|
||||
return operator()(p);
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepRotationZ::operator()
|
||||
( const HepLorentzVector & w ) const {
|
||||
return HepLorentzVector( operator() (w.vect()) , w.t() );
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepRotationZ::operator *
|
||||
(const HepLorentzVector & p) const {
|
||||
return operator()(p);
|
||||
}
|
||||
|
||||
inline HepRotationZ & HepRotationZ::operator *= (const HepRotationZ & m) {
|
||||
return *this = (*this) * (m);
|
||||
}
|
||||
|
||||
inline HepRotationZ & HepRotationZ::transform(const HepRotationZ & m) {
|
||||
return *this = m * (*this);
|
||||
}
|
||||
|
||||
inline double HepRotationZ::proper( double delta ) {
|
||||
// -PI < d <= PI
|
||||
if ( std::fabs(delta) < CLHEP::pi ) {
|
||||
return delta;
|
||||
} else {
|
||||
register double x = delta / (CLHEP::twopi);
|
||||
return (CLHEP::twopi) * ( x + std::floor(.5-x) );
|
||||
}
|
||||
} // proper()
|
||||
|
||||
inline HepRotationZ HepRotationZ::operator * ( const HepRotationZ & rz ) const {
|
||||
return HepRotationZ ( HepRotationZ::proper(d+rz.d),
|
||||
s*rz.c + c*rz.s,
|
||||
c*rz.c - s*rz.s );
|
||||
}
|
||||
|
||||
inline HepRotationZ HepRotationZ::inverse() const {
|
||||
return HepRotationZ( proper(-d), -s, c );
|
||||
}
|
||||
|
||||
inline HepRotationZ inverseOf(const HepRotationZ & r) {
|
||||
return r.inverse();
|
||||
}
|
||||
|
||||
inline HepRotationZ & HepRotationZ::invert() {
|
||||
return *this=inverse();
|
||||
}
|
||||
|
||||
inline HepLorentzVector HepRotationZ::col1() const
|
||||
{ return HepLorentzVector (colX(), 0); }
|
||||
inline HepLorentzVector HepRotationZ::col2() const
|
||||
{ return HepLorentzVector (colY(), 0); }
|
||||
inline HepLorentzVector HepRotationZ::col3() const
|
||||
{ return HepLorentzVector (colZ(), 0); }
|
||||
inline HepLorentzVector HepRotationZ::col4() const
|
||||
{ return HepLorentzVector (0,0,0,1); }
|
||||
inline HepLorentzVector HepRotationZ::row1() const
|
||||
{ return HepLorentzVector (rowX(), 0); }
|
||||
inline HepLorentzVector HepRotationZ::row2() const
|
||||
{ return HepLorentzVector (rowY(), 0); }
|
||||
inline HepLorentzVector HepRotationZ::row3() const
|
||||
{ return HepLorentzVector (rowZ(), 0); }
|
||||
inline HepLorentzVector HepRotationZ::row4() const
|
||||
{ return HepLorentzVector (0,0,0,1); }
|
||||
inline double HepRotationZ::xt() const { return 0.0; }
|
||||
inline double HepRotationZ::yt() const { return 0.0; }
|
||||
inline double HepRotationZ::zt() const { return 0.0; }
|
||||
inline double HepRotationZ::tx() const { return 0.0; }
|
||||
inline double HepRotationZ::ty() const { return 0.0; }
|
||||
inline double HepRotationZ::tz() const { return 0.0; }
|
||||
inline double HepRotationZ::tt() const { return 1.0; }
|
||||
|
||||
inline HepRep4x4 HepRotationZ::rep4x4() const {
|
||||
return HepRep4x4 ( c, -s, 0.0, 0.0,
|
||||
s, c, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
inline double HepRotationZ::getTolerance() {
|
||||
return Hep4RotationInterface::tolerance;
|
||||
}
|
||||
inline double HepRotationZ::setTolerance(double tol) {
|
||||
return Hep4RotationInterface::setTolerance(tol);
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,449 @@
|
||||
// -*- C++ -*-
|
||||
// CLASSDOC OFF
|
||||
// $Id:$
|
||||
// ---------------------------------------------------------------------------
|
||||
// CLASSDOC ON
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// Hep3Vector is a general 3-vector class defining vectors in three
|
||||
// dimension using double components. Rotations of these vectors are
|
||||
// performed by multiplying with an object of the HepRotation class.
|
||||
//
|
||||
// .SS See Also
|
||||
// LorentzVector.h, Rotation.h, LorentzRotation.h
|
||||
//
|
||||
// .SS Authors
|
||||
// Leif Lonnblad and Anders Nilsson; Modified by Evgueni Tcherniaev;
|
||||
// ZOOM additions by Mark Fischler
|
||||
//
|
||||
|
||||
#ifndef HEP_THREEVECTOR_H
|
||||
#define HEP_THREEVECTOR_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include "CLHEP/Utility/defs.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
class HepRotation;
|
||||
class HepEulerAngles;
|
||||
class HepAxisAngle;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class Hep3Vector {
|
||||
|
||||
public:
|
||||
|
||||
// Basic properties and operations on 3-vectors:
|
||||
|
||||
enum { X=0, Y=1, Z=2, NUM_COORDINATES=3, SIZE=NUM_COORDINATES };
|
||||
// Safe indexing of the coordinates when using with matrices, arrays, etc.
|
||||
// (BaBar)
|
||||
|
||||
Hep3Vector();
|
||||
explicit Hep3Vector(double x);
|
||||
Hep3Vector(double x, double y);
|
||||
Hep3Vector(double x, double y, double z);
|
||||
// The constructor.
|
||||
|
||||
inline Hep3Vector(const Hep3Vector &);
|
||||
// The copy constructor.
|
||||
|
||||
inline ~Hep3Vector();
|
||||
// The destructor. Not virtual - inheritance from this class is dangerous.
|
||||
|
||||
double operator () (int) const;
|
||||
// Get components by index -- 0-based (Geant4)
|
||||
|
||||
inline double operator [] (int) const;
|
||||
// Get components by index -- 0-based (Geant4)
|
||||
|
||||
double & operator () (int);
|
||||
// Set components by index. 0-based.
|
||||
|
||||
inline double & operator [] (int);
|
||||
// Set components by index. 0-based.
|
||||
|
||||
inline double x() const;
|
||||
inline double y() const;
|
||||
inline double z() const;
|
||||
// The components in cartesian coordinate system. Same as getX() etc.
|
||||
|
||||
inline void setX(double);
|
||||
inline void setY(double);
|
||||
inline void setZ(double);
|
||||
// Set the components in cartesian coordinate system.
|
||||
|
||||
inline void set( double x, double y, double z);
|
||||
// Set all three components in cartesian coordinate system.
|
||||
|
||||
inline double phi() const;
|
||||
// The azimuth angle.
|
||||
|
||||
inline double theta() const;
|
||||
// The polar angle.
|
||||
|
||||
inline double cosTheta() const;
|
||||
// Cosine of the polar angle.
|
||||
|
||||
inline double cos2Theta() const;
|
||||
// Cosine squared of the polar angle - faster than cosTheta(). (ZOOM)
|
||||
|
||||
inline double mag2() const;
|
||||
// The magnitude squared (r^2 in spherical coordinate system).
|
||||
|
||||
inline double mag() const;
|
||||
// The magnitude (r in spherical coordinate system).
|
||||
|
||||
inline void setPhi(double);
|
||||
// Set phi keeping mag and theta constant (BaBar).
|
||||
|
||||
inline void setTheta(double);
|
||||
// Set theta keeping mag and phi constant (BaBar).
|
||||
|
||||
void setMag(double);
|
||||
// Set magnitude keeping theta and phi constant (BaBar).
|
||||
|
||||
inline double perp2() const;
|
||||
// The transverse component squared (rho^2 in cylindrical coordinate system).
|
||||
|
||||
inline double perp() const;
|
||||
// The transverse component (rho in cylindrical coordinate system).
|
||||
|
||||
inline void setPerp(double);
|
||||
// Set the transverse component keeping phi and z constant.
|
||||
|
||||
void setCylTheta(double);
|
||||
// Set theta while keeping transvers component and phi fixed
|
||||
|
||||
inline double perp2(const Hep3Vector &) const;
|
||||
// The transverse component w.r.t. given axis squared.
|
||||
|
||||
inline double perp(const Hep3Vector &) const;
|
||||
// The transverse component w.r.t. given axis.
|
||||
|
||||
inline Hep3Vector & operator = (const Hep3Vector &);
|
||||
// Assignment.
|
||||
|
||||
inline bool operator == (const Hep3Vector &) const;
|
||||
inline bool operator != (const Hep3Vector &) const;
|
||||
// Comparisons (Geant4).
|
||||
|
||||
bool isNear (const Hep3Vector &, double epsilon=tolerance) const;
|
||||
// Check for equality within RELATIVE tolerance (default 2.2E-14). (ZOOM)
|
||||
// |v1 - v2|**2 <= epsilon**2 * |v1.dot(v2)|
|
||||
|
||||
double howNear(const Hep3Vector & v ) const;
|
||||
// std::sqrt ( |v1-v2|**2 / v1.dot(v2) ) with a maximum of 1.
|
||||
// If v1.dot(v2) is negative, will return 1.
|
||||
|
||||
double deltaR(const Hep3Vector & v) const;
|
||||
// std::sqrt( pseudorapity_difference**2 + deltaPhi **2 )
|
||||
|
||||
inline Hep3Vector & operator += (const Hep3Vector &);
|
||||
// Addition.
|
||||
|
||||
inline Hep3Vector & operator -= (const Hep3Vector &);
|
||||
// Subtraction.
|
||||
|
||||
inline Hep3Vector operator - () const;
|
||||
// Unary minus.
|
||||
|
||||
inline Hep3Vector & operator *= (double);
|
||||
// Scaling with real numbers.
|
||||
|
||||
Hep3Vector & operator /= (double);
|
||||
// Division by (non-zero) real number.
|
||||
|
||||
inline Hep3Vector unit() const;
|
||||
// Vector parallel to this, but of length 1.
|
||||
|
||||
inline Hep3Vector orthogonal() const;
|
||||
// Vector orthogonal to this (Geant4).
|
||||
|
||||
inline double dot(const Hep3Vector &) const;
|
||||
// double product.
|
||||
|
||||
inline Hep3Vector cross(const Hep3Vector &) const;
|
||||
// Cross product.
|
||||
|
||||
double angle(const Hep3Vector &) const;
|
||||
// The angle w.r.t. another 3-vector.
|
||||
|
||||
double pseudoRapidity() const;
|
||||
// Returns the pseudo-rapidity, i.e. -ln(std::tan(theta/2))
|
||||
|
||||
void setEta ( double p );
|
||||
// Set pseudo-rapidity, keeping magnitude and phi fixed. (ZOOM)
|
||||
|
||||
void setCylEta ( double p );
|
||||
// Set pseudo-rapidity, keeping transverse component and phi fixed. (ZOOM)
|
||||
|
||||
Hep3Vector & rotateX(double);
|
||||
// Rotates the Hep3Vector around the x-axis.
|
||||
|
||||
Hep3Vector & rotateY(double);
|
||||
// Rotates the Hep3Vector around the y-axis.
|
||||
|
||||
Hep3Vector & rotateZ(double);
|
||||
// Rotates the Hep3Vector around the z-axis.
|
||||
|
||||
Hep3Vector & rotateUz(const Hep3Vector&);
|
||||
// Rotates reference frame from Uz to newUz (unit vector) (Geant4).
|
||||
|
||||
Hep3Vector & rotate(double, const Hep3Vector &);
|
||||
// Rotates around the axis specified by another Hep3Vector.
|
||||
// (Uses methods of HepRotation, forcing linking in of Rotation.cc.)
|
||||
|
||||
Hep3Vector & operator *= (const HepRotation &);
|
||||
Hep3Vector & transform(const HepRotation &);
|
||||
// Transformation with a Rotation matrix.
|
||||
|
||||
// = = = = = = = = = = = = = = = = = = = = = = = =
|
||||
//
|
||||
// Esoteric properties and operations on 3-vectors:
|
||||
//
|
||||
// 1 - Set vectors in various coordinate systems
|
||||
// 2 - Synonyms for accessing coordinates and properties
|
||||
// 3 - Comparisions (dictionary, near-ness, and geometric)
|
||||
// 4 - Intrinsic properties
|
||||
// 5 - Properties releative to z axis and arbitrary directions
|
||||
// 6 - Polar and azimuthal angle decomposition and deltaPhi
|
||||
// 7 - Rotations
|
||||
//
|
||||
// = = = = = = = = = = = = = = = = = = = = = = = =
|
||||
|
||||
// 1 - Set vectors in various coordinate systems
|
||||
|
||||
inline void setRThetaPhi (double r, double theta, double phi);
|
||||
// Set in spherical coordinates: Angles are measured in RADIANS
|
||||
|
||||
inline void setREtaPhi ( double r, double eta, double phi );
|
||||
// Set in spherical coordinates, but specify peudorapidiy to determine theta.
|
||||
|
||||
inline void setRhoPhiZ (double rho, double phi, double z);
|
||||
// Set in cylindrical coordinates: Phi angle is measured in RADIANS
|
||||
|
||||
void setRhoPhiTheta ( double rho, double phi, double theta);
|
||||
// Set in cylindrical coordinates, but specify theta to determine z.
|
||||
|
||||
void setRhoPhiEta ( double rho, double phi, double eta);
|
||||
// Set in cylindrical coordinates, but specify pseudorapidity to determine z.
|
||||
|
||||
// 2 - Synonyms for accessing coordinates and properties
|
||||
|
||||
inline double getX() const;
|
||||
inline double getY() const;
|
||||
inline double getZ() const;
|
||||
// x(), y(), and z()
|
||||
|
||||
inline double getR () const;
|
||||
inline double getTheta() const;
|
||||
inline double getPhi () const;
|
||||
// mag(), theta(), and phi()
|
||||
|
||||
inline double r () const;
|
||||
// mag()
|
||||
|
||||
inline double rho () const;
|
||||
inline double getRho () const;
|
||||
// perp()
|
||||
|
||||
double eta () const;
|
||||
double getEta () const;
|
||||
// pseudoRapidity()
|
||||
|
||||
inline void setR ( double s );
|
||||
// setMag()
|
||||
|
||||
inline void setRho ( double s );
|
||||
// setPerp()
|
||||
|
||||
// 3 - Comparisions (dictionary, near-ness, and geometric)
|
||||
|
||||
int compare (const Hep3Vector & v) const;
|
||||
bool operator > (const Hep3Vector & v) const;
|
||||
bool operator < (const Hep3Vector & v) const;
|
||||
bool operator>= (const Hep3Vector & v) const;
|
||||
bool operator<= (const Hep3Vector & v) const;
|
||||
// dictionary ordering according to z, then y, then x component
|
||||
|
||||
inline double diff2 (const Hep3Vector & v) const;
|
||||
// |v1-v2|**2
|
||||
|
||||
static double setTolerance (double tol);
|
||||
static inline double getTolerance ();
|
||||
// Set the tolerance used in isNear() for Hep3Vectors
|
||||
|
||||
bool isParallel (const Hep3Vector & v, double epsilon=tolerance) const;
|
||||
// Are the vectors parallel, within the given tolerance?
|
||||
|
||||
bool isOrthogonal (const Hep3Vector & v, double epsilon=tolerance) const;
|
||||
// Are the vectors orthogonal, within the given tolerance?
|
||||
|
||||
double howParallel (const Hep3Vector & v) const;
|
||||
// | v1.cross(v2) / v1.dot(v2) |, to a maximum of 1.
|
||||
|
||||
double howOrthogonal (const Hep3Vector & v) const;
|
||||
// | v1.dot(v2) / v1.cross(v2) |, to a maximum of 1.
|
||||
|
||||
enum { ToleranceTicks = 100 };
|
||||
|
||||
// 4 - Intrinsic properties
|
||||
|
||||
double beta () const;
|
||||
// relativistic beta (considering v as a velocity vector with c=1)
|
||||
// Same as mag() but will object if >= 1
|
||||
|
||||
double gamma() const;
|
||||
// relativistic gamma (considering v as a velocity vector with c=1)
|
||||
|
||||
double coLinearRapidity() const;
|
||||
// inverse std::tanh (beta)
|
||||
|
||||
// 5 - Properties relative to Z axis and to an arbitrary direction
|
||||
|
||||
// Note that the non-esoteric CLHEP provides
|
||||
// theta(), cosTheta(), cos2Theta, and angle(const Hep3Vector&)
|
||||
|
||||
inline double angle() const;
|
||||
// angle against the Z axis -- synonym for theta()
|
||||
|
||||
inline double theta(const Hep3Vector & v2) const;
|
||||
// synonym for angle(v2)
|
||||
|
||||
double cosTheta (const Hep3Vector & v2) const;
|
||||
double cos2Theta(const Hep3Vector & v2) const;
|
||||
// cos and cos^2 of the angle between two vectors
|
||||
|
||||
inline Hep3Vector project () const;
|
||||
Hep3Vector project (const Hep3Vector & v2) const;
|
||||
// projection of a vector along a direction.
|
||||
|
||||
inline Hep3Vector perpPart() const;
|
||||
inline Hep3Vector perpPart (const Hep3Vector & v2) const;
|
||||
// vector minus its projection along a direction.
|
||||
|
||||
double rapidity () const;
|
||||
// inverse std::tanh(v.z())
|
||||
|
||||
double rapidity (const Hep3Vector & v2) const;
|
||||
// rapidity with respect to specified direction:
|
||||
// inverse std::tanh (v.dot(u)) where u is a unit in the direction of v2
|
||||
|
||||
double eta(const Hep3Vector & v2) const;
|
||||
// - ln tan of the angle beween the vector and the ref direction.
|
||||
|
||||
// 6 - Polar and azimuthal angle decomposition and deltaPhi
|
||||
|
||||
// Decomposition of an angle within reference defined by a direction:
|
||||
|
||||
double polarAngle (const Hep3Vector & v2) const;
|
||||
// The reference direction is Z: the polarAngle is std::abs(v.theta()-v2.theta()).
|
||||
|
||||
double deltaPhi (const Hep3Vector & v2) const;
|
||||
// v.phi()-v2.phi(), brought into the range (-PI,PI]
|
||||
|
||||
double azimAngle (const Hep3Vector & v2) const;
|
||||
// The reference direction is Z: the azimAngle is the same as deltaPhi
|
||||
|
||||
double polarAngle (const Hep3Vector & v2,
|
||||
const Hep3Vector & ref) const;
|
||||
// For arbitrary reference direction,
|
||||
// polarAngle is std::abs(v.angle(ref) - v2.angle(ref)).
|
||||
|
||||
double azimAngle (const Hep3Vector & v2,
|
||||
const Hep3Vector & ref) const;
|
||||
// To compute azimangle, project v and v2 into the plane normal to
|
||||
// the reference direction. Then in that plane take the angle going
|
||||
// clockwise around the direction from projection of v to that of v2.
|
||||
|
||||
// 7 - Rotations
|
||||
|
||||
// These mehtods **DO NOT** use anything in the HepRotation class.
|
||||
// Thus, use of v.rotate(axis,delta) does not force linking in Rotation.cc.
|
||||
|
||||
Hep3Vector & rotate (const Hep3Vector & axis, double delta);
|
||||
// Synonym for rotate (delta, axis)
|
||||
|
||||
Hep3Vector & rotate (const HepAxisAngle & ax);
|
||||
// HepAxisAngle is a struct holding an axis direction and an angle.
|
||||
|
||||
Hep3Vector & rotate (const HepEulerAngles & e);
|
||||
Hep3Vector & rotate (double phi,
|
||||
double theta,
|
||||
double psi);
|
||||
// Rotate via Euler Angles. Our Euler Angles conventions are
|
||||
// those of Goldstein Classical Mechanics page 107.
|
||||
|
||||
protected:
|
||||
void setSpherical (double r, double theta, double phi);
|
||||
void setCylindrical (double r, double phi, double z);
|
||||
double negativeInfinity() const;
|
||||
|
||||
protected:
|
||||
|
||||
double dx;
|
||||
double dy;
|
||||
double dz;
|
||||
// The components.
|
||||
|
||||
DLL_API static double tolerance;
|
||||
// default tolerance criterion for isNear() to return true.
|
||||
}; // Hep3Vector
|
||||
|
||||
// Global Methods
|
||||
|
||||
Hep3Vector rotationXOf (const Hep3Vector & vec, double delta);
|
||||
Hep3Vector rotationYOf (const Hep3Vector & vec, double delta);
|
||||
Hep3Vector rotationZOf (const Hep3Vector & vec, double delta);
|
||||
|
||||
Hep3Vector rotationOf (const Hep3Vector & vec,
|
||||
const Hep3Vector & axis, double delta);
|
||||
Hep3Vector rotationOf (const Hep3Vector & vec, const HepAxisAngle & ax);
|
||||
|
||||
Hep3Vector rotationOf (const Hep3Vector & vec,
|
||||
double phi, double theta, double psi);
|
||||
Hep3Vector rotationOf (const Hep3Vector & vec, const HepEulerAngles & e);
|
||||
// Return a new vector based on a rotation of the supplied vector
|
||||
|
||||
std::ostream & operator << (std::ostream &, const Hep3Vector &);
|
||||
// Output to a stream.
|
||||
|
||||
std::istream & operator >> (std::istream &, Hep3Vector &);
|
||||
// Input from a stream.
|
||||
|
||||
extern DLL_API const Hep3Vector HepXHat, HepYHat, HepZHat;
|
||||
|
||||
typedef Hep3Vector HepThreeVectorD;
|
||||
typedef Hep3Vector HepThreeVectorF;
|
||||
|
||||
Hep3Vector operator / (const Hep3Vector &, double a);
|
||||
// Division of 3-vectors by non-zero real number
|
||||
|
||||
inline Hep3Vector operator + (const Hep3Vector &, const Hep3Vector &);
|
||||
// Addition of 3-vectors.
|
||||
|
||||
inline Hep3Vector operator - (const Hep3Vector &, const Hep3Vector &);
|
||||
// Subtraction of 3-vectors.
|
||||
|
||||
inline double operator * (const Hep3Vector &, const Hep3Vector &);
|
||||
// double product of 3-vectors.
|
||||
|
||||
inline Hep3Vector operator * (const Hep3Vector &, double a);
|
||||
inline Hep3Vector operator * (double a, const Hep3Vector &);
|
||||
// Scaling of 3-vectors with a real number
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/ThreeVector.icc"
|
||||
|
||||
#endif /* HEP_THREEVECTOR_H */
|
||||
@@ -0,0 +1,292 @@
|
||||
// -*- C++ -*-
|
||||
// $Id:$
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// Hep3Vector class.
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// ------------------
|
||||
// Access to elements
|
||||
// ------------------
|
||||
|
||||
// x, y, z
|
||||
|
||||
inline double & Hep3Vector::operator[] (int i) { return operator()(i); }
|
||||
inline double Hep3Vector::operator[] (int i) const { return operator()(i); }
|
||||
|
||||
inline double Hep3Vector::x() const { return dx; }
|
||||
inline double Hep3Vector::y() const { return dy; }
|
||||
inline double Hep3Vector::z() const { return dz; }
|
||||
|
||||
inline double Hep3Vector::getX() const { return dx; }
|
||||
inline double Hep3Vector::getY() const { return dy; }
|
||||
inline double Hep3Vector::getZ() const { return dz; }
|
||||
|
||||
inline void Hep3Vector::setX(double x) { dx = x; }
|
||||
inline void Hep3Vector::setY(double y) { dy = y; }
|
||||
inline void Hep3Vector::setZ(double z) { dz = z; }
|
||||
|
||||
inline void Hep3Vector::set(double x, double y, double z) {
|
||||
dx = x;
|
||||
dy = y;
|
||||
dz = z;
|
||||
}
|
||||
|
||||
// --------------
|
||||
// Global methods
|
||||
// --------------
|
||||
|
||||
inline Hep3Vector operator + (const Hep3Vector & a, const Hep3Vector & b) {
|
||||
return Hep3Vector(a.x() + b.x(), a.y() + b.y(), a.z() + b.z());
|
||||
}
|
||||
|
||||
inline Hep3Vector operator - (const Hep3Vector & a, const Hep3Vector & b) {
|
||||
return Hep3Vector(a.x() - b.x(), a.y() - b.y(), a.z() - b.z());
|
||||
}
|
||||
|
||||
inline Hep3Vector operator * (const Hep3Vector & p, double a) {
|
||||
return Hep3Vector(a*p.x(), a*p.y(), a*p.z());
|
||||
}
|
||||
|
||||
inline Hep3Vector operator * (double a, const Hep3Vector & p) {
|
||||
return Hep3Vector(a*p.x(), a*p.y(), a*p.z());
|
||||
}
|
||||
|
||||
inline double operator * (const Hep3Vector & a, const Hep3Vector & b) {
|
||||
return a.dot(b);
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
// Set in various coordinates
|
||||
// --------------------------
|
||||
|
||||
inline void Hep3Vector::setRThetaPhi
|
||||
( double r, double theta, double phi ) {
|
||||
setSpherical (r, theta, phi);
|
||||
}
|
||||
|
||||
inline void Hep3Vector::setREtaPhi
|
||||
( double r, double eta, double phi ) {
|
||||
setSpherical (r, 2*std::atan(std::exp(-eta)), phi);
|
||||
}
|
||||
|
||||
inline void Hep3Vector::setRhoPhiZ
|
||||
( double rho, double phi, double z) {
|
||||
setCylindrical (rho, phi, z);
|
||||
}
|
||||
|
||||
// ------------
|
||||
// Constructors
|
||||
// ------------
|
||||
|
||||
inline Hep3Vector::Hep3Vector()
|
||||
: dx(0.), dy(0.), dz(0.) {}
|
||||
inline Hep3Vector::Hep3Vector(double x)
|
||||
: dx(x), dy(0.), dz(0.) {}
|
||||
inline Hep3Vector::Hep3Vector(double x, double y)
|
||||
: dx(x), dy(y), dz(0.) {}
|
||||
inline Hep3Vector::Hep3Vector(double x, double y, double z)
|
||||
: dx(x), dy(y), dz(z) {}
|
||||
|
||||
inline Hep3Vector::Hep3Vector(const Hep3Vector & p)
|
||||
: dx(p.dx), dy(p.dy), dz(p.dz) {}
|
||||
|
||||
inline Hep3Vector::~Hep3Vector() {}
|
||||
|
||||
inline Hep3Vector & Hep3Vector::operator = (const Hep3Vector & p) {
|
||||
dx = p.dx;
|
||||
dy = p.dy;
|
||||
dz = p.dz;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ------------------
|
||||
// Access to elements
|
||||
// ------------------
|
||||
|
||||
// r, theta, phi
|
||||
|
||||
inline double Hep3Vector::mag2() const { return dx*dx + dy*dy + dz*dz; }
|
||||
inline double Hep3Vector::mag() const { return std::sqrt(mag2()); }
|
||||
inline double Hep3Vector::r() const { return mag(); }
|
||||
|
||||
inline double Hep3Vector::theta() const {
|
||||
return dx == 0.0 && dy == 0.0 && dz == 0.0 ? 0.0 : std::atan2(perp(),dz);
|
||||
}
|
||||
inline double Hep3Vector::phi() const {
|
||||
return dx == 0.0 && dy == 0.0 ? 0.0 : std::atan2(dy,dx);
|
||||
}
|
||||
|
||||
inline double Hep3Vector::getR() const { return mag(); }
|
||||
inline double Hep3Vector::getTheta() const { return theta(); }
|
||||
inline double Hep3Vector::getPhi() const { return phi(); }
|
||||
inline double Hep3Vector::angle() const { return theta(); }
|
||||
|
||||
inline double Hep3Vector::cosTheta() const {
|
||||
double ptot = mag();
|
||||
return ptot == 0.0 ? 1.0 : dz/ptot;
|
||||
}
|
||||
|
||||
inline double Hep3Vector::cos2Theta() const {
|
||||
double ptot2 = mag2();
|
||||
return ptot2 == 0.0 ? 1.0 : dz*dz/ptot2;
|
||||
}
|
||||
|
||||
inline void Hep3Vector::setR(double r) { setMag(r); }
|
||||
|
||||
inline void Hep3Vector::setTheta(double th) {
|
||||
double ma = mag();
|
||||
double ph = phi();
|
||||
setX(ma*std::sin(th)*std::cos(ph));
|
||||
setY(ma*std::sin(th)*std::sin(ph));
|
||||
setZ(ma*std::cos(th));
|
||||
}
|
||||
|
||||
inline void Hep3Vector::setPhi(double ph) {
|
||||
double xy = perp();
|
||||
setX(xy*std::cos(ph));
|
||||
setY(xy*std::sin(ph));
|
||||
}
|
||||
|
||||
// perp, eta,
|
||||
|
||||
inline double Hep3Vector::perp2() const { return dx*dx + dy*dy; }
|
||||
inline double Hep3Vector::perp() const { return std::sqrt(perp2()); }
|
||||
inline double Hep3Vector::rho() const { return perp(); }
|
||||
inline double Hep3Vector::eta() const { return pseudoRapidity();}
|
||||
|
||||
inline double Hep3Vector::getRho() const { return perp(); }
|
||||
inline double Hep3Vector::getEta() const { return pseudoRapidity();}
|
||||
|
||||
inline void Hep3Vector::setPerp(double r) {
|
||||
double p = perp();
|
||||
if (p != 0.0) {
|
||||
dx *= r/p;
|
||||
dy *= r/p;
|
||||
}
|
||||
}
|
||||
inline void Hep3Vector::setRho(double rho) { setPerp (rho); }
|
||||
|
||||
// ----------
|
||||
// Comparison
|
||||
// ----------
|
||||
|
||||
inline bool Hep3Vector::operator == (const Hep3Vector& v) const {
|
||||
return (v.x()==x() && v.y()==y() && v.z()==z()) ? true : false;
|
||||
}
|
||||
|
||||
inline bool Hep3Vector::operator != (const Hep3Vector& v) const {
|
||||
return (v.x()!=x() || v.y()!=y() || v.z()!=z()) ? true : false;
|
||||
}
|
||||
|
||||
inline double Hep3Vector::getTolerance () {
|
||||
return tolerance;
|
||||
}
|
||||
|
||||
// ----------
|
||||
// Arithmetic
|
||||
// ----------
|
||||
|
||||
inline Hep3Vector& Hep3Vector::operator += (const Hep3Vector & p) {
|
||||
dx += p.x();
|
||||
dy += p.y();
|
||||
dz += p.z();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Hep3Vector& Hep3Vector::operator -= (const Hep3Vector & p) {
|
||||
dx -= p.x();
|
||||
dy -= p.y();
|
||||
dz -= p.z();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Hep3Vector Hep3Vector::operator - () const {
|
||||
return Hep3Vector(-dx, -dy, -dz);
|
||||
}
|
||||
|
||||
inline Hep3Vector& Hep3Vector::operator *= (double a) {
|
||||
dx *= a;
|
||||
dy *= a;
|
||||
dz *= a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// -------------------
|
||||
// Combine two Vectors
|
||||
// -------------------
|
||||
|
||||
inline double Hep3Vector::diff2(const Hep3Vector & p) const {
|
||||
return (*this-p).mag2();
|
||||
}
|
||||
|
||||
inline double Hep3Vector::dot(const Hep3Vector & p) const {
|
||||
return dx*p.x() + dy*p.y() + dz*p.z();
|
||||
}
|
||||
|
||||
inline Hep3Vector Hep3Vector::cross(const Hep3Vector & p) const {
|
||||
return Hep3Vector(dy*p.z()-p.y()*dz, dz*p.x()-p.z()*dx, dx*p.y()-p.x()*dy);
|
||||
}
|
||||
|
||||
inline double Hep3Vector::perp2(const Hep3Vector & p) const {
|
||||
double tot = p.mag2();
|
||||
double ss = dot(p);
|
||||
return tot > 0.0 ? mag2()-ss*ss/tot : mag2();
|
||||
}
|
||||
|
||||
inline double Hep3Vector::perp(const Hep3Vector & p) const {
|
||||
return std::sqrt(perp2(p));
|
||||
}
|
||||
|
||||
inline Hep3Vector Hep3Vector::perpPart () const {
|
||||
return Hep3Vector (dx, dy, 0);
|
||||
}
|
||||
inline Hep3Vector Hep3Vector::project () const {
|
||||
return Hep3Vector (0, 0, dz);
|
||||
}
|
||||
|
||||
inline Hep3Vector Hep3Vector::perpPart (const Hep3Vector & v2) const {
|
||||
return ( *this - project(v2) );
|
||||
}
|
||||
|
||||
inline double Hep3Vector::angle(const Hep3Vector & q) const {
|
||||
return std::acos(cosTheta(q));
|
||||
}
|
||||
|
||||
inline double Hep3Vector::theta(const Hep3Vector & q) const {
|
||||
return angle(q);
|
||||
}
|
||||
|
||||
inline double Hep3Vector::azimAngle(const Hep3Vector & v2) const {
|
||||
return deltaPhi(v2);
|
||||
}
|
||||
|
||||
// ----------
|
||||
// Properties
|
||||
// ----------
|
||||
|
||||
inline Hep3Vector Hep3Vector::unit() const {
|
||||
double tot = mag2();
|
||||
Hep3Vector p(x(),y(),z());
|
||||
return tot > 0.0 ? p *= (1.0/std::sqrt(tot)) : p;
|
||||
}
|
||||
|
||||
inline Hep3Vector Hep3Vector::orthogonal() const {
|
||||
double x = dx < 0.0 ? -dx : dx;
|
||||
double y = dy < 0.0 ? -dy : dy;
|
||||
double z = dz < 0.0 ? -dz : dz;
|
||||
if (x < y) {
|
||||
return x < z ? Hep3Vector(0,dz,-dy) : Hep3Vector(dy,-dx,0);
|
||||
}else{
|
||||
return y < z ? Hep3Vector(-dz,0,dx) : Hep3Vector(dy,-dx,0);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
@@ -0,0 +1,215 @@
|
||||
// -*- C++ -*-
|
||||
// CLASSDOC OFF
|
||||
// ---------------------------------------------------------------------------
|
||||
// CLASSDOC ON
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// Hep2Vector is a general 2-vector class defining vectors in two
|
||||
// dimension using double components. It comes from the ZOOM
|
||||
// PlaneVector class (the PhysicsVectors PlaneVector.h will typedef
|
||||
// PlaneVector to Hep2Vector).
|
||||
//
|
||||
// .SS See Also
|
||||
// ThreeVector.h
|
||||
//
|
||||
// .SS Authors
|
||||
// John Marraffino and Mark Fischler
|
||||
//
|
||||
|
||||
#ifndef HEP_TWOVECTOR_H
|
||||
#define HEP_TWOVECTOR_H
|
||||
|
||||
#ifdef GNUPRAGMA
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "CLHEP/Vector/ThreeVector.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
// Declarations of classes and global methods
|
||||
class Hep2Vector;
|
||||
std::ostream & operator << (std::ostream &, const Hep2Vector &);
|
||||
std::istream & operator >> (std::istream &, Hep2Vector &);
|
||||
inline double operator * (const Hep2Vector & a,const Hep2Vector & b);
|
||||
inline Hep2Vector operator * (const Hep2Vector & p, double a);
|
||||
inline Hep2Vector operator * (double a, const Hep2Vector & p);
|
||||
Hep2Vector operator / (const Hep2Vector & p, double a);
|
||||
inline Hep2Vector operator + (const Hep2Vector & a, const Hep2Vector & b);
|
||||
inline Hep2Vector operator - (const Hep2Vector & a, const Hep2Vector & b);
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @ingroup vector
|
||||
*/
|
||||
class Hep2Vector {
|
||||
|
||||
public:
|
||||
|
||||
enum { X=0, Y=1, NUM_COORDINATES=2, SIZE=NUM_COORDINATES };
|
||||
// Safe indexing of the coordinates when using with matrices, arrays, etc.
|
||||
|
||||
inline Hep2Vector( double x = 0.0, double y = 0.0 );
|
||||
// The constructor.
|
||||
|
||||
inline Hep2Vector(const Hep2Vector & p);
|
||||
// The copy constructor.
|
||||
|
||||
explicit Hep2Vector( const Hep3Vector & s);
|
||||
// "demotion" constructor"
|
||||
// WARNING -- THIS IGNORES THE Z COMPONENT OF THE Hep3Vector.
|
||||
// SO IN GENERAL, Hep2Vector(v)==v WILL NOT HOLD!
|
||||
|
||||
inline ~Hep2Vector();
|
||||
// The destructor.
|
||||
|
||||
inline double x() const;
|
||||
inline double y() const;
|
||||
// The components in cartesian coordinate system.
|
||||
|
||||
double operator () (int i) const;
|
||||
inline double operator [] (int i) const;
|
||||
// Get components by index. 0-based.
|
||||
|
||||
double & operator () (int i);
|
||||
inline double & operator [] (int i);
|
||||
// Set components by index. 0-based.
|
||||
|
||||
inline void setX(double x);
|
||||
inline void setY(double y);
|
||||
inline void set (double x, double y);
|
||||
// Set the components in cartesian coordinate system.
|
||||
|
||||
inline double phi() const;
|
||||
// The azimuth angle.
|
||||
|
||||
inline double mag2() const;
|
||||
// The magnitude squared.
|
||||
|
||||
inline double mag() const;
|
||||
// The magnitude.
|
||||
|
||||
inline double r() const;
|
||||
// r in polar coordinates (r, phi): equal to mag().
|
||||
|
||||
inline void setPhi(double phi);
|
||||
// Set phi keeping mag constant.
|
||||
|
||||
inline void setMag(double r);
|
||||
// Set magnitude keeping phi constant.
|
||||
|
||||
inline void setR(double r);
|
||||
// Set R keeping phi constant. Same as setMag.
|
||||
|
||||
inline void setPolar(double r, double phi);
|
||||
// Set by polar coordinates.
|
||||
|
||||
inline Hep2Vector & operator = (const Hep2Vector & p);
|
||||
// Assignment.
|
||||
|
||||
inline bool operator == (const Hep2Vector & v) const;
|
||||
inline bool operator != (const Hep2Vector & v) const;
|
||||
// Comparisons.
|
||||
|
||||
int compare (const Hep2Vector & v) const;
|
||||
bool operator > (const Hep2Vector & v) const;
|
||||
bool operator < (const Hep2Vector & v) const;
|
||||
bool operator>= (const Hep2Vector & v) const;
|
||||
bool operator<= (const Hep2Vector & v) const;
|
||||
// dictionary ordering according to y, then x component
|
||||
|
||||
static inline double getTolerance();
|
||||
static double setTolerance(double tol);
|
||||
|
||||
double howNear (const Hep2Vector &p) const;
|
||||
bool isNear (const Hep2Vector & p, double epsilon=tolerance) const;
|
||||
|
||||
double howParallel (const Hep2Vector &p) const;
|
||||
bool isParallel
|
||||
(const Hep2Vector & p, double epsilon=tolerance) const;
|
||||
|
||||
double howOrthogonal (const Hep2Vector &p) const;
|
||||
bool isOrthogonal
|
||||
(const Hep2Vector & p, double epsilon=tolerance) const;
|
||||
|
||||
inline Hep2Vector & operator += (const Hep2Vector &p);
|
||||
// Addition.
|
||||
|
||||
inline Hep2Vector & operator -= (const Hep2Vector &p);
|
||||
// Subtraction.
|
||||
|
||||
inline Hep2Vector operator - () const;
|
||||
// Unary minus.
|
||||
|
||||
inline Hep2Vector & operator *= (double a);
|
||||
// Scaling with real numbers.
|
||||
|
||||
inline Hep2Vector unit() const;
|
||||
// Unit vector parallel to this.
|
||||
|
||||
inline Hep2Vector orthogonal() const;
|
||||
// Vector orthogonal to this.
|
||||
|
||||
inline double dot(const Hep2Vector &p) const;
|
||||
// Scalar product.
|
||||
|
||||
inline double angle(const Hep2Vector &) const;
|
||||
// The angle w.r.t. another 2-vector.
|
||||
|
||||
void rotate(double);
|
||||
// Rotates the Hep2Vector.
|
||||
|
||||
operator Hep3Vector () const;
|
||||
// Cast a Hep2Vector as a Hep3Vector.
|
||||
|
||||
// The remaining methods are friends, thus defined at global scope:
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
friend std::ostream & operator<< (std::ostream &, const Hep2Vector &);
|
||||
// Output to a stream.
|
||||
|
||||
inline friend double operator * (const Hep2Vector & a,
|
||||
const Hep2Vector & b);
|
||||
// Scalar product.
|
||||
|
||||
inline friend Hep2Vector operator * (const Hep2Vector & p, double a);
|
||||
// v*c
|
||||
|
||||
inline friend Hep2Vector operator * (double a, const Hep2Vector & p);
|
||||
// c*v
|
||||
|
||||
friend Hep2Vector operator / (const Hep2Vector & p, double a);
|
||||
// v/c
|
||||
|
||||
inline friend Hep2Vector operator + (const Hep2Vector & a,
|
||||
const Hep2Vector & b);
|
||||
// v1+v2
|
||||
|
||||
inline friend Hep2Vector operator - (const Hep2Vector & a,
|
||||
const Hep2Vector & b);
|
||||
// v1-v2
|
||||
|
||||
enum { ZMpvToleranceTicks = 100 };
|
||||
|
||||
private:
|
||||
|
||||
double dx;
|
||||
double dy;
|
||||
// The components.
|
||||
|
||||
static double tolerance;
|
||||
// default tolerance criterion for isNear() to return true.
|
||||
|
||||
}; // Hep2Vector
|
||||
|
||||
static const Hep2Vector X_HAT2(1.0, 0.0);
|
||||
static const Hep2Vector Y_HAT2(0.0, 1.0);
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#include "CLHEP/Vector/TwoVector.icc"
|
||||
|
||||
#endif /* HEP_TWOVECTOR_H */
|
||||
@@ -0,0 +1,171 @@
|
||||
// -*- C++ -*-
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
||||
//
|
||||
// This is the definitions of the inline member functions of the
|
||||
// Hep2Vector class.
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
inline double Hep2Vector::x() const {
|
||||
return dx;
|
||||
}
|
||||
|
||||
inline double Hep2Vector::y() const {
|
||||
return dy;
|
||||
}
|
||||
|
||||
inline Hep2Vector::Hep2Vector(double x, double y)
|
||||
: dx(x), dy(y) {}
|
||||
|
||||
inline Hep2Vector::Hep2Vector( const Hep3Vector & s)
|
||||
: dx(s.x()), dy(s.y()) {}
|
||||
|
||||
inline void Hep2Vector::setX(double x) {
|
||||
dx = x;
|
||||
}
|
||||
|
||||
inline void Hep2Vector::setY(double y) {
|
||||
dy = y;
|
||||
}
|
||||
|
||||
inline void Hep2Vector::set(double x, double y) {
|
||||
dx = x;
|
||||
dy = y;
|
||||
}
|
||||
|
||||
double & Hep2Vector::operator[] (int i) { return operator()(i); }
|
||||
double Hep2Vector::operator[] (int i) const { return operator()(i); }
|
||||
|
||||
inline Hep2Vector::Hep2Vector(const Hep2Vector & p)
|
||||
: dx(p.x()), dy(p.y()) {}
|
||||
|
||||
inline Hep2Vector::~Hep2Vector() {}
|
||||
|
||||
inline Hep2Vector & Hep2Vector::operator = (const Hep2Vector & p) {
|
||||
dx = p.x();
|
||||
dy = p.y();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool Hep2Vector::operator == (const Hep2Vector& v) const {
|
||||
return (v.x()==x() && v.y()==y()) ? true : false;
|
||||
}
|
||||
|
||||
inline bool Hep2Vector::operator != (const Hep2Vector& v) const {
|
||||
return (v.x()!=x() || v.y()!=y()) ? true : false;
|
||||
}
|
||||
|
||||
inline Hep2Vector& Hep2Vector::operator += (const Hep2Vector & p) {
|
||||
dx += p.x();
|
||||
dy += p.y();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Hep2Vector& Hep2Vector::operator -= (const Hep2Vector & p) {
|
||||
dx -= p.x();
|
||||
dy -= p.y();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Hep2Vector Hep2Vector::operator - () const {
|
||||
return Hep2Vector(-dx, -dy);
|
||||
}
|
||||
|
||||
inline Hep2Vector& Hep2Vector::operator *= (double a) {
|
||||
dx *= a;
|
||||
dy *= a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline double Hep2Vector::dot(const Hep2Vector & p) const {
|
||||
return dx*p.x() + dy*p.y();
|
||||
}
|
||||
|
||||
inline double Hep2Vector::mag2() const {
|
||||
return dx*dx + dy*dy;
|
||||
}
|
||||
|
||||
inline double Hep2Vector::mag() const {
|
||||
return std::sqrt(mag2());
|
||||
}
|
||||
|
||||
inline double Hep2Vector::r() const {
|
||||
return std::sqrt(mag2());
|
||||
}
|
||||
|
||||
inline Hep2Vector Hep2Vector::unit() const {
|
||||
double tot = mag2();
|
||||
Hep2Vector p(*this);
|
||||
return tot > 0.0 ? p *= (1.0/std::sqrt(tot)) : Hep2Vector(1,0);
|
||||
}
|
||||
|
||||
inline Hep2Vector Hep2Vector::orthogonal() const {
|
||||
double x = std::fabs(dx), y = std::fabs(dy);
|
||||
if (x < y) {
|
||||
return Hep2Vector(dy,-dx);
|
||||
}else{
|
||||
return Hep2Vector(-dy,dx);
|
||||
}
|
||||
}
|
||||
|
||||
inline double Hep2Vector::phi() const {
|
||||
return dx == 0.0 && dy == 0.0 ? 0.0 : std::atan2(dy,dx);
|
||||
}
|
||||
|
||||
inline double Hep2Vector::angle(const Hep2Vector & q) const {
|
||||
double ptot2 = mag2()*q.mag2();
|
||||
return ptot2 <= 0.0 ? 0.0 : std::acos(dot(q)/std::sqrt(ptot2));
|
||||
}
|
||||
|
||||
inline void Hep2Vector::setMag(double r){
|
||||
double ph = phi();
|
||||
setX( r * std::cos(ph) );
|
||||
setY( r * std::sin(ph) );
|
||||
}
|
||||
|
||||
inline void Hep2Vector::setR(double r){
|
||||
setMag(r);
|
||||
}
|
||||
|
||||
inline void Hep2Vector::setPhi(double phi){
|
||||
double ma = mag();
|
||||
setX( ma * std::cos(phi) );
|
||||
setY( ma * std::sin(phi) );
|
||||
}
|
||||
|
||||
inline void Hep2Vector::setPolar(double r, double phi){
|
||||
setX( r * std::cos(phi) );
|
||||
setY( r * std::sin(phi) );
|
||||
}
|
||||
|
||||
inline Hep2Vector operator + (const Hep2Vector & a, const Hep2Vector & b) {
|
||||
return Hep2Vector(a.x() + b.x(), a.y() + b.y());
|
||||
}
|
||||
|
||||
inline Hep2Vector operator - (const Hep2Vector & a, const Hep2Vector & b) {
|
||||
return Hep2Vector(a.x() - b.x(), a.y() - b.y());
|
||||
}
|
||||
|
||||
inline Hep2Vector operator * (const Hep2Vector & p, double a) {
|
||||
return Hep2Vector(a*p.x(), a*p.y());
|
||||
}
|
||||
|
||||
inline Hep2Vector operator * (double a, const Hep2Vector & p) {
|
||||
return Hep2Vector(a*p.x(), a*p.y());
|
||||
}
|
||||
|
||||
inline double operator * (const Hep2Vector & a, const Hep2Vector & b) {
|
||||
return a.dot(b);
|
||||
}
|
||||
|
||||
inline double Hep2Vector::getTolerance () {
|
||||
return tolerance;
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
Reference in New Issue
Block a user