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
vv
std::vector< SpaceVector > vv
Definition: keyMergeIssues.doc:334
CLHEP::rotationYOf
HepLorentzVector rotationYOf(const HepLorentzVector &vec, double delta)
Definition: LorentzVectorB.cc:36
CLHEP::Hep3Vector::unit
Hep3Vector unit() const
CLHEP::Hep3Vector::dot
double dot(const Hep3Vector &) const
ee
Signatures of Hep3Vector::rotate For equivalent ZOOM axis There is no harm in leaving this axis CLHEP has implemented a first forming an identity then rotating that by axis and I leave the CLHEP code alone people are of course free to use the ZOOM originated method with signature which I believe will be faster Return types for rotateZ CLHEP and PhysicsVectors each have these three and they are identical except that the ZOOM version returns a reference to while in CLHEP they return void Having methods that alter an object return a reference to that object is convenient for certain chained and costs nothing I don t wish to potentially break ZOOM user code for no good so I have made these CLHEP method conform to this convention There are a couple of other CLHEP rotate and which use the void return but since these methods or signatures don t appear in the original ZOOM this can t break any so I leave the void return type alone for those After discussion with A P and I have modified the return types of other CLHEP methods which return void and would by the same reasoning be better returning *this These include rotate and boost methods in LorentzVector h HepLorentzVector explicit and leads to division by zero if this vector has ee
Definition: minorMergeIssues.doc:140
CLHEP
Definition: ClhepVersion.h:13
CLHEP::Hep3Vector::mag2
double mag2() const
CLHEP::Hep3Vector
Definition: Geometry/CLHEP/Vector/ThreeVector.h:41
phi
we want to make it possible for the user to use the so we provide a few new for double double phi
Definition: minorMergeIssues.doc:20
CLHEP::HepLorentzVector::boost
HepLorentzVector & boost(double, double, double)
Definition: LorentzVector.cc:57
CLHEP::rotationXOf
HepLorentzVector rotationXOf(const HepLorentzVector &vec, double delta)
Definition: LorentzVectorB.cc:30
CLHEP::HepLorentzVector
Definition: Geometry/CLHEP/Vector/LorentzVector.h:72
ZMthrowA
it has advantages For I leave the ZMthrows but substitute I replaced ZMthrow with ZMthrowA in this package ZMthrowA
Definition: keyMergeIssues.doc:69
CLHEP::rotationZOf
HepLorentzVector rotationZOf(const HepLorentzVector &vec, double delta)
Definition: LorentzVectorB.cc:42