CLHEP/Vector/Boost.h

00001 // -*- C++ -*-
00002 //
00003 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
00004 //
00005 // This is the definition of the HepBoost class for performing specialized
00006 // Lorentz transformations which are pure boosts on objects of the
00007 // HepLorentzVector class.
00008 //
00009 // HepBoost is a concrete implementation of Hep4RotationInterface.
00010 //
00011 // .SS See Also
00012 // RotationInterfaces.h
00013 // LorentzVector.h LorentzRotation.h 
00014 //  BoostX.h BoostY.h BoostZ.h 
00015 //
00016 // .SS Author
00017 // Mark Fischler
00018 
00019 #ifndef HEP_BOOST_H
00020 #define HEP_BOOST_H
00021 
00022 #ifdef GNUPRAGMA
00023 #pragma interface
00024 #endif
00025 
00026 #ifdef HEP_NO_INLINE_IN_DECLARATION
00027 #define inline
00028 #endif
00029 
00030 #include "CLHEP/Vector/RotationInterfaces.h"
00031 #include "CLHEP/Vector/BoostX.h"
00032 #include "CLHEP/Vector/BoostY.h"
00033 #include "CLHEP/Vector/BoostZ.h"
00034 #include "CLHEP/Vector/LorentzVector.h"
00035 
00036 // Declarations of classes and global methods
00037 class HepBoost;
00038 inline HepBoost inverseOf ( const HepBoost & lt );
00039 
00044 class HepBoost {
00045 
00046 public:
00047 
00048   // ----------  Constructors and Assignment:
00049 
00050   inline HepBoost();
00051   // Default constructor. Gives a boost of 0.  
00052 
00053   inline HepBoost(const HepBoost & m);
00054   // Copy constructor.
00055 
00056   inline HepBoost & operator = (const HepBoost & m);
00057   // Assignment.
00058 
00059          HepBoost & set (double betaX, double betaY, double betaZ);
00060   inline HepBoost       (double betaX, double betaY, double betaZ);
00061   // Constructor from three components of beta vector
00062 
00063          HepBoost & set (const HepRep4x4Symmetric & m);
00064   inline HepBoost       (const HepRep4x4Symmetric & m);
00065   // Constructor from symmetric HepRep4x4
00066 
00067          HepBoost & set (Hep3Vector direction, double beta);
00068   inline HepBoost       (Hep3Vector direction, double beta);
00069   // Constructor from a three vector direction and the magnitude of beta
00070 
00071          HepBoost & set (const Hep3Vector & boost);
00072   inline HepBoost       (const Hep3Vector & boost);
00073   // Constructor from a 3-vector of less than unit length
00074 
00075   inline HepBoost & set (const HepBoostX & boost);
00076   inline HepBoost & set (const HepBoostY & boost);
00077   inline HepBoost & set (const HepBoostZ & boost);
00078   inline HepBoost       (const HepBoostX & boost);
00079   inline HepBoost       (const HepBoostY & boost);
00080   inline HepBoost       (const HepBoostZ & boost);
00081   
00082   // ----------  Accessors:
00083 
00084   inline double  beta()  const;
00085   inline double  gamma() const;
00086   inline Hep3Vector boostVector() const;
00087   inline Hep3Vector getDirection() const;
00088   inline Hep3Vector direction() const;
00089 
00090   inline double xx() const;
00091   inline double xy() const;
00092   inline double xz() const;
00093   inline double xt() const;
00094   inline double yx() const;
00095   inline double yy() const;
00096   inline double yz() const;
00097   inline double yt() const;
00098   inline double zx() const;
00099   inline double zy() const;
00100   inline double zz() const;
00101   inline double zt() const;
00102   inline double tx() const;
00103   inline double ty() const;
00104   inline double tz() const;
00105   inline double tt() const;
00106   // Elements of the matrix.
00107 
00108   inline HepLorentzVector col1() const;
00109   inline HepLorentzVector col2() const;
00110   inline HepLorentzVector col3() const;
00111   inline HepLorentzVector col4() const;
00112   // orthosymplectic column vectors
00113 
00114   inline HepLorentzVector row1() const;
00115   inline HepLorentzVector row2() const;
00116   inline HepLorentzVector row3() const;
00117   inline HepLorentzVector row4() const;
00118   // orthosymplectic row vectors
00119 
00120   inline HepRep4x4 rep4x4() const;
00121   //   4x4 representation.
00122 
00123   inline HepRep4x4Symmetric rep4x4Symmetric() const;
00124   //   Symmetric 4x4 representation.
00125 
00126   // ----------  Decomposition:
00127 
00128   void decompose (HepRotation  & rotation, HepBoost   & boost) const;
00129   void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
00130   // Find R and B such that L = R*B -- trivial, since R is identity
00131 
00132   void decompose (HepBoost   & boost, HepRotation  & rotation) const;
00133   void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
00134   // Find R and B such that L = B*R -- trivial, since R is identity
00135 
00136   // ----------  Comparisons:
00137 
00138   inline int compare( const HepBoost & b  ) const;
00139   // Dictionary-order comparison, in order tt,zt,zz,yt,yz,yy,xt,xz,xy,xx
00140   // Used in operator<, >, <=, >=
00141 
00142   inline bool operator == (const HepBoost & b) const;
00143   inline bool operator != (const HepBoost & b) const;
00144   inline bool operator <= (const HepBoost & b) const;
00145   inline bool operator >= (const HepBoost & b) const;
00146   inline bool operator <  (const HepBoost & b) const;
00147   inline bool operator >  (const HepBoost & b) const;
00148   // Comparisons.
00149 
00150   inline bool isIdentity() const;
00151   // Returns true if a null boost.
00152 
00153   inline  double distance2( const HepBoost  & b  ) const;
00154   inline  double distance2( const HepBoostX & bx ) const;
00155   inline  double distance2( const HepBoostY & by ) const;
00156   inline  double distance2( const HepBoostZ & bz ) const;
00157   // Defined as the distance2 between the vectors (gamma*betaVector)
00158 
00159   double distance2( const HepRotation & r  ) const;
00160   double distance2( const HepLorentzRotation & lt  ) const;
00161   // Distance between this and other sorts of transformations
00162 
00163   inline double howNear(   const HepBoost & b ) const;
00164   inline bool isNear(   const HepBoost & b,
00165              double epsilon=Hep4RotationInterface::tolerance) const;
00166 
00167   double howNear( const HepRotation & r  ) const;
00168   double howNear( const HepLorentzRotation & lt  ) const;
00169 
00170   bool isNear( const HepRotation & r, 
00171              double epsilon=Hep4RotationInterface::tolerance) const;
00172   bool isNear( const HepLorentzRotation & lt, 
00173              double epsilon=Hep4RotationInterface::tolerance) const;
00174 
00175   // ----------  Properties:
00176 
00177   double norm2() const;
00178   // (beta*gamma)^2
00179 
00180   void rectify();
00181   // set as an exact boost, based on the timelike part of the boost matrix.
00182 
00183   // ---------- Application:
00184 
00185   inline HepLorentzVector operator()( const HepLorentzVector & p ) const;
00186   // Transform a Lorentz Vector.             
00187 
00188   inline HepLorentzVector operator* ( const HepLorentzVector & p ) const;
00189   // Multiplication with a Lorentz Vector.
00190 
00191   // ---------- Operations in the group of 4-Rotations
00192 
00193   HepLorentzRotation operator * (const HepBoost & b) const;
00194   HepLorentzRotation operator * (const HepRotation & r) const;
00195   HepLorentzRotation operator * (const HepLorentzRotation & lt) const;
00196   // Product of two Lorentz Rotations (this) * lt - matrix multiplication  
00197   // Notice that the product of two pure boosts is no longer a pure boost
00198 
00199   inline HepBoost inverse() const;
00200   // Return the inverse.
00201 
00202   inline friend HepBoost inverseOf ( const HepBoost & lt );
00203   // global methods to invert.
00204 
00205   inline HepBoost & invert();
00206   // Inverts the Boost matrix.
00207 
00208   // ---------- I/O:
00209 
00210   HepStd::ostream & print( HepStd::ostream & os ) const;
00211   // Output form is (bx, by, bz) 
00212 
00213   // ---------- Tolerance              
00214 
00215   static inline double getTolerance();
00216   static inline double setTolerance(double tol);
00217 
00218 protected:
00219 
00220   inline HepLorentzVector vectorMultiplication 
00221                                         ( const HepLorentzVector & w ) const;
00222   // Multiplication with a Lorentz Vector.
00223 
00224   HepLorentzRotation matrixMultiplication (const HepRep4x4 & m) const;
00225   HepLorentzRotation matrixMultiplication (const HepRep4x4Symmetric & m) const;
00226 
00227   inline HepBoost
00228        (double xx, double xy, double xz, double xt,
00229                    double yy, double yz, double yt,
00230                               double zz, double zt,
00231                                          double tt);
00232   // Protected constructor.
00233   // DOES NOT CHECK FOR VALIDITY AS A LORENTZ BOOST.
00234 
00235   inline void setBoost(double bx, double by, double bz);
00236 
00237   HepRep4x4Symmetric rep_;
00238 
00239 };
00240 
00241 inline   
00242 HepStd::ostream & operator << 
00243         ( HepStd::ostream & os, const HepBoost& b ) {return b.print(os);}
00244 
00245 #ifdef HEP_NO_INLINE_IN_DECLARATION
00246 #undef inline
00247 #endif
00248 
00249 #ifdef HEP_SHORT_NAMES
00250 typedef HepBoost LBoost;
00251 #endif
00252 
00253 #ifndef HEP_DEBUG_INLINE
00254 #include "CLHEP/Vector/Boost.icc"
00255 #endif
00256 
00257 #endif /* HEP_BOOST_H */

Class Library for High Energy Physics (version 1.8)