Geant4 Cross Reference |
1 // -*- C++ -*- 1 // -*- C++ -*- 2 // 2 // 3 // This file is a part of the CLHEP - a Class 3 // This file is a part of the CLHEP - a Class Library for High Energy Physics. 4 // 4 // 5 // This is the definition of the HepBoost clas 5 // This is the definition of the HepBoost class for performing specialized 6 // Lorentz transformations which are pure boos 6 // Lorentz transformations which are pure boosts on objects of the 7 // HepLorentzVector class. 7 // HepLorentzVector class. 8 // 8 // 9 // HepBoost is a concrete implementation of He 9 // HepBoost is a concrete implementation of Hep4RotationInterface. 10 // 10 // 11 // .SS See Also 11 // .SS See Also 12 // RotationInterfaces.h 12 // RotationInterfaces.h 13 // LorentzVector.h LorentzRotation.h 13 // LorentzVector.h LorentzRotation.h 14 // BoostX.h BoostY.h BoostZ.h 14 // BoostX.h BoostY.h BoostZ.h 15 // 15 // 16 // .SS Author 16 // .SS Author 17 // Mark Fischler 17 // Mark Fischler 18 18 19 #ifndef HEP_BOOST_H 19 #ifndef HEP_BOOST_H 20 #define HEP_BOOST_H 20 #define HEP_BOOST_H 21 21 >> 22 #ifdef GNUPRAGMA >> 23 #pragma interface >> 24 #endif >> 25 22 #include "CLHEP/Vector/RotationInterfaces.h" 26 #include "CLHEP/Vector/RotationInterfaces.h" 23 #include "CLHEP/Vector/BoostX.h" 27 #include "CLHEP/Vector/BoostX.h" 24 #include "CLHEP/Vector/BoostY.h" 28 #include "CLHEP/Vector/BoostY.h" 25 #include "CLHEP/Vector/BoostZ.h" 29 #include "CLHEP/Vector/BoostZ.h" 26 #include "CLHEP/Vector/LorentzVector.h" 30 #include "CLHEP/Vector/LorentzVector.h" 27 31 28 namespace CLHEP { 32 namespace CLHEP { 29 33 30 // Declarations of classes and global methods 34 // Declarations of classes and global methods 31 class HepBoost; 35 class HepBoost; 32 inline HepBoost inverseOf ( const HepBoost & l 36 inline HepBoost inverseOf ( const HepBoost & lt ); 33 37 34 /** 38 /** 35 * @author 39 * @author 36 * @ingroup vector 40 * @ingroup vector 37 */ 41 */ 38 class HepBoost { 42 class HepBoost { 39 43 40 public: 44 public: 41 45 42 // ---------- Constructors and Assignment: 46 // ---------- Constructors and Assignment: 43 47 44 inline HepBoost(); 48 inline HepBoost(); 45 // Default constructor. Gives a boost of 0. 49 // Default constructor. Gives a boost of 0. 46 50 47 inline HepBoost(const HepBoost & m); 51 inline HepBoost(const HepBoost & m); 48 inline HepBoost(HepBoost && m) = default; << 52 // Copy constructor. 49 // Copy and move constructors. << 50 53 51 inline HepBoost & operator = (const HepBoost 54 inline HepBoost & operator = (const HepBoost & m); 52 inline HepBoost & operator = (HepBoost && m) << 55 // Assignment. 53 // Copy and move assignment operators. << 54 56 55 HepBoost & set (double betaX, double 57 HepBoost & set (double betaX, double betaY, double betaZ); 56 inline HepBoost (double betaX, double 58 inline HepBoost (double betaX, double betaY, double betaZ); 57 // Constructor from three components of beta 59 // Constructor from three components of beta vector 58 60 59 HepBoost & set (const HepRep4x4Symmet 61 HepBoost & set (const HepRep4x4Symmetric & m); 60 inline HepBoost (const HepRep4x4Symmet 62 inline HepBoost (const HepRep4x4Symmetric & m); 61 // Constructor from symmetric HepRep4x4 63 // Constructor from symmetric HepRep4x4 62 64 63 HepBoost & set (Hep3Vector direction, 65 HepBoost & set (Hep3Vector direction, double beta); 64 inline HepBoost (Hep3Vector direction, 66 inline HepBoost (Hep3Vector direction, double beta); 65 // Constructor from a three vector direction 67 // Constructor from a three vector direction and the magnitude of beta 66 68 67 HepBoost & set (const Hep3Vector & bo 69 HepBoost & set (const Hep3Vector & boost); 68 inline HepBoost (const Hep3Vector & bo 70 inline HepBoost (const Hep3Vector & boost); 69 // Constructor from a 3-vector of less than 71 // Constructor from a 3-vector of less than unit length 70 72 71 inline HepBoost & set (const HepBoostX & boo 73 inline HepBoost & set (const HepBoostX & boost); 72 inline HepBoost & set (const HepBoostY & boo 74 inline HepBoost & set (const HepBoostY & boost); 73 inline HepBoost & set (const HepBoostZ & boo 75 inline HepBoost & set (const HepBoostZ & boost); 74 inline HepBoost (const HepBoostX & boo 76 inline HepBoost (const HepBoostX & boost); 75 inline HepBoost (const HepBoostY & boo 77 inline HepBoost (const HepBoostY & boost); 76 inline HepBoost (const HepBoostZ & boo 78 inline HepBoost (const HepBoostZ & boost); 77 79 78 // ---------- Accessors: 80 // ---------- Accessors: 79 81 80 inline double beta() const; 82 inline double beta() const; 81 inline double gamma() const; 83 inline double gamma() const; 82 inline Hep3Vector boostVector() const; 84 inline Hep3Vector boostVector() const; 83 inline Hep3Vector getDirection() const; 85 inline Hep3Vector getDirection() const; 84 inline Hep3Vector direction() const; 86 inline Hep3Vector direction() const; 85 87 86 inline double xx() const; 88 inline double xx() const; 87 inline double xy() const; 89 inline double xy() const; 88 inline double xz() const; 90 inline double xz() const; 89 inline double xt() const; 91 inline double xt() const; 90 inline double yx() const; 92 inline double yx() const; 91 inline double yy() const; 93 inline double yy() const; 92 inline double yz() const; 94 inline double yz() const; 93 inline double yt() const; 95 inline double yt() const; 94 inline double zx() const; 96 inline double zx() const; 95 inline double zy() const; 97 inline double zy() const; 96 inline double zz() const; 98 inline double zz() const; 97 inline double zt() const; 99 inline double zt() const; 98 inline double tx() const; 100 inline double tx() const; 99 inline double ty() const; 101 inline double ty() const; 100 inline double tz() const; 102 inline double tz() const; 101 inline double tt() const; 103 inline double tt() const; 102 // Elements of the matrix. 104 // Elements of the matrix. 103 105 104 inline HepLorentzVector col1() const; 106 inline HepLorentzVector col1() const; 105 inline HepLorentzVector col2() const; 107 inline HepLorentzVector col2() const; 106 inline HepLorentzVector col3() const; 108 inline HepLorentzVector col3() const; 107 inline HepLorentzVector col4() const; 109 inline HepLorentzVector col4() const; 108 // orthosymplectic column vectors 110 // orthosymplectic column vectors 109 111 110 inline HepLorentzVector row1() const; 112 inline HepLorentzVector row1() const; 111 inline HepLorentzVector row2() const; 113 inline HepLorentzVector row2() const; 112 inline HepLorentzVector row3() const; 114 inline HepLorentzVector row3() const; 113 inline HepLorentzVector row4() const; 115 inline HepLorentzVector row4() const; 114 // orthosymplectic row vectors 116 // orthosymplectic row vectors 115 117 116 inline HepRep4x4 rep4x4() const; 118 inline HepRep4x4 rep4x4() const; 117 // 4x4 representation. 119 // 4x4 representation. 118 120 119 inline HepRep4x4Symmetric rep4x4Symmetric() 121 inline HepRep4x4Symmetric rep4x4Symmetric() const; 120 // Symmetric 4x4 representation. 122 // Symmetric 4x4 representation. 121 123 122 // ---------- Decomposition: 124 // ---------- Decomposition: 123 125 124 void decompose (HepRotation & rotation, Hep 126 void decompose (HepRotation & rotation, HepBoost & boost) const; 125 void decompose (HepAxisAngle & rotation, Hep 127 void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const; 126 // Find R and B such that L = R*B -- trivial 128 // Find R and B such that L = R*B -- trivial, since R is identity 127 129 128 void decompose (HepBoost & boost, HepRotat 130 void decompose (HepBoost & boost, HepRotation & rotation) const; 129 void decompose (Hep3Vector & boost, HepAxisA 131 void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const; 130 // Find R and B such that L = B*R -- trivial 132 // Find R and B such that L = B*R -- trivial, since R is identity 131 133 132 // ---------- Comparisons: 134 // ---------- Comparisons: 133 135 134 inline int compare( const HepBoost & b ) co 136 inline int compare( const HepBoost & b ) const; 135 // Dictionary-order comparison, in order tt, 137 // Dictionary-order comparison, in order tt,zt,zz,yt,yz,yy,xt,xz,xy,xx 136 // Used in operator<, >, <=, >= 138 // Used in operator<, >, <=, >= 137 139 138 inline bool operator == (const HepBoost & b) 140 inline bool operator == (const HepBoost & b) const; 139 inline bool operator != (const HepBoost & b) 141 inline bool operator != (const HepBoost & b) const; 140 inline bool operator <= (const HepBoost & b) 142 inline bool operator <= (const HepBoost & b) const; 141 inline bool operator >= (const HepBoost & b) 143 inline bool operator >= (const HepBoost & b) const; 142 inline bool operator < (const HepBoost & b) 144 inline bool operator < (const HepBoost & b) const; 143 inline bool operator > (const HepBoost & b) 145 inline bool operator > (const HepBoost & b) const; 144 // Comparisons. 146 // Comparisons. 145 147 146 inline bool isIdentity() const; 148 inline bool isIdentity() const; 147 // Returns true if a null boost. 149 // Returns true if a null boost. 148 150 149 inline double distance2( const HepBoost & 151 inline double distance2( const HepBoost & b ) const; 150 inline double distance2( const HepBoostX & 152 inline double distance2( const HepBoostX & bx ) const; 151 inline double distance2( const HepBoostY & 153 inline double distance2( const HepBoostY & by ) const; 152 inline double distance2( const HepBoostZ & 154 inline double distance2( const HepBoostZ & bz ) const; 153 // Defined as the distance2 between the vect 155 // Defined as the distance2 between the vectors (gamma*betaVector) 154 156 155 double distance2( const HepRotation & r ) c 157 double distance2( const HepRotation & r ) const; 156 double distance2( const HepLorentzRotation & 158 double distance2( const HepLorentzRotation & lt ) const; 157 // Distance between this and other sorts of 159 // Distance between this and other sorts of transformations 158 160 159 inline double howNear( const HepBoost & b 161 inline double howNear( const HepBoost & b ) const; 160 inline bool isNear( const HepBoost & b, 162 inline bool isNear( const HepBoost & b, 161 double epsilon=Hep4RotationInterf 163 double epsilon=Hep4RotationInterface::tolerance) const; 162 164 163 double howNear( const HepRotation & r ) con 165 double howNear( const HepRotation & r ) const; 164 double howNear( const HepLorentzRotation & l 166 double howNear( const HepLorentzRotation & lt ) const; 165 167 166 bool isNear( const HepRotation & r, 168 bool isNear( const HepRotation & r, 167 double epsilon=Hep4RotationInterf 169 double epsilon=Hep4RotationInterface::tolerance) const; 168 bool isNear( const HepLorentzRotation & lt, 170 bool isNear( const HepLorentzRotation & lt, 169 double epsilon=Hep4RotationInterf 171 double epsilon=Hep4RotationInterface::tolerance) const; 170 172 171 // ---------- Properties: 173 // ---------- Properties: 172 174 173 double norm2() const; 175 double norm2() const; 174 // (beta*gamma)^2 176 // (beta*gamma)^2 175 177 176 void rectify(); 178 void rectify(); 177 // set as an exact boost, based on the timel 179 // set as an exact boost, based on the timelike part of the boost matrix. 178 180 179 // ---------- Application: 181 // ---------- Application: 180 182 181 inline HepLorentzVector operator()( const He 183 inline HepLorentzVector operator()( const HepLorentzVector & p ) const; 182 // Transform a Lorentz Vector. 184 // Transform a Lorentz Vector. 183 185 184 inline HepLorentzVector operator* ( const He 186 inline HepLorentzVector operator* ( const HepLorentzVector & p ) const; 185 // Multiplication with a Lorentz Vector. 187 // Multiplication with a Lorentz Vector. 186 188 187 // ---------- Operations in the group of 4-R 189 // ---------- Operations in the group of 4-Rotations 188 190 189 HepLorentzRotation operator * (const HepBoos 191 HepLorentzRotation operator * (const HepBoost & b) const; 190 HepLorentzRotation operator * (const HepRota 192 HepLorentzRotation operator * (const HepRotation & r) const; 191 HepLorentzRotation operator * (const HepLore 193 HepLorentzRotation operator * (const HepLorentzRotation & lt) const; 192 // Product of two Lorentz Rotations (this) * 194 // Product of two Lorentz Rotations (this) * lt - matrix multiplication 193 // Notice that the product of two pure boost 195 // Notice that the product of two pure boosts is no longer a pure boost 194 196 195 inline HepBoost inverse() const; 197 inline HepBoost inverse() const; 196 // Return the inverse. 198 // Return the inverse. 197 199 198 inline friend HepBoost inverseOf ( const Hep 200 inline friend HepBoost inverseOf ( const HepBoost & lt ); 199 // global methods to invert. 201 // global methods to invert. 200 202 201 inline HepBoost & invert(); 203 inline HepBoost & invert(); 202 // Inverts the Boost matrix. 204 // Inverts the Boost matrix. 203 205 204 // ---------- I/O: 206 // ---------- I/O: 205 207 206 std::ostream & print( std::ostream & os ) co 208 std::ostream & print( std::ostream & os ) const; 207 // Output form is (bx, by, bz) 209 // Output form is (bx, by, bz) 208 210 209 // ---------- Tolerance 211 // ---------- Tolerance 210 212 211 static inline double getTolerance(); 213 static inline double getTolerance(); 212 static inline double setTolerance(double tol 214 static inline double setTolerance(double tol); 213 215 214 protected: 216 protected: 215 217 216 inline HepLorentzVector vectorMultiplication 218 inline HepLorentzVector vectorMultiplication 217 ( const HepLorentzVector & w ) const 219 ( const HepLorentzVector & w ) const; 218 // Multiplication with a Lorentz Vector. 220 // Multiplication with a Lorentz Vector. 219 221 220 HepLorentzRotation matrixMultiplication (con 222 HepLorentzRotation matrixMultiplication (const HepRep4x4 & m) const; 221 HepLorentzRotation matrixMultiplication (con 223 HepLorentzRotation matrixMultiplication (const HepRep4x4Symmetric & m) const; 222 224 223 inline HepBoost 225 inline HepBoost 224 (double xx, double xy, double xz, doubl 226 (double xx, double xy, double xz, double xt, 225 double yy, double yz, double yt, 227 double yy, double yz, double yt, 226 double zz, double zt, 228 double zz, double zt, 227 double tt); 229 double tt); 228 // Protected constructor. 230 // Protected constructor. 229 // DOES NOT CHECK FOR VALIDITY AS A LORENTZ 231 // DOES NOT CHECK FOR VALIDITY AS A LORENTZ BOOST. 230 232 231 inline void setBoost(double bx, double by, d 233 inline void setBoost(double bx, double by, double bz); 232 234 233 HepRep4x4Symmetric rep_; 235 HepRep4x4Symmetric rep_; 234 236 235 }; // HepBoost 237 }; // HepBoost 236 238 237 inline 239 inline 238 std::ostream & operator << 240 std::ostream & operator << 239 ( std::ostream & os, const HepBoost& b ) {re 241 ( std::ostream & os, const HepBoost& b ) {return b.print(os);} 240 242 241 } // namespace CLHEP 243 } // namespace CLHEP 242 244 243 #include "CLHEP/Vector/Boost.icc" 245 #include "CLHEP/Vector/Boost.icc" 244 246 245 #endif /* HEP_BOOST_H */ 247 #endif /* HEP_BOOST_H */ 246 248