File indexing completed on 2025-01-18 09:54:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <cmath>
0011
0012 namespace CLHEP {
0013
0014
0015
0016 inline HepBoost::HepBoost() : rep_() {}
0017
0018 inline HepBoost::HepBoost(const HepBoost & m1) : rep_(m1.rep_) {}
0019
0020 inline HepBoost & HepBoost::operator = (const HepBoost & m1) {
0021 rep_ = m1.rep_;
0022 return *this;
0023 }
0024
0025 inline HepBoost::HepBoost(double betaX, double betaY, double betaZ)
0026 {
0027 set(betaX, betaY, betaZ);
0028 }
0029
0030 inline HepBoost::HepBoost(const HepRep4x4Symmetric & m1) : rep_(m1) {}
0031
0032 inline HepBoost::HepBoost(Hep3Vector ddirection, double bbeta)
0033 {
0034 double length = ddirection.mag();
0035 if (length==0) {
0036 ZMthrowC ( ZMxpvZeroVector("HepBoost constructed using a zero vector as direction") );
0037 set(0,0,0);
0038 }
0039 set(bbeta*ddirection.x()/length,
0040 bbeta*ddirection.y()/length,
0041 bbeta*ddirection.z()/length);
0042 }
0043
0044 inline HepBoost::HepBoost(const Hep3Vector & boost)
0045 {
0046 set(boost.x(), boost.y(), boost.z());
0047 }
0048
0049 inline HepBoost::HepBoost(const HepBoostX & boost) {set(boost.boostVector());}
0050 inline HepBoost::HepBoost(const HepBoostY & boost) {set(boost.boostVector());}
0051 inline HepBoost::HepBoost(const HepBoostZ & boost) {set(boost.boostVector());}
0052 inline HepBoost & HepBoost::set(const HepBoostX & boost)
0053 {return set(boost.boostVector());}
0054 inline HepBoost & HepBoost::set(const HepBoostY & boost)
0055 {return set(boost.boostVector());}
0056 inline HepBoost & HepBoost::set(const HepBoostZ & boost)
0057 {return set(boost.boostVector());}
0058
0059
0060 inline HepBoost::HepBoost (
0061 double xx1, double xy1, double xz1, double xt1,
0062 double yy1, double yz1, double yt1,
0063 double zz1, double zt1,
0064 double tt1) :
0065 rep_ ( xx1, xy1, xz1, xt1, yy1, yz1, yt1, zz1, zt1, tt1 ) {}
0066
0067
0068
0069 inline double HepBoost::beta() const {
0070 return std::sqrt( 1.0 - 1.0 / (rep_.tt_ * rep_.tt_) );
0071 }
0072
0073 inline double HepBoost::gamma() const {
0074 return rep_.tt_;
0075 }
0076
0077 inline Hep3Vector HepBoost::boostVector() const {
0078 return (1.0/rep_.tt_) * Hep3Vector( rep_.xt_, rep_.yt_, rep_.zt_ );
0079 }
0080
0081 inline Hep3Vector HepBoost::getDirection() const {
0082 double norm = 1.0/beta();
0083 return (norm*boostVector());
0084 }
0085
0086 inline Hep3Vector HepBoost::direction() const {
0087 return getDirection();
0088 }
0089
0090 inline double HepBoost::xx() const { return rep_.xx_; }
0091 inline double HepBoost::xy() const { return rep_.xy_; }
0092 inline double HepBoost::xz() const { return rep_.xz_; }
0093 inline double HepBoost::xt() const { return rep_.xt_; }
0094 inline double HepBoost::yx() const { return rep_.xy_; }
0095 inline double HepBoost::yy() const { return rep_.yy_; }
0096 inline double HepBoost::yz() const { return rep_.yz_; }
0097 inline double HepBoost::yt() const { return rep_.yt_; }
0098 inline double HepBoost::zx() const { return rep_.xz_; }
0099 inline double HepBoost::zy() const { return rep_.yz_; }
0100 inline double HepBoost::zz() const { return rep_.zz_; }
0101 inline double HepBoost::zt() const { return rep_.zt_; }
0102 inline double HepBoost::tx() const { return rep_.xt_; }
0103 inline double HepBoost::ty() const { return rep_.yt_; }
0104 inline double HepBoost::tz() const { return rep_.zt_; }
0105 inline double HepBoost::tt() const { return rep_.tt_; }
0106
0107 inline HepLorentzVector HepBoost::col1() const {
0108 return HepLorentzVector ( xx(), yx(), zx(), tx() );
0109 }
0110 inline HepLorentzVector HepBoost::col2() const {
0111 return HepLorentzVector ( xy(), yy(), zy(), ty() );
0112 }
0113 inline HepLorentzVector HepBoost::col3() const {
0114 return HepLorentzVector ( xz(), yz(), zz(), tz() );
0115 }
0116 inline HepLorentzVector HepBoost::col4() const {
0117 return HepLorentzVector ( xt(), yt(), zt(), tt() );
0118 }
0119
0120 inline HepLorentzVector HepBoost::row1() const {
0121 return HepLorentzVector ( col1() );
0122 }
0123 inline HepLorentzVector HepBoost::row2() const {
0124 return HepLorentzVector ( col2() );
0125 }
0126 inline HepLorentzVector HepBoost::row3() const {
0127 return HepLorentzVector ( col3() );
0128 }
0129 inline HepLorentzVector HepBoost::row4() const {
0130 return HepLorentzVector ( col4() );
0131 }
0132
0133 inline HepRep4x4 HepBoost::rep4x4() const {
0134 return HepRep4x4( rep_ );
0135 }
0136
0137 inline HepRep4x4Symmetric HepBoost::rep4x4Symmetric() const {
0138 return rep_;
0139 }
0140
0141
0142 inline void HepBoost::setBoost(double bx, double by, double bz) {
0143 set(bx, by, bz);
0144 }
0145
0146
0147
0148
0149 int HepBoost::compare ( const HepBoost & b ) const {
0150 const HepRep4x4Symmetric & s1 = b.rep4x4Symmetric();
0151 if (rep_.tt_ < s1.tt_) return -1; else if (rep_.tt_ > s1.tt_) return 1;
0152 else if (rep_.zt_ < s1.zt_) return -1; else if (rep_.zt_ > s1.zt_) return 1;
0153 else if (rep_.zz_ < s1.zz_) return -1; else if (rep_.zz_ > s1.zz_) return 1;
0154 else if (rep_.yt_ < s1.yt_) return -1; else if (rep_.yt_ > s1.yt_) return 1;
0155 else if (rep_.yz_ < s1.yz_) return -1; else if (rep_.yz_ > s1.yz_) return 1;
0156 else if (rep_.yy_ < s1.yy_) return -1; else if (rep_.yy_ > s1.yy_) return 1;
0157 else if (rep_.xt_ < s1.xt_) return -1; else if (rep_.xt_ > s1.xt_) return 1;
0158 else if (rep_.xz_ < s1.xz_) return -1; else if (rep_.xz_ > s1.xz_) return 1;
0159 else if (rep_.xy_ < s1.xy_) return -1; else if (rep_.xy_ > s1.xy_) return 1;
0160 else if (rep_.xx_ < s1.xx_) return -1; else if (rep_.xx_ > s1.xx_) return 1;
0161 else return 0;
0162 }
0163
0164 inline bool
0165 HepBoost::operator == (const HepBoost & b) const {
0166 const HepRep4x4Symmetric & s1 = b.rep4x4Symmetric();
0167 return (
0168 rep_.xx_==s1.xx_ && rep_.xy_==s1.xy_ && rep_.xz_==s1.xz_ && rep_.xt_==s1.xt_
0169 && rep_.yy_==s1.yy_ && rep_.yz_==s1.yz_ && rep_.yt_==s1.yt_
0170 && rep_.zz_==s1.zz_ && rep_.zt_==s1.zt_
0171 && rep_.tt_==s1.tt_
0172 );
0173 }
0174
0175 inline bool
0176 HepBoost::operator != (const HepBoost & r) const {
0177 return ( !(operator==(r)) );
0178 }
0179 inline bool HepBoost::operator <= ( const HepBoost & b ) const
0180 { return compare(b)<= 0; }
0181 inline bool HepBoost::operator >= ( const HepBoost & b ) const
0182 { return compare(b)>= 0; }
0183 inline bool HepBoost::operator < ( const HepBoost & b ) const
0184 { return compare(b)< 0; }
0185 inline bool HepBoost::operator > ( const HepBoost & b ) const
0186 { return compare(b)> 0; }
0187
0188 inline bool HepBoost::isIdentity() const {
0189 return (xx() == 1.0 && xy() == 0.0 && xz() == 0.0 && xt() == 0.0
0190 && yy() == 1.0 && yz() == 0.0 && yt() == 0.0
0191 && zz() == 1.0 && zt() == 0.0
0192 && tt() == 1.0);
0193 }
0194
0195 inline double HepBoost::distance2( const HepBoost & b ) const {
0196 double bgx = rep_.xt_ - b.rep_.xt_;
0197 double bgy = rep_.yt_ - b.rep_.yt_;
0198 double bgz = rep_.zt_ - b.rep_.zt_;
0199 return bgx*bgx+bgy*bgy+bgz*bgz;
0200 }
0201
0202 inline double HepBoost::distance2( const HepBoostX & bx ) const {
0203 double bgx = rep_.xt_ - bx.beta()*bx.gamma();
0204 double bgy = rep_.yt_;
0205 double bgz = rep_.zt_;
0206 return bgx*bgx+bgy*bgy+bgz*bgz;
0207 }
0208
0209 inline double HepBoost::distance2( const HepBoostY & by ) const {
0210 double bgy = rep_.xt_;
0211 double bgx = rep_.yt_ - by.beta()*by.gamma();
0212 double bgz = rep_.zt_;
0213 return bgx*bgx+bgy*bgy+bgz*bgz;
0214 }
0215
0216 inline double HepBoost::distance2( const HepBoostZ & bz ) const {
0217 double bgz = rep_.xt_;
0218 double bgy = rep_.yt_;
0219 double bgx = rep_.zt_ - bz.beta()*bz.gamma();
0220 return bgx*bgx+bgy*bgy+bgz*bgz;
0221 }
0222
0223 inline double HepBoost::howNear ( const HepBoost & b ) const {
0224 return std::sqrt(distance2(b));
0225 }
0226
0227 inline bool HepBoost::isNear(const HepBoost & b, double epsilon) const{
0228 return (distance2(b) <= epsilon*epsilon);
0229 }
0230
0231
0232
0233
0234 inline HepLorentzVector
0235 HepBoost::vectorMultiplication(const HepLorentzVector & p) const {
0236 double x = p.x();
0237 double y = p.y();
0238 double z = p.z();
0239 double t = p.t();
0240 return HepLorentzVector( rep_.xx_*x + rep_.xy_*y + rep_.xz_*z + rep_.xt_*t,
0241 rep_.xy_*x + rep_.yy_*y + rep_.yz_*z + rep_.yt_*t,
0242 rep_.xz_*x + rep_.yz_*y + rep_.zz_*z + rep_.zt_*t,
0243 rep_.xt_*x + rep_.yt_*y + rep_.zt_*z + rep_.tt_*t);
0244 }
0245
0246 inline HepLorentzVector
0247 HepBoost::operator () (const HepLorentzVector & p) const {
0248 return vectorMultiplication(p);
0249 }
0250
0251 inline HepLorentzVector
0252 HepBoost::operator * (const HepLorentzVector & p) const {
0253 return vectorMultiplication(p);
0254 }
0255
0256
0257
0258
0259 inline HepBoost HepBoost::inverse() const {
0260 return HepBoost( xx(), yx(), zx(), -tx(),
0261 yy(), zy(), -ty(),
0262 zz(), -tz(),
0263 tt());
0264 }
0265
0266 inline HepBoost inverseOf ( const HepBoost & lt ) {
0267 return HepBoost( lt.xx(), lt.yx(), lt.zx(), -lt.tx(),
0268 lt.yy(), lt.zy(), -lt.ty(),
0269 lt.zz(), -lt.tz(),
0270 lt.tt());
0271 }
0272
0273 inline HepBoost & HepBoost::invert() {
0274 rep_.xt_ = -rep_.xt_;
0275 rep_.yt_ = -rep_.yt_;
0276 rep_.zt_ = -rep_.zt_;
0277 return *this;
0278 }
0279
0280
0281
0282 inline double HepBoost::getTolerance() {
0283 return Hep4RotationInterface::tolerance;
0284 }
0285 inline double HepBoost::setTolerance(double tol) {
0286 return Hep4RotationInterface::setTolerance(tol);
0287 }
0288
0289 }