Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
LorentzVectorB.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id:$
3// ---------------------------------------------------------------------------
4//
5// This file is a part of the CLHEP - a Class Library for High Energy Physics.
6//
7// This is the implementation of the HepLorentzVector class:
8// Those methods originating in ZOOM dealing with simple boosts and rotations.
9// Use of one of these methods will not force loading of the HepRotation or
10// HepLorentzRotation class.
11//
12
13#ifdef GNUPRAGMA
14#pragma implementation
15#endif
16
18
19namespace CLHEP {
20
21//-*********
22// rotationOf()
23//-*********
24
25// Each of these is a shell over a rotate method.
26
28 (const HepLorentzVector & vec, double phi){
29 HepLorentzVector vv (vec);
30 return vv.rotateX (phi);
31}
32
34 (const HepLorentzVector & vec, double phi){
35 HepLorentzVector vv (vec);
36 return vv.rotateY (phi);
37}
38
40 (const HepLorentzVector & vec, double phi){
41 HepLorentzVector vv (vec);
42 return vv.rotateZ (phi);
43}
44
45//-********
46// boost
47//-********
48
50 ( const Hep3Vector & aaxis, double bbeta ) {
51 if (bbeta==0) {
52 return *this; // do nothing for a 0 boost
53 }
54 double r2 = aaxis.mag2();
55 if ( r2 == 0 ) {
56 std::cerr << "HepLorentzVector::boost() - "
57 << "A zero vector used as axis defining a boost -- no boost done"
58 << std::endl;
59 return *this;
60 }
61 double b2 = bbeta*bbeta;
62 if (b2 >= 1) {
63 std::cerr << "HepLorentzVector::boost() - "
64 << "LorentzVector boosted with beta >= 1 (speed of light) -- \n"
65 << "no boost done" << std::endl;
66 } else {
67 Hep3Vector u = aaxis.unit();
68 register double ggamma = std::sqrt(1./(1.-b2));
69 register double betaDotV = u.dot(pp)*bbeta;
70 register double tt = ee;
71
72 ee = ggamma * (tt + betaDotV);
73 pp += ( ((ggamma-1)/b2)*betaDotV*bbeta + ggamma*bbeta*tt ) * u;
74 // Note: I have verified the behavior of this even when beta is very
75 // small -- (gamma-1)/b2 becomes inaccurate by O(1), but it is then
76 // multiplied by O(beta**2) and added to an O(beta) term, so the
77 // inaccuracy does not affect the final result.
78 }
79 return *this;
80} /* boost (axis, beta) */
81
82} // namespace CLHEP
Hep3Vector unit() const
double mag2() const
double dot(const Hep3Vector &) const
HepLorentzVector & boost(double, double, double)
HepLorentzVector & rotateZ(double)
HepLorentzVector & rotateX(double)
HepLorentzVector & rotateY(double)
Definition: DoubConv.h:17
HepLorentzVector rotationYOf(const HepLorentzVector &vec, double delta)
HepLorentzVector rotationXOf(const HepLorentzVector &vec, double delta)
HepLorentzVector rotationZOf(const HepLorentzVector &vec, double delta)