source: trunk/CLHEP/Vector/BoostX.icc@ 21

Last change on this file since 21 was 4, checked in by Pavel Demin, 16 years ago

first commit

File size: 5.4 KB
Line 
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// HepBoostX class
8//
9
10#include <cmath>
11
12namespace CLHEP {
13
14// ---------- Constructors and Assignment:
15
16inline HepBoostX::HepBoostX() : beta_(0.0), gamma_(1.0) {}
17
18inline HepBoostX::HepBoostX(const HepBoostX & b) :
19 beta_ (b.beta_),
20 gamma_(b.gamma_) {}
21
22inline HepBoostX & HepBoostX::operator = (const HepBoostX & b) {
23 beta_ = b.beta_;
24 gamma_ = b.gamma_;
25 return *this;
26}
27
28inline HepBoostX::HepBoostX(double beta) { set(beta); }
29
30// - Protected method:
31inline HepBoostX::HepBoostX( double beta, double gamma ) :
32 beta_(beta), gamma_(gamma) {}
33
34// ---------- Accessors:
35
36inline double HepBoostX::beta() const {
37 return beta_;
38}
39
40inline double HepBoostX::gamma() const {
41 return gamma_;
42}
43
44inline Hep3Vector HepBoostX::boostVector() const {
45 return Hep3Vector( beta_, 0, 0 );
46}
47
48inline Hep3Vector HepBoostX::getDirection() const {
49 return Hep3Vector(1.0, 0.0, 0.0);
50}
51
52inline double HepBoostX::xx() const { return gamma();}
53inline double HepBoostX::xy() const { return 0.0;}
54inline double HepBoostX::xz() const { return 0.0;}
55inline double HepBoostX::xt() const { return beta()*gamma();}
56inline double HepBoostX::yx() const { return 0.0;}
57inline double HepBoostX::yy() const { return 1.0;}
58inline double HepBoostX::yz() const { return 0.0;}
59inline double HepBoostX::yt() const { return 0.0;}
60inline double HepBoostX::zx() const { return 0.0;}
61inline double HepBoostX::zy() const { return 0.0;}
62inline double HepBoostX::zz() const { return 1.0;}
63inline double HepBoostX::zt() const { return 0.0;}
64inline double HepBoostX::tx() const { return beta()*gamma();}
65inline double HepBoostX::ty() const { return 0.0;}
66inline double HepBoostX::tz() const { return 0.0;}
67inline double HepBoostX::tt() const { return gamma();}
68
69inline HepLorentzVector HepBoostX::col1() const {
70 return HepLorentzVector ( gamma(), 0, 0, beta()*gamma() );
71}
72inline HepLorentzVector HepBoostX::col2() const {
73 return HepLorentzVector ( 0, 1, 0, 0 );
74}
75inline HepLorentzVector HepBoostX::col3() const {
76 return HepLorentzVector ( 0, 0, 1, 0 );
77}
78inline HepLorentzVector HepBoostX::col4() const {
79 return HepLorentzVector ( beta()*gamma(), 0, 0, gamma() );
80}
81
82inline HepLorentzVector HepBoostX::row1() const {
83 return HepLorentzVector ( col1() );
84}
85inline HepLorentzVector HepBoostX::row2() const {
86 return HepLorentzVector ( col2() );
87}
88inline HepLorentzVector HepBoostX::row3() const {
89 return HepLorentzVector ( col3() );
90}
91inline HepLorentzVector HepBoostX::row4() const {
92 return HepLorentzVector ( col4() );
93}
94
95// ---------- Comparisons:
96
97inline int HepBoostX::compare( const HepBoostX & b ) const {
98 if (beta() < b.beta()) {
99 return -1;
100 } else if (beta() > b.beta()) {
101 return 1;
102 } else {
103 return 0;
104 }
105}
106
107inline bool HepBoostX::operator == ( const HepBoostX & b ) const {
108 return beta_ == b.beta_;
109}
110inline bool HepBoostX::operator != ( const HepBoostX & b ) const {
111 return beta_ != b.beta_;
112}
113inline bool HepBoostX::operator <= ( const HepBoostX & b ) const {
114 return beta_ <= b.beta_;
115}
116inline bool HepBoostX::operator >= ( const HepBoostX & b ) const {
117 return beta_ >= b.beta_;
118}
119inline bool HepBoostX::operator < ( const HepBoostX & b ) const {
120 return beta_ < b.beta_;
121}
122inline bool HepBoostX::operator > ( const HepBoostX & b ) const {
123 return beta_ > b.beta_;
124}
125
126inline bool HepBoostX::isIdentity() const {
127 return ( beta() == 0 );
128}
129
130inline double HepBoostX::distance2( const HepBoostX & b ) const {
131 double d = beta()*gamma() - b.beta()*b.gamma();
132 return d*d;
133}
134
135inline double HepBoostX::howNear(const HepBoostX & b) const {
136 return std::sqrt(distance2(b)); }
137inline double HepBoostX::howNear(const HepBoost & b) const {
138 return std::sqrt(distance2(b)); }
139inline double HepBoostX::howNear(const HepRotation & r) const {
140 return std::sqrt(distance2(r)); }
141inline double HepBoostX::howNear(const HepLorentzRotation & lt) const {
142 return std::sqrt(distance2(lt)); }
143
144inline bool HepBoostX::isNear(const HepBoostX & b,
145 double epsilon) const {
146 return (distance2(b) <= epsilon*epsilon);
147}
148inline bool HepBoostX::isNear(const HepBoost & b,
149 double epsilon) const {
150 return (distance2(b) <= epsilon*epsilon);
151}
152
153// ---------- Properties:
154
155inline double HepBoostX::norm2() const {
156 register double bg = beta_*gamma_;
157 return bg*bg;
158}
159
160// ---------- Application:
161
162inline HepLorentzVector
163HepBoostX::operator * (const HepLorentzVector & p) const {
164 double bg = beta_*gamma_;
165 return HepLorentzVector(gamma_*p.x() + bg*p.t(),
166 p.y(),
167 p.z(),
168 gamma_*p.t() + bg*p.x());
169}
170
171inline HepLorentzVector
172HepBoostX::operator() (const HepLorentzVector & w) const {
173 return operator*(w);
174}
175
176// ---------- Operations in the group of 4-Rotations
177
178inline HepBoostX HepBoostX::inverse() const {
179 return HepBoostX( -beta(), gamma() );
180}
181
182inline HepBoostX inverseOf ( const HepBoostX & b ) {
183 return HepBoostX( -b.beta(), b.gamma());
184}
185
186inline HepBoostX & HepBoostX::invert() {
187 beta_ = -beta_;
188 return *this;
189}
190
191// ---------- Tolerance:
192
193inline double HepBoostX::getTolerance() {
194 return Hep4RotationInterface::tolerance;
195}
196inline double HepBoostX::setTolerance(double tol) {
197 return Hep4RotationInterface::setTolerance(tol);
198}
199
200} // namespace CLHEP
Note: See TracBrowser for help on using the repository browser.