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