CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

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