source: trunk/CLHEP/src/LorentzVectorB.cc@ 16

Last change on this file since 16 was 4, checked in by Pavel Demin, 16 years ago

first commit

File size: 2.3 KB
Line 
1// -*- C++ -*-
2// $Id: LorentzVectorB.cc,v 1.1 2008-06-04 14:15:06 demin 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
21namespace CLHEP {
22
23//-*********
24// rotationOf()
25//-*********
26
27// Each of these is a shell over a rotate method.
28
29HepLorentzVector rotationXOf
30 (const HepLorentzVector & vec, double phi){
31 HepLorentzVector vv (vec);
32 return vv.rotateX (phi);
33}
34
35HepLorentzVector rotationYOf
36 (const HepLorentzVector & vec, double phi){
37 HepLorentzVector vv (vec);
38 return vv.rotateY (phi);
39}
40
41HepLorentzVector rotationZOf
42 (const HepLorentzVector & vec, double phi){
43 HepLorentzVector vv (vec);
44 return vv.rotateZ (phi);
45}
46
47//-********
48// boost
49//-********
50
51HepLorentzVector & HepLorentzVector::boost
52 ( const Hep3Vector & axis, double beta ) {
53 if (beta==0) {
54 return *this; // do nothing for a 0 boost
55 }
56 double r2 = axis.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 = beta*beta;
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 = axis.unit();
69 register double gamma = sqrt(1./(1.-b2));
70 register double betaDotV = u.dot(pp)*beta;
71 register double tt = ee;
72
73 ee = gamma * (tt + betaDotV);
74 pp += ( ((gamma-1)/b2)*betaDotV*beta + gamma*beta*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
Note: See TracBrowser for help on using the repository browser.