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