CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

BoostX.cc

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

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7