CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // CLASSDOC OFF 00003 // $Id: LorentzRotation.h,v 1.3 2003/10/23 21:29:52 garren Exp $ 00004 // --------------------------------------------------------------------------- 00005 // CLASSDOC ON 00006 // 00007 // This file is a part of the CLHEP - a Class Library for High Energy Physics. 00008 // 00009 // This is the definition of the HepLorentzRotation class for performing 00010 // Lorentz transformations (rotations and boosts) on objects of the 00011 // HepLorentzVector class. 00012 // 00013 // HepLorentzRotation is a concrete implementation of Hep4RotationInterface. 00014 // 00015 // .SS See Also 00016 // RotationInterfaces.h 00017 // ThreeVector.h, LorentzVector.h 00018 // Rotation.h, Boost.h 00019 // 00020 // .SS Author 00021 // Leif Lonnblad, Mark Fischler 00022 00023 #ifndef HEP_LORENTZROTATION_H 00024 #define HEP_LORENTZROTATION_H 00025 00026 #ifdef GNUPRAGMA 00027 #pragma interface 00028 #endif 00029 00030 #include "CLHEP/Vector/defs.h" 00031 #include "CLHEP/Vector/RotationInterfaces.h" 00032 #include "CLHEP/Vector/Rotation.h" 00033 #include "CLHEP/Vector/Boost.h" 00034 #include "CLHEP/Vector/LorentzVector.h" 00035 00036 namespace CLHEP { 00037 00038 // Global methods 00039 00040 inline HepLorentzRotation inverseOf ( const HepLorentzRotation & lt ); 00041 HepLorentzRotation operator * (const HepRotation & r, 00042 const HepLorentzRotation & lt); 00043 HepLorentzRotation operator * (const HepRotationX & r, 00044 const HepLorentzRotation & lt); 00045 HepLorentzRotation operator * (const HepRotationY & r, 00046 const HepLorentzRotation & lt); 00047 HepLorentzRotation operator * (const HepRotationZ & r, 00048 const HepLorentzRotation & lt); 00049 00054 class HepLorentzRotation { 00055 00056 public: 00057 // ---------- Identity HepLorentzRotation: 00058 00059 static const HepLorentzRotation IDENTITY; 00060 00061 // ---------- Constructors and Assignment: 00062 00063 inline HepLorentzRotation(); 00064 // Default constructor. Gives a unit matrix. 00065 00066 inline HepLorentzRotation (const HepLorentzRotation & r); 00067 // Copy constructor. 00068 00069 inline HepLorentzRotation (const HepRotation & r); 00070 inline explicit HepLorentzRotation (const HepRotationX & r); 00071 inline explicit HepLorentzRotation (const HepRotationY & r); 00072 inline explicit HepLorentzRotation (const HepRotationZ & r); 00073 inline HepLorentzRotation (const HepBoost & b); 00074 inline explicit HepLorentzRotation (const HepBoostX & b); 00075 inline explicit HepLorentzRotation (const HepBoostY & b); 00076 inline explicit HepLorentzRotation (const HepBoostZ & b); 00077 // Constructors from special cases. 00078 00079 inline HepLorentzRotation & operator = (const HepLorentzRotation & m); 00080 inline HepLorentzRotation & operator = (const HepRotation & m); 00081 inline HepLorentzRotation & operator = (const HepBoost & m); 00082 // Assignment. 00083 00084 HepLorentzRotation & set (double bx, double by, double bz); 00085 inline HepLorentzRotation & set (const Hep3Vector & p); 00086 inline HepLorentzRotation & set (const HepRotation & r); 00087 inline HepLorentzRotation & set (const HepRotationX & r); 00088 inline HepLorentzRotation & set (const HepRotationY & r); 00089 inline HepLorentzRotation & set (const HepRotationZ & r); 00090 inline HepLorentzRotation & set (const HepBoost & boost); 00091 inline HepLorentzRotation & set (const HepBoostX & boost); 00092 inline HepLorentzRotation & set (const HepBoostY & boost); 00093 inline HepLorentzRotation & set (const HepBoostZ & boost); 00094 inline HepLorentzRotation (double bx, double by, double bz); 00095 inline HepLorentzRotation (const Hep3Vector & p); 00096 // Other Constructors giving a Lorentz-boost. 00097 00098 HepLorentzRotation & set( const HepBoost & B, const HepRotation & R ); 00099 inline HepLorentzRotation ( const HepBoost & B, const HepRotation & R ); 00100 // supply B and R: T = B R: 00101 00102 HepLorentzRotation & set( const HepRotation & R, const HepBoost & B ); 00103 inline HepLorentzRotation ( const HepRotation & R, const HepBoost & B ); 00104 // supply R and B: T = R B: 00105 00106 HepLorentzRotation ( const HepLorentzVector & col1, 00107 const HepLorentzVector & col2, 00108 const HepLorentzVector & col3, 00109 const HepLorentzVector & col4 ); 00110 // Construct from four *orthosymplectic* LorentzVectors for the columns: 00111 // NOTE: 00112 // This constructor, and the two set methods below, 00113 // will check that the columns (or rows) form an orthosymplectic 00114 // matrix, and will adjust values so that this relation is 00115 // as exact as possible. 00116 // Orthosymplectic means the dot product USING THE METRIC 00117 // of two different coumns will be 0, and of a column with 00118 // itself will be one. 00119 00120 HepLorentzRotation & set( const HepLorentzVector & col1, 00121 const HepLorentzVector & col2, 00122 const HepLorentzVector & col3, 00123 const HepLorentzVector & col4 ); 00124 // supply four *orthosymplectic* HepLorentzVectors for the columns 00125 00126 HepLorentzRotation & setRows( const HepLorentzVector & row1, 00127 const HepLorentzVector & row2, 00128 const HepLorentzVector & row3, 00129 const HepLorentzVector & row4 ); 00130 // supply four *orthosymplectic* HepLorentzVectors for the columns 00131 00132 inline HepLorentzRotation & set( const HepRep4x4 & rep ); 00133 inline HepLorentzRotation ( const HepRep4x4 & rep ); 00134 // supply a HepRep4x4 structure (16 numbers) 00135 // WARNING: 00136 // This constructor and set method will assume the 00137 // HepRep4x4 supplied is in fact an orthosymplectic matrix. 00138 // No checking or correction is done. If you are 00139 // not certain the matrix is orthosymplectic, break it 00140 // into four HepLorentzVector columns and use the form 00141 // HepLorentzRotation (col1, col2, col3, col4) 00142 00143 // ---------- Accessors: 00144 00145 inline double xx() const; 00146 inline double xy() const; 00147 inline double xz() const; 00148 inline double xt() const; 00149 inline double yx() const; 00150 inline double yy() const; 00151 inline double yz() const; 00152 inline double yt() const; 00153 inline double zx() const; 00154 inline double zy() const; 00155 inline double zz() const; 00156 inline double zt() const; 00157 inline double tx() const; 00158 inline double ty() const; 00159 inline double tz() const; 00160 inline double tt() const; 00161 // Elements of the matrix. 00162 00163 inline HepLorentzVector col1() const; 00164 inline HepLorentzVector col2() const; 00165 inline HepLorentzVector col3() const; 00166 inline HepLorentzVector col4() const; 00167 // orthosymplectic column vectors 00168 00169 inline HepLorentzVector row1() const; 00170 inline HepLorentzVector row2() const; 00171 inline HepLorentzVector row3() const; 00172 inline HepLorentzVector row4() const; 00173 // orthosymplectic row vectors 00174 00175 inline HepRep4x4 rep4x4() const; 00176 // 4x4 representation: 00177 00178 // ------------ Subscripting: 00179 00180 class HepLorentzRotation_row { 00181 public: 00182 inline HepLorentzRotation_row(const HepLorentzRotation &, int); 00183 inline double operator [] (int) const; 00184 private: 00185 const HepLorentzRotation & rr; 00186 int ii; 00187 }; 00188 // Helper class for implemention of C-style subscripting r[i][j] 00189 00190 inline const HepLorentzRotation_row operator [] (int) const; 00191 // Returns object of the helper class for C-style subscripting r[i][j] 00192 00193 double operator () (int, int) const; 00194 // Fortran-style subscripting: returns (i,j) element of the matrix. 00195 00196 // ---------- Decomposition: 00197 00198 void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const; 00199 void decompose (HepBoost & boost, HepRotation & rotation) const; 00200 // Find B and R such that L = B*R 00201 00202 void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const; 00203 void decompose (HepRotation & rotation, HepBoost & boost) const; 00204 // Find R and B such that L = R*B 00205 00206 // ---------- Comparisons: 00207 00208 int compare( const HepLorentzRotation & m ) const; 00209 // Dictionary-order comparison, in order tt,tz,...zt,zz,zy,zx,yt,yz,...,xx 00210 // Used in operator<, >, <=, >= 00211 00212 inline bool operator == (const HepLorentzRotation &) const; 00213 inline bool operator != (const HepLorentzRotation &) const; 00214 inline bool operator <= (const HepLorentzRotation &) const; 00215 inline bool operator >= (const HepLorentzRotation &) const; 00216 inline bool operator < (const HepLorentzRotation &) const; 00217 inline bool operator > (const HepLorentzRotation &) const; 00218 00219 inline bool isIdentity() const; 00220 // Returns true if the Identity matrix. 00221 00222 double distance2( const HepBoost & b ) const; 00223 double distance2( const HepRotation & r ) const; 00224 double distance2( const HepLorentzRotation & lt ) const; 00225 // Decomposes L = B*R, returns the sum of distance2 for B and R. 00226 00227 double howNear( const HepBoost & b ) const; 00228 double howNear( const HepRotation & r) const; 00229 double howNear( const HepLorentzRotation & lt ) const; 00230 00231 bool isNear(const HepBoost & b, 00232 double epsilon=Hep4RotationInterface::tolerance) const; 00233 bool isNear(const HepRotation & r, 00234 double epsilon=Hep4RotationInterface::tolerance) const; 00235 bool isNear(const HepLorentzRotation & lt, 00236 double epsilon=Hep4RotationInterface::tolerance) const; 00237 00238 // ---------- Properties: 00239 00240 double norm2() const; 00241 // distance2 (IDENTITY), which involves decomposing into B and R and summing 00242 // norm2 for the individual B and R parts. 00243 00244 void rectify(); 00245 // non-const but logically moot correction for accumulated roundoff errors 00246 // rectify averages the matrix with the orthotranspose of its actual 00247 // inverse (absent accumulated roundoff errors, the orthotranspose IS 00248 // the inverse)); this removes to first order those errors. 00249 // Then it formally decomposes that, extracts axis and delta for its 00250 // Rotation part, forms a LorentzRotation from a true HepRotation 00251 // with those values of axis and delta, times the true Boost 00252 // with that boost vector. 00253 00254 // ---------- Application: 00255 00256 inline HepLorentzVector vectorMultiplication(const HepLorentzVector&) const; 00257 inline HepLorentzVector operator()( const HepLorentzVector & w ) const; 00258 inline HepLorentzVector operator* ( const HepLorentzVector & p ) const; 00259 // Multiplication with a Lorentz Vector. 00260 00261 // ---------- Operations in the group of 4-Rotations 00262 00263 HepLorentzRotation matrixMultiplication(const HepRep4x4 & m) const; 00264 00265 inline HepLorentzRotation operator * (const HepBoost & b) const; 00266 inline HepLorentzRotation operator * (const HepRotation & r) const; 00267 inline HepLorentzRotation operator * (const HepLorentzRotation & lt) const; 00268 // Product of two Lorentz Rotations (this) * lt - matrix multiplication 00269 00270 inline HepLorentzRotation & operator *= (const HepBoost & b); 00271 inline HepLorentzRotation & operator *= (const HepRotation & r); 00272 inline HepLorentzRotation & operator *= (const HepLorentzRotation & lt); 00273 inline HepLorentzRotation & transform (const HepBoost & b); 00274 inline HepLorentzRotation & transform (const HepRotation & r); 00275 inline HepLorentzRotation & transform (const HepLorentzRotation & lt); 00276 // Matrix multiplication. 00277 // Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a; 00278 00279 // Here there is an opportunity for speedup by providing specialized forms 00280 // of lt * r and lt * b where r is a RotationX Y or Z or b is a BoostX Y or Z 00281 // These are, in fact, provided below for the transform() methods. 00282 00283 HepLorentzRotation & rotateX(double delta); 00284 // Rotation around the x-axis; equivalent to LT = RotationX(delta) * LT 00285 00286 HepLorentzRotation & rotateY(double delta); 00287 // Rotation around the y-axis; equivalent to LT = RotationY(delta) * LT 00288 00289 HepLorentzRotation & rotateZ(double delta); 00290 // Rotation around the z-axis; equivalent to LT = RotationZ(delta) * LT 00291 00292 inline HepLorentzRotation & rotate(double delta, const Hep3Vector& axis); 00293 inline HepLorentzRotation & rotate(double delta, const Hep3Vector *axis); 00294 // Rotation around specified vector - LT = Rotation(delta,axis)*LT 00295 00296 HepLorentzRotation & boostX(double beta); 00297 // Pure boost along the x-axis; equivalent to LT = BoostX(beta) * LT 00298 00299 HepLorentzRotation & boostY(double beta); 00300 // Pure boost along the y-axis; equivalent to LT = BoostX(beta) * LT 00301 00302 HepLorentzRotation & boostZ(double beta); 00303 // Pure boost along the z-axis; equivalent to LT = BoostX(beta) * LT 00304 00305 inline HepLorentzRotation & boost(double, double, double); 00306 inline HepLorentzRotation & boost(const Hep3Vector &); 00307 // Lorenz boost. 00308 00309 inline HepLorentzRotation inverse() const; 00310 // Return the inverse. 00311 00312 inline HepLorentzRotation & invert(); 00313 // Inverts the LorentzRotation matrix. 00314 00315 // ---------- I/O: 00316 00317 std::ostream & print( std::ostream & os ) const; 00318 // Aligned six-digit-accurate output of the transformation matrix. 00319 00320 // ---------- Tolerance 00321 00322 static inline double getTolerance(); 00323 static inline double setTolerance(double tol); 00324 00325 friend HepLorentzRotation inverseOf ( const HepLorentzRotation & lt ); 00326 00327 protected: 00328 00329 inline HepLorentzRotation 00330 (double mxx, double mxy, double mxz, double mxt, 00331 double myx, double myy, double myz, double myt, 00332 double mzx, double mzy, double mzz, double mzt, 00333 double mtx, double mty, double mtz, double mtt); 00334 // Protected constructor. 00335 // DOES NOT CHECK FOR VALIDITY AS A LORENTZ TRANSFORMATION. 00336 00337 inline void setBoost(double, double, double); 00338 // Set elements according to a boost vector. 00339 00340 double mxx, mxy, mxz, mxt, 00341 myx, myy, myz, myt, 00342 mzx, mzy, mzz, mzt, 00343 mtx, mty, mtz, mtt; 00344 // The matrix elements. 00345 00346 }; // HepLorentzRotation 00347 00348 inline std::ostream & operator<< 00349 ( std::ostream & os, const HepLorentzRotation& lt ) 00350 {return lt.print(os);} 00351 00352 inline bool operator==(const HepRotation &r, const HepLorentzRotation & lt) 00353 { return lt==r; } 00354 inline bool operator!=(const HepRotation &r, const HepLorentzRotation & lt) 00355 { return lt!=r; } 00356 inline bool operator<=(const HepRotation &r, const HepLorentzRotation & lt) 00357 { return lt<=r; } 00358 inline bool operator>=(const HepRotation &r, const HepLorentzRotation & lt) 00359 { return lt>=r; } 00360 inline bool operator<(const HepRotation &r, const HepLorentzRotation & lt) 00361 { return lt<r; } 00362 inline bool operator>(const HepRotation &r, const HepLorentzRotation & lt) 00363 { return lt>r; } 00364 00365 inline bool operator==(const HepBoost &b, const HepLorentzRotation & lt) 00366 { return lt==b; } 00367 inline bool operator!=(const HepBoost &b, const HepLorentzRotation & lt) 00368 { return lt!=b; } 00369 inline bool operator<=(const HepBoost &b, const HepLorentzRotation & lt) 00370 { return lt<=b; } 00371 inline bool operator>=(const HepBoost &b, const HepLorentzRotation & lt) 00372 { return lt>=b; } 00373 inline bool operator<(const HepBoost &b, const HepLorentzRotation & lt) 00374 { return lt<b; } 00375 inline bool operator>(const HepBoost &b, const HepLorentzRotation & lt) 00376 { return lt>b; } 00377 00378 } // namespace CLHEP 00379 00380 #include "CLHEP/Vector/LorentzRotation.icc" 00381 00382 #ifdef ENABLE_BACKWARDS_COMPATIBILITY 00383 // backwards compatibility will be enabled ONLY in CLHEP 1.9 00384 using namespace CLHEP; 00385 #endif 00386 00387 #endif /* HEP_LORENTZROTATION_H */ 00388