ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LorentzVectorB.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LorentzVectorB.cc
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 HepLorentzVector class:
7 // Those methods originating in ZOOM dealing with simple boosts and rotations.
8 // Use of one of these methods will not force loading of the HepRotation or
9 // HepLorentzRotation class.
10 //
11 
12 #ifdef GNUPRAGMA
13 #pragma implementation
14 #endif
15 
17 
18 namespace CLHEP {
19 
20 //-*********
21 // rotationOf()
22 //-*********
23 
24 // Each of these is a shell over a rotate method.
25 
26 HepLorentzVector rotationXOf
27  (const HepLorentzVector & vec, double phi){
28  HepLorentzVector vv (vec);
29  return vv.rotateX (phi);
30 }
31 
32 HepLorentzVector rotationYOf
33  (const HepLorentzVector & vec, double phi){
34  HepLorentzVector vv (vec);
35  return vv.rotateY (phi);
36 }
37 
38 HepLorentzVector rotationZOf
39  (const HepLorentzVector & vec, double phi){
40  HepLorentzVector vv (vec);
41  return vv.rotateZ (phi);
42 }
43 
44 //-********
45 // boost
46 //-********
47 
48 HepLorentzVector & HepLorentzVector::boost
49  ( const Hep3Vector & aaxis, double bbeta ) {
50  if (bbeta==0) {
51  return *this; // do nothing for a 0 boost
52  }
53  double r2 = aaxis.mag2();
54  if ( r2 == 0 ) {
55  std::cerr << "HepLorentzVector::boost() - "
56  << "A zero vector used as axis defining a boost -- no boost done"
57  << std::endl;
58  return *this;
59  }
60  double b2 = bbeta*bbeta;
61  if (b2 >= 1) {
62  std::cerr << "HepLorentzVector::boost() - "
63  << "LorentzVector boosted with beta >= 1 (speed of light) -- \n"
64  << "no boost done" << std::endl;
65  } else {
66  Hep3Vector u = aaxis.unit();
67  double ggamma = std::sqrt(1./(1.-b2));
68  double betaDotV = u.dot(pp)*bbeta;
69  double tt = ee;
70 
71  ee = ggamma * (tt + betaDotV);
72  pp += ( ((ggamma-1)/b2)*betaDotV*bbeta + ggamma*bbeta*tt ) * u;
73  // Note: I have verified the behavior of this even when beta is very
74  // small -- (gamma-1)/b2 becomes inaccurate by O(1), but it is then
75  // multiplied by O(beta**2) and added to an O(beta) term, so the
76  // inaccuracy does not affect the final result.
77  }
78  return *this;
79 } /* boost (axis, beta) */
80 
81 } // namespace CLHEP