Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
BoostX.cc
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 implementation of the HepBoostX class.
7//
8
9#ifdef GNUPRAGMA
10#pragma implementation
11#endif
12
13#include "CLHEP/Vector/BoostX.h"
14#include "CLHEP/Vector/Boost.h"
17
18namespace CLHEP {
19
20
21// ---------- Constructors and Assignment:
22
23HepBoostX & HepBoostX::set (double bbeta) {
24 double b2 = bbeta*bbeta;
25 if (b2 >= 1) {
26 std::cerr << "HepBoostX::set() - "
27 << "Beta supplied to set HepBoostX represents speed >= c." << std::endl;
28 beta_ = 1.0 - 1.0E-8; // NaN-proofing
29 gamma_ = 1.0 / std::sqrt(1.0 - b2);
30 return *this;
31 }
32 beta_ = bbeta;
33 gamma_ = 1.0 / std::sqrt(1.0 - b2);
34 return *this;
35}
36
37// ---------- Accessors:
38
40 double bg = beta_*gamma_;
41 return HepRep4x4( gamma_, 0, 0, bg,
42 0, 1, 0, 0,
43 0, 0, 1, 0,
44 bg, 0, 0, gamma_ );
45}
46
48 double bg = beta_*gamma_;
49 return HepRep4x4Symmetric( gamma_, 0, 0, bg,
50 1, 0, 0,
51 1, 0,
52 gamma_ );
53}
54
55// ---------- Decomposition:
56
57void HepBoostX::decompose (HepRotation & rotation, HepBoost & boost) const {
58 HepAxisAngle vdelta = HepAxisAngle();
59 rotation = HepRotation(vdelta);
60 Hep3Vector bbeta = boostVector();
61 boost = HepBoost(bbeta);
62}
63
64void HepBoostX::decompose (HepAxisAngle & rotation, Hep3Vector & boost) const {
65 rotation = HepAxisAngle();
66 boost = boostVector();
67}
68
69void HepBoostX::decompose (HepBoost & boost, HepRotation & rotation) const {
70 HepAxisAngle vdelta = HepAxisAngle();
71 rotation = HepRotation(vdelta);
72 Hep3Vector bbeta = boostVector();
73 boost = HepBoost(bbeta);
74}
75
76void HepBoostX::decompose (Hep3Vector & boost, HepAxisAngle & rotation) const {
77 rotation = HepAxisAngle();
78 boost = boostVector();
79}
80
81// ---------- Comparisons:
82
83double HepBoostX::distance2( const HepBoost & b ) const {
84 return b.distance2(*this);
85}
86
87double HepBoostX::distance2( const HepRotation & r ) const {
88 double db2 = norm2();
89 double dr2 = r.norm2();
90 return (db2 + dr2);
91}
92
93double HepBoostX::distance2( const HepLorentzRotation & lt ) const {
94 HepBoost b1;
95 HepRotation r1;
96 lt.decompose(b1,r1);
97 double db2 = distance2(b1);
98 double dr2 = r1.norm2();
99 return (db2 + dr2);
100}
101
102bool HepBoostX::isNear (const HepRotation & r, double epsilon) const {
103 double db2 = norm2();
104 if (db2 > epsilon*epsilon) return false;
105 double dr2 = r.norm2();
106 return (db2+dr2 <= epsilon*epsilon);
107}
108
110 double epsilon) const {
111 HepBoost b1;
112 HepRotation r1;
113 double db2 = distance2(b1);
114 lt.decompose(b1,r1);
115 if (db2 > epsilon*epsilon) return false;
116 double dr2 = r1.norm2();
117 return (db2 + dr2);
118}
119
120// ---------- Properties:
121
123 // Assuming the representation of this is close to a true pure boost,
124 // but may have drifted due to round-off error from many operations,
125 // this forms an "exact" pure boostX matrix for again.
126
127 double b2 = beta_*beta_;
128 if (b2 >= 1) {
129 beta_ = 1.0 - 1.0e-8; // NaN-proofing
130 b2 = beta_*beta_;
131 }
132 gamma_ = 1.0 / std::sqrt(1.0 - b2);
133}
134
135// ---------- Application:
136
137// ---------- Operations in the group of 4-Rotations
138
140 return HepBoostX ( (beta()+b.beta()) / (1+beta()*b.beta()) );
141}
143 HepLorentzRotation me (*this);
144 return me*b;
145}
147 HepLorentzRotation me (*this);
148 return me*r;
149}
151 HepLorentzRotation me (*this);
152 return me*lt;
153}
154
155// ---------- I/O:
156
157std::ostream & HepBoostX::print( std::ostream & os ) const {
158 os << "Boost in X direction (beta = " << beta_
159 << ", gamma = " << gamma_ << ") ";
160 return os;
161}
162
163} // namespace CLHEP
double distance2(const HepBoostX &b) const
double beta() const
HepLorentzVector operator*(const HepLorentzVector &w) const
HepRep4x4 rep4x4() const
Definition: BoostX.cc:39
double norm2() const
double beta_
Definition: BoostX.h:208
HepBoostX & set(double beta)
Definition: BoostX.cc:23
bool isNear(const HepBoostX &b, double epsilon=Hep4RotationInterface::tolerance) const
Hep3Vector boostVector() const
std::ostream & print(std::ostream &os) const
Definition: BoostX.cc:157
void decompose(HepRotation &rotation, HepBoost &boost) const
Definition: BoostX.cc:57
HepRep4x4Symmetric rep4x4Symmetric() const
Definition: BoostX.cc:47
double gamma_
Definition: BoostX.h:209
void rectify()
Definition: BoostX.cc:122
double distance2(const HepBoost &b) const
void decompose(Hep3Vector &boost, HepAxisAngle &rotation) const
double norm2() const
Definition: RotationP.cc:50
Definition: DoubConv.h:17