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