CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
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
9#include "CLHEP/Vector/defs.h"
10#include "CLHEP/Vector/BoostZ.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// ---------- Constructors and Assignment:
22
23HepBoostZ & HepBoostZ::set (double bbeta) {
24 double b2 = bbeta*bbeta;
25 if (b2 >= 1) {
26 ZMthrowA (ZMxpvTachyonic(
27 "Beta supplied to set HepBoostZ represents speed >= c."));
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( 1, 0, 0, 0,
42 0, 1, 0, 0,
43 0, 0, gamma_, bg,
44 0, 0, bg, gamma_ );
45}
46
48 double bg = beta_*gamma_;
49 return HepRep4x4Symmetric( 1, 0, 0, 0,
50 1, 0, 0,
51 gamma_, bg,
52 gamma_ );
53}
54
55// ---------- Decomposition:
56
57void HepBoostZ::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 HepBoostZ::decompose (HepAxisAngle & rotation, Hep3Vector & boost) const {
65 rotation = HepAxisAngle();
66 boost = boostVector();
67}
68
69void HepBoostZ::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 HepBoostZ::decompose (Hep3Vector & boost, HepAxisAngle & rotation) const {
77 rotation = HepAxisAngle();
78 boost = boostVector();
79}
80
81// ---------- Comparisons:
82
83double HepBoostZ::distance2( const HepBoost & b ) const {
84 return b.distance2(*this);
85}
86
87double HepBoostZ::distance2( const HepRotation & r ) const {
88 double db2 = norm2();
89 double dr2 = r.norm2();
90 return (db2 + dr2);
91}
92
93double HepBoostZ::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 HepBoostZ::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 BoostZ 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 HepBoostZ ( (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 & HepBoostZ::print( std::ostream & os ) const {
158 os << "Boost in Z direction (beta = " << beta_
159 << ", gamma = " << gamma_ << ") ";
160 return os;
161}
162
163} // namespace CLHEP
#define ZMthrowA(A)
Definition: ZMxpv.h:128
HepBoostZ & set(double beta)
Definition: BoostZ.cc:23
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:157
HepRep4x4 rep4x4() const
Definition: BoostZ.cc:39
HepRep4x4Symmetric rep4x4Symmetric() const
Definition: BoostZ.cc:47
double distance2(const HepBoostZ &b) const
double beta_
Definition: BoostZ.h:207
double gamma_
Definition: BoostZ.h:208
void rectify()
Definition: BoostZ.cc:122
void decompose(HepRotation &rotation, HepBoost &boost) const
Definition: BoostZ.cc:57
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:48