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

LorentzVectorB.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: LorentzVectorB.cc,v 1.2 2003/08/13 20:00:14 garren Exp $
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 
17 #include "CLHEP/Vector/defs.h"
18 #include "CLHEP/Vector/LorentzVector.h"
19 #include "CLHEP/Vector/ZMxpv.h"
20 
21 namespace CLHEP {
22 
23 //-*********
24 // rotationOf()
25 //-*********
26 
27 // Each of these is a shell over a rotate method.
28 
29 HepLorentzVector rotationXOf
30  (const HepLorentzVector & vec, double phi){
31  HepLorentzVector vv (vec);
32  return vv.rotateX (phi);
33 }
34 
35 HepLorentzVector rotationYOf
36  (const HepLorentzVector & vec, double phi){
37  HepLorentzVector vv (vec);
38  return vv.rotateY (phi);
39 }
40 
41 HepLorentzVector rotationZOf
42  (const HepLorentzVector & vec, double phi){
43  HepLorentzVector vv (vec);
44  return vv.rotateZ (phi);
45 }
46 
47 //-********
48 // boost
49 //-********
50 
51 HepLorentzVector & HepLorentzVector::boost
52  ( const Hep3Vector & aaxis, double bbeta ) {
53  if (bbeta==0) {
54  return *this; // do nothing for a 0 boost
55  }
56  double r2 = aaxis.mag2();
57  if ( r2 == 0 ) {
58  ZMthrowA (ZMxpvZeroVector(
59  "A zero vector used as axis defining a boost -- no boost done"));
60  return *this;
61  }
62  double b2 = bbeta*bbeta;
63  if (b2 >= 1) {
64  ZMthrowA (ZMxpvTachyonic(
65  "LorentzVector boosted with beta >= 1 (speed of light) -- \n"
66  "no boost done"));
67  } else {
68  Hep3Vector u = aaxis.unit();
69  register double ggamma = std::sqrt(1./(1.-b2));
70  register double betaDotV = u.dot(pp)*bbeta;
71  register double tt = ee;
72 
73  ee = ggamma * (tt + betaDotV);
74  pp += ( ((ggamma-1)/b2)*betaDotV*bbeta + ggamma*bbeta*tt ) * u;
75  // Note: I have verified the behavior of this even when beta is very
76  // small -- (gamma-1)/b2 becomes inaccurate by O(1), but it is then
77  // multiplied by O(beta**2) and added to an O(beta) term, so the
78  // inaccuracy does not affect the final result.
79  }
80  return *this;
81 } /* boost (axis, beta) */
82 
83 } // namespace CLHEP
HepLorentzVector & rotateX(double)
double dot(const Hep3Vector &) const
HepLorentzVector rotationXOf(const HepLorentzVector &vec, double delta)
HepLorentzVector rotationYOf(const HepLorentzVector &vec, double delta)
HepLorentzVector & rotateY(double)
double mag2() const
HepLorentzVector rotationZOf(const HepLorentzVector &vec, double delta)
#define ZMthrowA(A)
Hep3Vector unit() const
HepLorentzVector & rotateZ(double)
HepLorentzVector & boost(double, double, double)