[4] | 1 | // -*- C++ -*-
|
---|
| 2 | // ---------------------------------------------------------------------------
|
---|
| 3 | //
|
---|
| 4 | // This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
---|
| 5 | //
|
---|
| 6 | // This is the definitions of the inline member functions of the
|
---|
| 7 | // HepBoost class
|
---|
| 8 | //
|
---|
| 9 |
|
---|
| 10 | #include <cmath>
|
---|
| 11 |
|
---|
| 12 | namespace CLHEP {
|
---|
| 13 |
|
---|
| 14 | // ---------- Constructors and Assignment:
|
---|
| 15 |
|
---|
| 16 | inline HepBoost::HepBoost() : rep_() {}
|
---|
| 17 |
|
---|
| 18 | inline HepBoost::HepBoost(const HepBoost & m) : rep_(m.rep_) {}
|
---|
| 19 |
|
---|
| 20 | inline HepBoost & HepBoost::operator = (const HepBoost & m) {
|
---|
| 21 | rep_ = m.rep_;
|
---|
| 22 | return *this;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | inline HepBoost::HepBoost(double betaX, double betaY, double betaZ)
|
---|
| 26 | {
|
---|
| 27 | set(betaX, betaY, betaZ);
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | inline HepBoost::HepBoost(const HepRep4x4Symmetric & m) : rep_(m) {}
|
---|
| 31 |
|
---|
| 32 | inline HepBoost::HepBoost(Hep3Vector direction, double beta)
|
---|
| 33 | {
|
---|
| 34 | double length = direction.mag();
|
---|
| 35 | if (length==0) {
|
---|
| 36 | ZMthrowC ( ZMxpvZeroVector("HepBoost constructed using a zero vector as direction") );
|
---|
| 37 | set(0,0,0);
|
---|
| 38 | }
|
---|
| 39 | set(beta*direction.x()/length,
|
---|
| 40 | beta*direction.y()/length,
|
---|
| 41 | beta*direction.z()/length);
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | inline HepBoost::HepBoost(const Hep3Vector & boost)
|
---|
| 45 | {
|
---|
| 46 | set(boost.x(), boost.y(), boost.z());
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | inline HepBoost::HepBoost(const HepBoostX & boost) {set(boost.boostVector());}
|
---|
| 50 | inline HepBoost::HepBoost(const HepBoostY & boost) {set(boost.boostVector());}
|
---|
| 51 | inline HepBoost::HepBoost(const HepBoostZ & boost) {set(boost.boostVector());}
|
---|
| 52 | inline HepBoost & HepBoost::set(const HepBoostX & boost)
|
---|
| 53 | {return set(boost.boostVector());}
|
---|
| 54 | inline HepBoost & HepBoost::set(const HepBoostY & boost)
|
---|
| 55 | {return set(boost.boostVector());}
|
---|
| 56 | inline HepBoost & HepBoost::set(const HepBoostZ & boost)
|
---|
| 57 | {return set(boost.boostVector());}
|
---|
| 58 |
|
---|
| 59 | // - Protected method:
|
---|
| 60 | inline HepBoost::HepBoost (
|
---|
| 61 | double xx, double xy, double xz, double xt,
|
---|
| 62 | double yy, double yz, double yt,
|
---|
| 63 | double zz, double zt,
|
---|
| 64 | double tt) :
|
---|
| 65 | rep_ ( xx, xy, xz, xt, yy, yz, yt, zz, zt, tt ) {}
|
---|
| 66 |
|
---|
| 67 | // ---------- Accessors:
|
---|
| 68 |
|
---|
| 69 | inline double HepBoost::beta() const {
|
---|
| 70 | return std::sqrt( 1.0 - 1.0 / (rep_.tt_ * rep_.tt_) );
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | inline double HepBoost::gamma() const {
|
---|
| 74 | return rep_.tt_;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | inline Hep3Vector HepBoost::boostVector() const {
|
---|
| 78 | return (1.0/rep_.tt_) * Hep3Vector( rep_.xt_, rep_.yt_, rep_.zt_ );
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | inline Hep3Vector HepBoost::getDirection() const {
|
---|
| 82 | double norm = 1.0/beta();
|
---|
| 83 | return (norm*boostVector());
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | inline Hep3Vector HepBoost::direction() const {
|
---|
| 87 | return getDirection();
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | inline double HepBoost::xx() const { return rep_.xx_; }
|
---|
| 91 | inline double HepBoost::xy() const { return rep_.xy_; }
|
---|
| 92 | inline double HepBoost::xz() const { return rep_.xz_; }
|
---|
| 93 | inline double HepBoost::xt() const { return rep_.xt_; }
|
---|
| 94 | inline double HepBoost::yx() const { return rep_.xy_; }
|
---|
| 95 | inline double HepBoost::yy() const { return rep_.yy_; }
|
---|
| 96 | inline double HepBoost::yz() const { return rep_.yz_; }
|
---|
| 97 | inline double HepBoost::yt() const { return rep_.yt_; }
|
---|
| 98 | inline double HepBoost::zx() const { return rep_.xz_; }
|
---|
| 99 | inline double HepBoost::zy() const { return rep_.yz_; }
|
---|
| 100 | inline double HepBoost::zz() const { return rep_.zz_; }
|
---|
| 101 | inline double HepBoost::zt() const { return rep_.zt_; }
|
---|
| 102 | inline double HepBoost::tx() const { return rep_.xt_; }
|
---|
| 103 | inline double HepBoost::ty() const { return rep_.yt_; }
|
---|
| 104 | inline double HepBoost::tz() const { return rep_.zt_; }
|
---|
| 105 | inline double HepBoost::tt() const { return rep_.tt_; }
|
---|
| 106 |
|
---|
| 107 | inline HepLorentzVector HepBoost::col1() const {
|
---|
| 108 | return HepLorentzVector ( xx(), yx(), zx(), tx() );
|
---|
| 109 | }
|
---|
| 110 | inline HepLorentzVector HepBoost::col2() const {
|
---|
| 111 | return HepLorentzVector ( xy(), yy(), zy(), ty() );
|
---|
| 112 | }
|
---|
| 113 | inline HepLorentzVector HepBoost::col3() const {
|
---|
| 114 | return HepLorentzVector ( xz(), yz(), zz(), tz() );
|
---|
| 115 | }
|
---|
| 116 | inline HepLorentzVector HepBoost::col4() const {
|
---|
| 117 | return HepLorentzVector ( xt(), yt(), zt(), tt() );
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | inline HepLorentzVector HepBoost::row1() const {
|
---|
| 121 | return HepLorentzVector ( col1() );
|
---|
| 122 | }
|
---|
| 123 | inline HepLorentzVector HepBoost::row2() const {
|
---|
| 124 | return HepLorentzVector ( col2() );
|
---|
| 125 | }
|
---|
| 126 | inline HepLorentzVector HepBoost::row3() const {
|
---|
| 127 | return HepLorentzVector ( col3() );
|
---|
| 128 | }
|
---|
| 129 | inline HepLorentzVector HepBoost::row4() const {
|
---|
| 130 | return HepLorentzVector ( col4() );
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | inline HepRep4x4 HepBoost::rep4x4() const {
|
---|
| 134 | return HepRep4x4( rep_ );
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | inline HepRep4x4Symmetric HepBoost::rep4x4Symmetric() const {
|
---|
| 138 | return rep_;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | inline void HepBoost::setBoost(double bx, double by, double bz) {
|
---|
| 143 | set(bx, by, bz);
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | // ---------- Comparisons:
|
---|
| 148 |
|
---|
| 149 | int HepBoost::compare ( const HepBoost & b ) const {
|
---|
| 150 | const HepRep4x4Symmetric & s = b.rep4x4Symmetric();
|
---|
| 151 | if (rep_.tt_ < s.tt_) return -1; else if (rep_.tt_ > s.tt_) return 1;
|
---|
| 152 | else if (rep_.zt_ < s.zt_) return -1; else if (rep_.zt_ > s.zt_) return 1;
|
---|
| 153 | else if (rep_.zz_ < s.zz_) return -1; else if (rep_.zz_ > s.zz_) return 1;
|
---|
| 154 | else if (rep_.yt_ < s.yt_) return -1; else if (rep_.yt_ > s.yt_) return 1;
|
---|
| 155 | else if (rep_.yz_ < s.yz_) return -1; else if (rep_.yz_ > s.yz_) return 1;
|
---|
| 156 | else if (rep_.yy_ < s.yy_) return -1; else if (rep_.yy_ > s.yy_) return 1;
|
---|
| 157 | else if (rep_.xt_ < s.xt_) return -1; else if (rep_.xt_ > s.xt_) return 1;
|
---|
| 158 | else if (rep_.xz_ < s.xz_) return -1; else if (rep_.xz_ > s.xz_) return 1;
|
---|
| 159 | else if (rep_.xy_ < s.xy_) return -1; else if (rep_.xy_ > s.xy_) return 1;
|
---|
| 160 | else if (rep_.xx_ < s.xx_) return -1; else if (rep_.xx_ > s.xx_) return 1;
|
---|
| 161 | else return 0;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | inline bool
|
---|
| 165 | HepBoost::operator == (const HepBoost & b) const {
|
---|
| 166 | const HepRep4x4Symmetric & s = b.rep4x4Symmetric();
|
---|
| 167 | return (
|
---|
| 168 | rep_.xx_==s.xx_ && rep_.xy_==s.xy_ && rep_.xz_==s.xz_ && rep_.xt_==s.xt_
|
---|
| 169 | && rep_.yy_==s.yy_ && rep_.yz_==s.yz_ && rep_.yt_==s.yt_
|
---|
| 170 | && rep_.zz_==s.zz_ && rep_.zt_==s.zt_
|
---|
| 171 | && rep_.tt_==s.tt_
|
---|
| 172 | );
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | inline bool
|
---|
| 176 | HepBoost::operator != (const HepBoost & r) const {
|
---|
| 177 | return ( !(operator==(r)) );
|
---|
| 178 | }
|
---|
| 179 | inline bool HepBoost::operator <= ( const HepBoost & b ) const
|
---|
| 180 | { return compare(b)<= 0; }
|
---|
| 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 |
|
---|
| 188 | inline bool HepBoost::isIdentity() const {
|
---|
| 189 | return (xx() == 1.0 && xy() == 0.0 && xz() == 0.0 && xt() == 0.0
|
---|
| 190 | && yy() == 1.0 && yz() == 0.0 && yt() == 0.0
|
---|
| 191 | && zz() == 1.0 && zt() == 0.0
|
---|
| 192 | && tt() == 1.0);
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | inline double HepBoost::distance2( const HepBoost & b ) const {
|
---|
| 196 | double bgx = rep_.xt_ - b.rep_.xt_;
|
---|
| 197 | double bgy = rep_.yt_ - b.rep_.yt_;
|
---|
| 198 | double bgz = rep_.zt_ - b.rep_.zt_;
|
---|
| 199 | return bgx*bgx+bgy*bgy+bgz*bgz;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | inline double HepBoost::distance2( const HepBoostX & bx ) const {
|
---|
| 203 | double bgx = rep_.xt_ - bx.beta()*bx.gamma();
|
---|
| 204 | double bgy = rep_.yt_;
|
---|
| 205 | double bgz = rep_.zt_;
|
---|
| 206 | return bgx*bgx+bgy*bgy+bgz*bgz;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | inline double HepBoost::distance2( const HepBoostY & by ) const {
|
---|
| 210 | double bgy = rep_.xt_;
|
---|
| 211 | double bgx = rep_.yt_ - by.beta()*by.gamma();
|
---|
| 212 | double bgz = rep_.zt_;
|
---|
| 213 | return bgx*bgx+bgy*bgy+bgz*bgz;
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | inline double HepBoost::distance2( const HepBoostZ & bz ) const {
|
---|
| 217 | double bgz = rep_.xt_;
|
---|
| 218 | double bgy = rep_.yt_;
|
---|
| 219 | double bgx = rep_.zt_ - bz.beta()*bz.gamma();
|
---|
| 220 | return bgx*bgx+bgy*bgy+bgz*bgz;
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 | inline double HepBoost::howNear ( const HepBoost & b ) const {
|
---|
| 224 | return std::sqrt(distance2(b));
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | inline bool HepBoost::isNear(const HepBoost & b, double epsilon) const{
|
---|
| 228 | return (distance2(b) <= epsilon*epsilon);
|
---|
| 229 | }
|
---|
| 230 |
|
---|
| 231 | // ---------- Application:
|
---|
| 232 |
|
---|
| 233 | // - Protected method:
|
---|
| 234 | inline HepLorentzVector
|
---|
| 235 | HepBoost::vectorMultiplication(const HepLorentzVector & p) const {
|
---|
| 236 | register double x = p.x();
|
---|
| 237 | register double y = p.y();
|
---|
| 238 | register double z = p.z();
|
---|
| 239 | register double t = p.t();
|
---|
| 240 | return HepLorentzVector( rep_.xx_*x + rep_.xy_*y + rep_.xz_*z + rep_.xt_*t,
|
---|
| 241 | rep_.xy_*x + rep_.yy_*y + rep_.yz_*z + rep_.yt_*t,
|
---|
| 242 | rep_.xz_*x + rep_.yz_*y + rep_.zz_*z + rep_.zt_*t,
|
---|
| 243 | rep_.xt_*x + rep_.yt_*y + rep_.zt_*z + rep_.tt_*t);
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | inline HepLorentzVector
|
---|
| 247 | HepBoost::operator () (const HepLorentzVector & p) const {
|
---|
| 248 | return vectorMultiplication(p);
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | inline HepLorentzVector
|
---|
| 252 | HepBoost::operator * (const HepLorentzVector & p) const {
|
---|
| 253 | return vectorMultiplication(p);
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 |
|
---|
| 257 | // ---------- Operations in the group of 4-Rotations
|
---|
| 258 |
|
---|
| 259 | inline HepBoost HepBoost::inverse() const {
|
---|
| 260 | return HepBoost( xx(), yx(), zx(), -tx(),
|
---|
| 261 | yy(), zy(), -ty(),
|
---|
| 262 | zz(), -tz(),
|
---|
| 263 | tt());
|
---|
| 264 | }
|
---|
| 265 |
|
---|
| 266 | inline HepBoost inverseOf ( const HepBoost & lt ) {
|
---|
| 267 | return HepBoost( lt.xx(), lt.yx(), lt.zx(), -lt.tx(),
|
---|
| 268 | lt.yy(), lt.zy(), -lt.ty(),
|
---|
| 269 | lt.zz(), -lt.tz(),
|
---|
| 270 | lt.tt());
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | inline HepBoost & HepBoost::invert() {
|
---|
| 274 | rep_.xt_ = -rep_.xt_;
|
---|
| 275 | rep_.yt_ = -rep_.yt_;
|
---|
| 276 | rep_.zt_ = -rep_.zt_;
|
---|
| 277 | return *this;
|
---|
| 278 | }
|
---|
| 279 |
|
---|
| 280 | // ---------- Tolerance:
|
---|
| 281 |
|
---|
| 282 | inline double HepBoost::getTolerance() {
|
---|
| 283 | return Hep4RotationInterface::tolerance;
|
---|
| 284 | }
|
---|
| 285 | inline double HepBoost::setTolerance(double tol) {
|
---|
| 286 | return Hep4RotationInterface::setTolerance(tol);
|
---|
| 287 | }
|
---|
| 288 |
|
---|
| 289 | } // namespace CLHEP
|
---|