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