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