Boost.icc

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 definitions of the inline member functions of the
00007 // HepBoost class
00008 //
00009 
00010 #include <cmath>
00011 
00012 namespace CLHEP  {
00013 
00014 // ----------  Constructors and Assignment:
00015 
00016 inline HepBoost::HepBoost() : rep_() {}
00017 
00018 inline HepBoost::HepBoost(const HepBoost & m1) : rep_(m1.rep_) {}
00019 
00020 inline HepBoost & HepBoost::operator = (const HepBoost & m1) { 
00021   rep_ = m1.rep_; 
00022   return *this;
00023 }
00024 
00025 inline HepBoost::HepBoost(double betaX, double betaY, double betaZ) 
00026 {
00027   set(betaX, betaY, betaZ);
00028 }
00029 
00030 inline HepBoost::HepBoost(const HepRep4x4Symmetric & m1) : rep_(m1) {}
00031 
00032 inline HepBoost::HepBoost(Hep3Vector ddirection, double bbeta) 
00033 {
00034   double length = ddirection.mag();
00035   if (length==0) {
00036     std::cerr << "HepBoost::HepBoost() - "
00037               << "HepBoost constructed using a zero vector as direction"
00038               << std::endl;
00039     set(0,0,0);
00040   }
00041   set(bbeta*ddirection.x()/length,
00042       bbeta*ddirection.y()/length,
00043       bbeta*ddirection.z()/length);
00044 }
00045 
00046 inline HepBoost::HepBoost(const Hep3Vector & boost) 
00047 {
00048   set(boost.x(), boost.y(), boost.z());
00049 }
00050 
00051 inline HepBoost::HepBoost(const HepBoostX & boost) {set(boost.boostVector());}
00052 inline HepBoost::HepBoost(const HepBoostY & boost) {set(boost.boostVector());}
00053 inline HepBoost::HepBoost(const HepBoostZ & boost) {set(boost.boostVector());}
00054 inline HepBoost & HepBoost::set(const HepBoostX & boost) 
00055                                             {return set(boost.boostVector());}
00056 inline HepBoost & HepBoost::set(const HepBoostY & boost)
00057                                             {return set(boost.boostVector());}
00058 inline HepBoost & HepBoost::set(const HepBoostZ & boost)
00059                                             {return set(boost.boostVector());}
00060 
00061 // - Protected method:
00062 inline HepBoost::HepBoost ( 
00063   double xx1, double xy1, double xz1, double xt1,
00064               double yy1, double yz1, double yt1,
00065                           double zz1, double zt1,
00066                                       double tt1) :
00067           rep_ ( xx1, xy1, xz1, xt1, yy1, yz1, yt1, zz1, zt1, tt1 ) {}  
00068 
00069 // ----------  Accessors:
00070 
00071 inline double  HepBoost::beta() const {   
00072   return std::sqrt( 1.0 - 1.0 / (rep_.tt_ * rep_.tt_) );
00073 }
00074 
00075 inline double  HepBoost::gamma() const {
00076   return rep_.tt_; 
00077 }
00078 
00079 inline Hep3Vector HepBoost::boostVector() const { 
00080   return  (1.0/rep_.tt_) * Hep3Vector( rep_.xt_, rep_.yt_, rep_.zt_ );
00081 }
00082 
00083 inline Hep3Vector HepBoost::getDirection() const { 
00084   double norm = 1.0/beta();
00085   return  (norm*boostVector());
00086 }
00087 
00088 inline Hep3Vector HepBoost::direction() const { 
00089   return  getDirection();
00090 }
00091 
00092 inline double HepBoost::xx() const { return rep_.xx_; }
00093 inline double HepBoost::xy() const { return rep_.xy_; }
00094 inline double HepBoost::xz() const { return rep_.xz_; }
00095 inline double HepBoost::xt() const { return rep_.xt_; }
00096 inline double HepBoost::yx() const { return rep_.xy_; }
00097 inline double HepBoost::yy() const { return rep_.yy_; }
00098 inline double HepBoost::yz() const { return rep_.yz_; }
00099 inline double HepBoost::yt() const { return rep_.yt_; }
00100 inline double HepBoost::zx() const { return rep_.xz_; }
00101 inline double HepBoost::zy() const { return rep_.yz_; }
00102 inline double HepBoost::zz() const { return rep_.zz_; }
00103 inline double HepBoost::zt() const { return rep_.zt_; }
00104 inline double HepBoost::tx() const { return rep_.xt_; }
00105 inline double HepBoost::ty() const { return rep_.yt_; }
00106 inline double HepBoost::tz() const { return rep_.zt_; }
00107 inline double HepBoost::tt() const { return rep_.tt_; }
00108 
00109 inline HepLorentzVector HepBoost::col1() const {
00110   return HepLorentzVector ( xx(), yx(), zx(), tx() );
00111 }
00112 inline HepLorentzVector HepBoost::col2() const {
00113   return HepLorentzVector ( xy(), yy(), zy(), ty() );
00114 }
00115 inline HepLorentzVector HepBoost::col3() const {
00116   return HepLorentzVector ( xz(), yz(), zz(), tz() );
00117 }
00118 inline HepLorentzVector HepBoost::col4() const {
00119   return HepLorentzVector ( xt(), yt(), zt(), tt() );
00120 }
00121 
00122 inline HepLorentzVector HepBoost::row1() const {
00123   return HepLorentzVector ( col1() );
00124 }
00125 inline HepLorentzVector HepBoost::row2() const {
00126   return HepLorentzVector ( col2() );
00127 }
00128 inline HepLorentzVector HepBoost::row3() const {
00129   return HepLorentzVector ( col3() );
00130 }
00131 inline HepLorentzVector HepBoost::row4() const {
00132   return HepLorentzVector ( col4() );
00133 }
00134 
00135 inline HepRep4x4 HepBoost::rep4x4() const {
00136   return HepRep4x4( rep_ );
00137 }
00138 
00139 inline HepRep4x4Symmetric HepBoost::rep4x4Symmetric() const {
00140   return rep_;
00141 }
00142 
00143 
00144 inline void HepBoost::setBoost(double bx, double by, double bz) {
00145   set(bx, by, bz);
00146 }
00147 
00148 
00149 // ----------  Comparisons:
00150 
00151 int HepBoost::compare ( const HepBoost & b ) const {
00152   const HepRep4x4Symmetric & s1 = b.rep4x4Symmetric();
00153        if (rep_.tt_ < s1.tt_) return -1; else if (rep_.tt_ > s1.tt_) return 1;
00154   else if (rep_.zt_ < s1.zt_) return -1; else if (rep_.zt_ > s1.zt_) return 1;
00155   else if (rep_.zz_ < s1.zz_) return -1; else if (rep_.zz_ > s1.zz_) return 1;
00156   else if (rep_.yt_ < s1.yt_) return -1; else if (rep_.yt_ > s1.yt_) return 1;
00157   else if (rep_.yz_ < s1.yz_) return -1; else if (rep_.yz_ > s1.yz_) return 1;
00158   else if (rep_.yy_ < s1.yy_) return -1; else if (rep_.yy_ > s1.yy_) return 1;
00159   else if (rep_.xt_ < s1.xt_) return -1; else if (rep_.xt_ > s1.xt_) return 1;
00160   else if (rep_.xz_ < s1.xz_) return -1; else if (rep_.xz_ > s1.xz_) return 1;
00161   else if (rep_.xy_ < s1.xy_) return -1; else if (rep_.xy_ > s1.xy_) return 1;
00162   else if (rep_.xx_ < s1.xx_) return -1; else if (rep_.xx_ > s1.xx_) return 1;
00163   else return 0;
00164 }
00165 
00166 inline bool
00167 HepBoost::operator == (const HepBoost & b) const {
00168   const HepRep4x4Symmetric & s1 = b.rep4x4Symmetric();
00169   return ( 
00170      rep_.xx_==s1.xx_ && rep_.xy_==s1.xy_ && rep_.xz_==s1.xz_ && rep_.xt_==s1.xt_
00171                    && rep_.yy_==s1.yy_ && rep_.yz_==s1.yz_ && rep_.yt_==s1.yt_
00172                                       && rep_.zz_==s1.zz_ && rep_.zt_==s1.zt_
00173                                                          && rep_.tt_==s1.tt_
00174   );
00175 }
00176 
00177 inline bool
00178 HepBoost::operator != (const HepBoost & r) const {
00179   return ( !(operator==(r)) );
00180 }
00181 inline bool HepBoost::operator <= ( const HepBoost & b ) const
00182         { return compare(b)<= 0; }
00183 inline bool HepBoost::operator >= ( const HepBoost & b ) const
00184         { return compare(b)>= 0; }
00185 inline bool HepBoost::operator <  ( const HepBoost & b ) const
00186         { return compare(b)<  0; }
00187 inline bool HepBoost::operator >  ( const HepBoost & b ) const
00188         { return compare(b)>  0; }
00189 
00190 inline bool HepBoost::isIdentity() const {
00191   return (xx() == 1.0 && xy() == 0.0 && xz() == 0.0 && xt() == 0.0 
00192                       && yy() == 1.0 && yz() == 0.0 && yt() == 0.0 
00193                                      && zz() == 1.0 && zt() == 0.0 
00194                                                     && tt() == 1.0);
00195 }
00196 
00197 inline double HepBoost::distance2( const HepBoost & b ) const {
00198   double bgx = rep_.xt_ - b.rep_.xt_;
00199   double bgy = rep_.yt_ - b.rep_.yt_;
00200   double bgz = rep_.zt_ - b.rep_.zt_;
00201   return bgx*bgx+bgy*bgy+bgz*bgz;
00202 }
00203 
00204 inline double HepBoost::distance2( const HepBoostX & bx ) const {
00205   double bgx = rep_.xt_ - bx.beta()*bx.gamma();
00206   double bgy = rep_.yt_;
00207   double bgz = rep_.zt_;
00208   return bgx*bgx+bgy*bgy+bgz*bgz;
00209 }
00210 
00211 inline double HepBoost::distance2( const HepBoostY & by ) const {
00212   double bgy = rep_.xt_;
00213   double bgx = rep_.yt_ - by.beta()*by.gamma();
00214   double bgz = rep_.zt_;
00215   return bgx*bgx+bgy*bgy+bgz*bgz;
00216 }
00217 
00218 inline double HepBoost::distance2( const HepBoostZ & bz ) const {
00219   double bgz = rep_.xt_;
00220   double bgy = rep_.yt_;
00221   double bgx = rep_.zt_ - bz.beta()*bz.gamma();
00222   return bgx*bgx+bgy*bgy+bgz*bgz;
00223 }
00224 
00225 inline double HepBoost::howNear ( const HepBoost & b ) const {
00226   return std::sqrt(distance2(b));
00227 }
00228 
00229 inline bool HepBoost::isNear(const HepBoost & b, double epsilon) const{
00230   return (distance2(b) <= epsilon*epsilon);
00231 }
00232 
00233 // ---------- Application:
00234 
00235 // - Protected method:
00236 inline HepLorentzVector
00237 HepBoost::vectorMultiplication(const HepLorentzVector & p) const {
00238   register double x = p.x();
00239   register double y = p.y();
00240   register double z = p.z();
00241   register double t = p.t();
00242   return HepLorentzVector( rep_.xx_*x + rep_.xy_*y + rep_.xz_*z + rep_.xt_*t,
00243                            rep_.xy_*x + rep_.yy_*y + rep_.yz_*z + rep_.yt_*t,
00244                            rep_.xz_*x + rep_.yz_*y + rep_.zz_*z + rep_.zt_*t,
00245                            rep_.xt_*x + rep_.yt_*y + rep_.zt_*z + rep_.tt_*t);
00246 }
00247 
00248 inline HepLorentzVector
00249 HepBoost::operator () (const HepLorentzVector & p) const {
00250   return vectorMultiplication(p);
00251 }
00252 
00253 inline HepLorentzVector
00254 HepBoost::operator * (const HepLorentzVector & p) const {
00255   return vectorMultiplication(p);
00256 }
00257 
00258 
00259 // ---------- Operations in the group of 4-Rotations
00260 
00261 inline HepBoost HepBoost::inverse() const {
00262   return HepBoost( xx(),  yx(),  zx(), -tx(),
00263                           yy(),  zy(), -ty(),
00264                                  zz(), -tz(),
00265                                         tt());
00266 }
00267 
00268 inline HepBoost inverseOf ( const HepBoost & lt ) {
00269   return HepBoost( lt.xx(),  lt.yx(),  lt.zx(), -lt.tx(),
00270                              lt.yy(),  lt.zy(), -lt.ty(),
00271                                        lt.zz(), -lt.tz(),
00272                                                  lt.tt());
00273 }
00274 
00275 inline HepBoost & HepBoost::invert() {
00276   rep_.xt_ = -rep_.xt_;
00277   rep_.yt_ = -rep_.yt_;
00278   rep_.zt_ = -rep_.zt_;
00279   return *this;
00280 }
00281 
00282 // ---------- Tolerance:
00283 
00284 inline double HepBoost::getTolerance() {
00285   return Hep4RotationInterface::tolerance;
00286 }
00287 inline double HepBoost::setTolerance(double tol) {
00288   return Hep4RotationInterface::setTolerance(tol);
00289 }
00290 
00291 }  // namespace CLHEP

Generated on Mon May 27 17:47:34 2013 for Geant4 by  doxygen 1.4.7