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:
16inline HepBoost::HepBoost() : rep_() {}
18inline HepBoost::HepBoost(const HepBoost & m1) : rep_(m1.rep_) {}
20inline HepBoost & HepBoost::operator = (const HepBoost & m1) {
25inline HepBoost::HepBoost(double betaX, double betaY, double betaZ)
27 set(betaX, betaY, betaZ);
30inline HepBoost::HepBoost(const HepRep4x4Symmetric & m1) : rep_(m1) {}
32inline 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);
46inline HepBoost::HepBoost(const Hep3Vector & boost)
48 set(boost.x(), boost.y(), boost.z());
51inline HepBoost::HepBoost(const HepBoostX & boost) {set(boost.boostVector());}
52inline HepBoost::HepBoost(const HepBoostY & boost) {set(boost.boostVector());}
53inline HepBoost::HepBoost(const HepBoostZ & boost) {set(boost.boostVector());}
54inline HepBoost & HepBoost::set(const HepBoostX & boost)
55 {return set(boost.boostVector());}
56inline HepBoost & HepBoost::set(const HepBoostY & boost)
57 {return set(boost.boostVector());}
58inline HepBoost & HepBoost::set(const HepBoostZ & boost)
59 {return set(boost.boostVector());}
62inline 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:
71inline double HepBoost::beta() const {
72 return std::sqrt( 1.0 - 1.0 / (rep_.tt_ * rep_.tt_) );
75inline double HepBoost::gamma() const {
79inline Hep3Vector HepBoost::boostVector() const {
80 return (1.0/rep_.tt_) * Hep3Vector( rep_.xt_, rep_.yt_, rep_.zt_ );
83inline Hep3Vector HepBoost::getDirection() const {
84 double norm = 1.0/beta();
85 return (norm*boostVector());
88inline Hep3Vector HepBoost::direction() const {
89 return getDirection();
92inline double HepBoost::xx() const { return rep_.xx_; }
93inline double HepBoost::xy() const { return rep_.xy_; }
94inline double HepBoost::xz() const { return rep_.xz_; }
95inline double HepBoost::xt() const { return rep_.xt_; }
96inline double HepBoost::yx() const { return rep_.xy_; }
97inline double HepBoost::yy() const { return rep_.yy_; }
98inline double HepBoost::yz() const { return rep_.yz_; }
99inline double HepBoost::yt() const { return rep_.yt_; }
100inline double HepBoost::zx() const { return rep_.xz_; }
101inline double HepBoost::zy() const { return rep_.yz_; }
102inline double HepBoost::zz() const { return rep_.zz_; }
103inline double HepBoost::zt() const { return rep_.zt_; }
104inline double HepBoost::tx() const { return rep_.xt_; }
105inline double HepBoost::ty() const { return rep_.yt_; }
106inline double HepBoost::tz() const { return rep_.zt_; }
107inline double HepBoost::tt() const { return rep_.tt_; }
109inline HepLorentzVector HepBoost::col1() const {
110 return HepLorentzVector ( xx(), yx(), zx(), tx() );
112inline HepLorentzVector HepBoost::col2() const {
113 return HepLorentzVector ( xy(), yy(), zy(), ty() );
115inline HepLorentzVector HepBoost::col3() const {
116 return HepLorentzVector ( xz(), yz(), zz(), tz() );
118inline HepLorentzVector HepBoost::col4() const {
119 return HepLorentzVector ( xt(), yt(), zt(), tt() );
122inline HepLorentzVector HepBoost::row1() const {
123 return HepLorentzVector ( col1() );
125inline HepLorentzVector HepBoost::row2() const {
126 return HepLorentzVector ( col2() );
128inline HepLorentzVector HepBoost::row3() const {
129 return HepLorentzVector ( col3() );
131inline HepLorentzVector HepBoost::row4() const {
132 return HepLorentzVector ( col4() );
135inline HepRep4x4 HepBoost::rep4x4() const {
136 return HepRep4x4( rep_ );
139inline HepRep4x4Symmetric HepBoost::rep4x4Symmetric() const {
144inline void HepBoost::setBoost(double bx, double by, double bz) {
149// ---------- Comparisons:
151int 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;
167HepBoost::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_
178HepBoost::operator != (const HepBoost & r) const {
179 return ( !(operator==(r)) );
181inline bool HepBoost::operator <= ( const HepBoost & b ) const
182 { return compare(b)<= 0; }
183inline bool HepBoost::operator >= ( const HepBoost & b ) const
184 { return compare(b)>= 0; }
185inline bool HepBoost::operator < ( const HepBoost & b ) const
186 { return compare(b)< 0; }
187inline bool HepBoost::operator > ( const HepBoost & b ) const
188 { return compare(b)> 0; }
190inline 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
197inline 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;
204inline 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;
211inline 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;
218inline 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;
225inline double HepBoost::howNear ( const HepBoost & b ) const {
226 return std::sqrt(distance2(b));
229inline bool HepBoost::isNear(const HepBoost & b, double epsilon) const{
230 return (distance2(b) <= epsilon*epsilon);
233// ---------- Application:
235// - Protected method:
236inline HepLorentzVector
237HepBoost::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);
248inline HepLorentzVector
249HepBoost::operator () (const HepLorentzVector & p) const {
250 return vectorMultiplication(p);
253inline HepLorentzVector
254HepBoost::operator * (const HepLorentzVector & p) const {
255 return vectorMultiplication(p);
259// ---------- Operations in the group of 4-Rotations
261inline HepBoost HepBoost::inverse() const {
262 return HepBoost( xx(), yx(), zx(), -tx(),
268inline HepBoost inverseOf ( const HepBoost & lt ) {
269 return HepBoost( lt.xx(), lt.yx(), lt.zx(), -lt.tx(),
270 lt.yy(), lt.zy(), -lt.ty(),
275inline HepBoost & HepBoost::invert() {
276 rep_.xt_ = -rep_.xt_;
277 rep_.yt_ = -rep_.yt_;
278 rep_.zt_ = -rep_.zt_;
282// ---------- Tolerance:
284inline double HepBoost::getTolerance() {
285 return Hep4RotationInterface::tolerance;
287inline double HepBoost::setTolerance(double tol) {
288 return Hep4RotationInterface::setTolerance(tol);