CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // --------------------------------------------------------------------------- 00003 // 00004 // This file is a part of the CLHEP - a Class Library for High Energy Physics. 00005 // 00006 // This is the implementation of the HepBoostZ class. 00007 // 00008 00009 #ifdef GNUPRAGMA 00010 #pragma implementation 00011 #endif 00012 00013 #include "CLHEP/Vector/defs.h" 00014 #include "CLHEP/Vector/BoostZ.h" 00015 #include "CLHEP/Vector/Boost.h" 00016 #include "CLHEP/Vector/Rotation.h" 00017 #include "CLHEP/Vector/LorentzRotation.h" 00018 #include "CLHEP/Vector/ZMxpv.h" 00019 00020 namespace CLHEP { 00021 00022 // ---------- Constructors and Assignment: 00023 00024 HepBoostZ & HepBoostZ::set (double beta) { 00025 double b2 = beta*beta; 00026 if (b2 >= 1) { 00027 ZMthrowA (ZMxpvTachyonic( 00028 "Beta supplied to set HepBoostZ represents speed >= c.")); 00029 beta_ = 1.0 - 1.0E-8; // NaN-proofing 00030 gamma_ = 1.0 / sqrt(1.0 - b2); 00031 return *this; 00032 } 00033 beta_ = beta; 00034 gamma_ = 1.0 / sqrt(1.0 - b2); 00035 return *this; 00036 } 00037 00038 // ---------- Accessors: 00039 00040 HepRep4x4 HepBoostZ::rep4x4() const { 00041 double bg = beta_*gamma_; 00042 return HepRep4x4( 1, 0, 0, 0, 00043 0, 1, 0, 0, 00044 0, 0, gamma_, bg, 00045 0, 0, bg, gamma_ ); 00046 } 00047 00048 HepRep4x4Symmetric HepBoostZ::rep4x4Symmetric() const { 00049 double bg = beta_*gamma_; 00050 return HepRep4x4Symmetric( 1, 0, 0, 0, 00051 1, 0, 0, 00052 gamma_, bg, 00053 gamma_ ); 00054 } 00055 00056 // ---------- Decomposition: 00057 00058 void HepBoostZ::decompose (HepRotation & rotation, HepBoost & boost) const { 00059 HepAxisAngle vdelta = HepAxisAngle(); 00060 rotation = HepRotation(vdelta); 00061 Hep3Vector beta = boostVector(); 00062 boost = HepBoost(beta); 00063 } 00064 00065 void HepBoostZ::decompose (HepAxisAngle & rotation, Hep3Vector & boost) const { 00066 rotation = HepAxisAngle(); 00067 boost = boostVector(); 00068 } 00069 00070 void HepBoostZ::decompose (HepBoost & boost, HepRotation & rotation) const { 00071 HepAxisAngle vdelta = HepAxisAngle(); 00072 rotation = HepRotation(vdelta); 00073 Hep3Vector beta = boostVector(); 00074 boost = HepBoost(beta); 00075 } 00076 00077 void HepBoostZ::decompose (Hep3Vector & boost, HepAxisAngle & rotation) const { 00078 rotation = HepAxisAngle(); 00079 boost = boostVector(); 00080 } 00081 00082 // ---------- Comparisons: 00083 00084 double HepBoostZ::distance2( const HepBoost & b ) const { 00085 return b.distance2(*this); 00086 } 00087 00088 double HepBoostZ::distance2( const HepRotation & r ) const { 00089 double db2 = norm2(); 00090 double dr2 = r.norm2(); 00091 return (db2 + dr2); 00092 } 00093 00094 double HepBoostZ::distance2( const HepLorentzRotation & lt ) const { 00095 HepBoost b1; 00096 HepRotation r1; 00097 lt.decompose(b1,r1); 00098 double db2 = distance2(b1); 00099 double dr2 = r1.norm2(); 00100 return (db2 + dr2); 00101 } 00102 00103 bool HepBoostZ::isNear (const HepRotation & r, double epsilon) const { 00104 double db2 = norm2(); 00105 if (db2 > epsilon*epsilon) return false; 00106 double dr2 = r.norm2(); 00107 return (db2+dr2 <= epsilon*epsilon); 00108 } 00109 00110 bool HepBoostZ::isNear ( const HepLorentzRotation & lt, 00111 double epsilon ) const { 00112 HepBoost b1; 00113 HepRotation r1; 00114 double db2 = distance2(b1); 00115 lt.decompose(b1,r1); 00116 if (db2 > epsilon*epsilon) return false; 00117 double dr2 = r1.norm2(); 00118 return (db2 + dr2); 00119 } 00120 00121 // ---------- Properties: 00122 00123 void HepBoostZ::rectify() { 00124 // Assuming the representation of this is close to a true pure boost, 00125 // but may have drifted due to round-off error from many operations, 00126 // this forms an "exact" pure BoostZ matrix for again. 00127 00128 double b2 = beta_*beta_; 00129 if (b2 >= 1) { 00130 beta_ = 1.0 - 1.0e-8; // NaN-proofing 00131 b2 = beta_*beta_; 00132 } 00133 gamma_ = 1.0 / sqrt(1.0 - b2); 00134 } 00135 00136 // ---------- Application: 00137 00138 // ---------- Operations in the group of 4-Rotations 00139 00140 HepBoostZ HepBoostZ::operator * (const HepBoostZ & b) const { 00141 return HepBoostZ ( (beta()+b.beta()) / (1+beta()*b.beta()) ); 00142 } 00143 HepLorentzRotation HepBoostZ::operator * (const HepBoost & b) const { 00144 HepLorentzRotation me (*this); 00145 return me*b; 00146 } 00147 HepLorentzRotation HepBoostZ::operator * (const HepRotation & r) const { 00148 HepLorentzRotation me (*this); 00149 return me*r; 00150 } 00151 HepLorentzRotation HepBoostZ::operator * (const HepLorentzRotation & lt) const { 00152 HepLorentzRotation me (*this); 00153 return me*lt; 00154 } 00155 00156 // ---------- I/O 00157 00158 std::ostream & HepBoostZ::print( std::ostream & os ) const { 00159 os << "Boost in Z direction (beta = " << beta_ 00160 << ", gamma = " << gamma_ << ") "; 00161 return os; 00162 } 00163 00164 } // namespace CLHEP