2 // ---------------------------------------------------------------------------
 
    4 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
 
    6 // This is the definitions of the inline member functions of the
 
   14 // ----------  Constructors and Assignment:
 
   16 inline HepBoost::HepBoost() : rep_() {}
 
   18 inline HepBoost::HepBoost(const HepBoost & m1) : rep_(m1.rep_) {}
 
   20 inline HepBoost & HepBoost::operator = (const HepBoost & m1) { 
 
   25 inline HepBoost::HepBoost(double betaX, double betaY, double betaZ) 
 
   27   set(betaX, betaY, betaZ);
 
   30 inline HepBoost::HepBoost(const HepRep4x4Symmetric & m1) : rep_(m1) {}
 
   32 inline HepBoost::HepBoost(Hep3Vector ddirection, double bbeta) 
 
   34   double length = ddirection.mag();
 
   36     std::cerr << "HepBoost::HepBoost() - "
 
   37               << "HepBoost constructed using a zero vector as direction"
 
   41   set(bbeta*ddirection.x()/length,
 
   42       bbeta*ddirection.y()/length,
 
   43       bbeta*ddirection.z()/length);
 
   46 inline HepBoost::HepBoost(const Hep3Vector & boost) 
 
   48   set(boost.x(), boost.y(), boost.z());
 
   51 inline HepBoost::HepBoost(const HepBoostX & boost) {set(boost.boostVector());}
 
   52 inline HepBoost::HepBoost(const HepBoostY & boost) {set(boost.boostVector());}
 
   53 inline HepBoost::HepBoost(const HepBoostZ & boost) {set(boost.boostVector());}
 
   54 inline HepBoost & HepBoost::set(const HepBoostX & boost) 
 
   55                                        {return set(boost.boostVector());}
 
   56 inline HepBoost & HepBoost::set(const HepBoostY & boost)
 
   57                                        {return set(boost.boostVector());}
 
   58 inline HepBoost & HepBoost::set(const HepBoostZ & boost)
 
   59                                        {return set(boost.boostVector());}
 
   61 // - Protected method:
 
   62 inline HepBoost::HepBoost ( 
 
   63   double xx1, double xy1, double xz1, double xt1,
 
   64               double yy1, double yz1, double yt1,
 
   65                           double zz1, double zt1,
 
   67      rep_ ( xx1, xy1, xz1, xt1, yy1, yz1, yt1, zz1, zt1, tt1 ) {}  
 
   69 // ----------  Accessors:
 
   71 inline double  HepBoost::beta() const {   
 
   72   return std::sqrt( 1.0 - 1.0 / (rep_.tt_ * rep_.tt_) );
 
   75 inline double  HepBoost::gamma() const {
 
   79 inline Hep3Vector HepBoost::boostVector() const { 
 
   80   return  (1.0/rep_.tt_) * Hep3Vector( rep_.xt_, rep_.yt_, rep_.zt_ );
 
   83 inline Hep3Vector HepBoost::getDirection() const { 
 
   84   double norm = 1.0/beta();
 
   85   return  (norm*boostVector());
 
   88 inline Hep3Vector HepBoost::direction() const { 
 
   89   return  getDirection();
 
   92 inline double HepBoost::xx() const { return rep_.xx_; }
 
   93 inline double HepBoost::xy() const { return rep_.xy_; }
 
   94 inline double HepBoost::xz() const { return rep_.xz_; }
 
   95 inline double HepBoost::xt() const { return rep_.xt_; }
 
   96 inline double HepBoost::yx() const { return rep_.xy_; }
 
   97 inline double HepBoost::yy() const { return rep_.yy_; }
 
   98 inline double HepBoost::yz() const { return rep_.yz_; }
 
   99 inline double HepBoost::yt() const { return rep_.yt_; }
 
  100 inline double HepBoost::zx() const { return rep_.xz_; }
 
  101 inline double HepBoost::zy() const { return rep_.yz_; }
 
  102 inline double HepBoost::zz() const { return rep_.zz_; }
 
  103 inline double HepBoost::zt() const { return rep_.zt_; }
 
  104 inline double HepBoost::tx() const { return rep_.xt_; }
 
  105 inline double HepBoost::ty() const { return rep_.yt_; }
 
  106 inline double HepBoost::tz() const { return rep_.zt_; }
 
  107 inline double HepBoost::tt() const { return rep_.tt_; }
 
  109 inline HepLorentzVector HepBoost::col1() const {
 
  110   return HepLorentzVector ( xx(), yx(), zx(), tx() );
 
  112 inline HepLorentzVector HepBoost::col2() const {
 
  113   return HepLorentzVector ( xy(), yy(), zy(), ty() );
 
  115 inline HepLorentzVector HepBoost::col3() const {
 
  116   return HepLorentzVector ( xz(), yz(), zz(), tz() );
 
  118 inline HepLorentzVector HepBoost::col4() const {
 
  119   return HepLorentzVector ( xt(), yt(), zt(), tt() );
 
  122 inline HepLorentzVector HepBoost::row1() const {
 
  123   return HepLorentzVector ( col1() );
 
  125 inline HepLorentzVector HepBoost::row2() const {
 
  126   return HepLorentzVector ( col2() );
 
  128 inline HepLorentzVector HepBoost::row3() const {
 
  129   return HepLorentzVector ( col3() );
 
  131 inline HepLorentzVector HepBoost::row4() const {
 
  132   return HepLorentzVector ( col4() );
 
  135 inline HepRep4x4 HepBoost::rep4x4() const {
 
  136   return HepRep4x4( rep_ );
 
  139 inline HepRep4x4Symmetric HepBoost::rep4x4Symmetric() const {
 
  144 inline void HepBoost::setBoost(double bx, double by, double bz) {
 
  149 // ----------  Comparisons:
 
  151 int HepBoost::compare ( const HepBoost & b ) const {
 
  152   const HepRep4x4Symmetric & s1 = b.rep4x4Symmetric();
 
  153        if (rep_.tt_ < s1.tt_) return -1; else if (rep_.tt_ > s1.tt_) return 1;
 
  154   else if (rep_.zt_ < s1.zt_) return -1; else if (rep_.zt_ > s1.zt_) return 1;
 
  155   else if (rep_.zz_ < s1.zz_) return -1; else if (rep_.zz_ > s1.zz_) return 1;
 
  156   else if (rep_.yt_ < s1.yt_) return -1; else if (rep_.yt_ > s1.yt_) return 1;
 
  157   else if (rep_.yz_ < s1.yz_) return -1; else if (rep_.yz_ > s1.yz_) return 1;
 
  158   else if (rep_.yy_ < s1.yy_) return -1; else if (rep_.yy_ > s1.yy_) return 1;
 
  159   else if (rep_.xt_ < s1.xt_) return -1; else if (rep_.xt_ > s1.xt_) return 1;
 
  160   else if (rep_.xz_ < s1.xz_) return -1; else if (rep_.xz_ > s1.xz_) return 1;
 
  161   else if (rep_.xy_ < s1.xy_) return -1; else if (rep_.xy_ > s1.xy_) return 1;
 
  162   else if (rep_.xx_ < s1.xx_) return -1; else if (rep_.xx_ > s1.xx_) return 1;
 
  167 HepBoost::operator == (const HepBoost & b) const {
 
  168   const HepRep4x4Symmetric & s1 = b.rep4x4Symmetric();
 
  170      rep_.xx_==s1.xx_ && rep_.xy_==s1.xy_ && rep_.xz_==s1.xz_ && rep_.xt_==s1.xt_
 
  171                    && rep_.yy_==s1.yy_ && rep_.yz_==s1.yz_ && rep_.yt_==s1.yt_
 
  172                                       && rep_.zz_==s1.zz_ && rep_.zt_==s1.zt_
 
  178 HepBoost::operator != (const HepBoost & r) const {
 
  179   return ( !(operator==(r)) );
 
  181 inline bool HepBoost::operator <= ( const HepBoost & b ) const
 
  182         { return compare(b)<= 0; }
 
  183 inline bool HepBoost::operator >= ( const HepBoost & b ) const
 
  184         { return compare(b)>= 0; }
 
  185 inline bool HepBoost::operator <  ( const HepBoost & b ) const
 
  186         { return compare(b)<  0; }
 
  187 inline bool HepBoost::operator >  ( const HepBoost & b ) const
 
  188         { return compare(b)>  0; }
 
  190 inline bool HepBoost::isIdentity() const {
 
  191   return (xx() == 1.0 && xy() == 0.0 && xz() == 0.0 && xt() == 0.0 
 
  192                  && yy() == 1.0 && yz() == 0.0 && yt() == 0.0 
 
  193                                 && zz() == 1.0 && zt() == 0.0 
 
  197 inline double HepBoost::distance2( const HepBoost & b ) const {
 
  198   double bgx = rep_.xt_ - b.rep_.xt_;
 
  199   double bgy = rep_.yt_ - b.rep_.yt_;
 
  200   double bgz = rep_.zt_ - b.rep_.zt_;
 
  201   return bgx*bgx+bgy*bgy+bgz*bgz;
 
  204 inline double HepBoost::distance2( const HepBoostX & bx ) const {
 
  205   double bgx = rep_.xt_ - bx.beta()*bx.gamma();
 
  206   double bgy = rep_.yt_;
 
  207   double bgz = rep_.zt_;
 
  208   return bgx*bgx+bgy*bgy+bgz*bgz;
 
  211 inline double HepBoost::distance2( const HepBoostY & by ) const {
 
  212   double bgy = rep_.xt_;
 
  213   double bgx = rep_.yt_ - by.beta()*by.gamma();
 
  214   double bgz = rep_.zt_;
 
  215   return bgx*bgx+bgy*bgy+bgz*bgz;
 
  218 inline double HepBoost::distance2( const HepBoostZ & bz ) const {
 
  219   double bgz = rep_.xt_;
 
  220   double bgy = rep_.yt_;
 
  221   double bgx = rep_.zt_ - bz.beta()*bz.gamma();
 
  222   return bgx*bgx+bgy*bgy+bgz*bgz;
 
  225 inline double HepBoost::howNear ( const HepBoost & b ) const {
 
  226   return std::sqrt(distance2(b));
 
  229 inline bool HepBoost::isNear(const HepBoost & b, double epsilon) const{
 
  230   return (distance2(b) <= epsilon*epsilon);
 
  233 // ---------- Application:
 
  235 // - Protected method:
 
  236 inline HepLorentzVector
 
  237 HepBoost::vectorMultiplication(const HepLorentzVector & p) const {
 
  242   return HepLorentzVector( rep_.xx_*x + rep_.xy_*y + rep_.xz_*z + rep_.xt_*t,
 
  243                       rep_.xy_*x + rep_.yy_*y + rep_.yz_*z + rep_.yt_*t,
 
  244                       rep_.xz_*x + rep_.yz_*y + rep_.zz_*z + rep_.zt_*t,
 
  245                       rep_.xt_*x + rep_.yt_*y + rep_.zt_*z + rep_.tt_*t);
 
  248 inline HepLorentzVector
 
  249 HepBoost::operator () (const HepLorentzVector & p) const {
 
  250   return vectorMultiplication(p);
 
  253 inline HepLorentzVector
 
  254 HepBoost::operator * (const HepLorentzVector & p) const {
 
  255   return vectorMultiplication(p);
 
  259 // ---------- Operations in the group of 4-Rotations
 
  261 inline HepBoost HepBoost::inverse() const {
 
  262   return HepBoost( xx(),  yx(),  zx(), -tx(),
 
  268 inline HepBoost inverseOf ( const HepBoost & lt ) {
 
  269   return HepBoost( lt.xx(),  lt.yx(),  lt.zx(), -lt.tx(),
 
  270                              lt.yy(),  lt.zy(), -lt.ty(),
 
  275 inline HepBoost & HepBoost::invert() {
 
  276   rep_.xt_ = -rep_.xt_;
 
  277   rep_.yt_ = -rep_.yt_;
 
  278   rep_.zt_ = -rep_.zt_;
 
  282 // ---------- Tolerance:
 
  284 inline double HepBoost::getTolerance() {
 
  285   return Hep4RotationInterface::tolerance;
 
  287 inline double HepBoost::setTolerance(double tol) {
 
  288   return Hep4RotationInterface::setTolerance(tol);