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