13 #pragma implementation
16 #include "CLHEP/Vector/LorentzVector.h"
23 Hep3Vector::ToleranceTicks * 2.22045e-16;
24 double HepLorentzVector::metric = 1.0;
26 double HepLorentzVector::operator () (
int i)
const {
35 std::cerr <<
"HepLorentzVector subscripting: bad index (" << i <<
")"
41 double & HepLorentzVector::operator () (
int i) {
52 <<
"HepLorentzVector subscripting: bad index (" << i <<
")"
58 HepLorentzVector & HepLorentzVector::boost
59 (
double bx,
double by,
double bz){
60 double b2 = bx*bx + by*by + bz*bz;
61 double ggamma = 1.0 / std::sqrt(1.0 - b2);
62 double bp = bx*
x() + by*y() + bz*
z();
63 double gamma2 = b2 > 0 ? (ggamma - 1.0)/
b2 : 0.0;
65 setX(
x() + gamma2*
bp*bx + ggamma*bx*t());
66 setY(y() + gamma2*
bp*by + ggamma*by*t());
67 setZ(
z() + gamma2*
bp*bz + ggamma*bz*t());
68 setT(ggamma*(t() +
bp));
72 HepLorentzVector & HepLorentzVector::rotateX(
double a) {
76 HepLorentzVector & HepLorentzVector::rotateY(
double a) {
80 HepLorentzVector & HepLorentzVector::rotateZ(
double a) {
85 HepLorentzVector & HepLorentzVector::rotateUz(
const Hep3Vector &v1) {
90 std::ostream &
operator<< (std::ostream & os,
const HepLorentzVector & v1)
92 return os <<
"(" << v1.x() <<
"," << v1.y() <<
"," << v1.z()
93 <<
";" << v1.t() <<
")";
96 std::istream &
operator>> (std::istream & is, HepLorentzVector & v1) {
109 if (is.fail() || c !=
'(' ) {
110 std::cerr <<
"Could not find required opening parenthesis "
111 <<
"in input of a HepLorentzVector" << std::endl;
115 is >> x >> std::ws >> c;
116 if (is.fail() || c !=
',' ) {
117 std::cerr <<
"Could not find x value and required trailing comma "
118 <<
"in input of a HepLorentzVector" << std::endl;
122 is >> y >> std::ws >> c;
123 if (is.fail() || c !=
',' ) {
124 std::cerr <<
"Could not find y value and required trailing comma "
125 <<
"in input of a HepLorentzVector" << std::endl;
129 is >> z >> std::ws >> c;
130 if (is.fail() || c !=
';' ) {
131 std::cerr <<
"Could not find z value and required trailing semicolon "
132 <<
"in input of a HepLorentzVector" << std::endl;
136 is >> t >> std::ws >> c;
137 if (is.fail() || c !=
')' ) {
138 std::cerr <<
"Could not find t value and required close parenthesis "
139 <<
"in input of a HepLorentzVector" << std::endl;
152 HepLorentzVector & HepLorentzVector::operator /= (
double c) {
159 double oneOverC = 1.0/c;
165 HepLorentzVector
operator / (
const HepLorentzVector &
w,
double c) {
172 double oneOverC = 1.0/c;
173 return HepLorentzVector (w.getV() * oneOverC,
174 w.getT() * oneOverC);
177 Hep3Vector HepLorentzVector::boostVector()
const {
179 if (
pp.mag2() == 0) {
180 return Hep3Vector(0,0,0);
182 std::cerr <<
"HepLorentzVector::boostVector() - "
183 <<
"boostVector computed for LorentzVector with t=0 -- infinite result"
188 if (restMass2() <= 0) {
189 std::cerr <<
"HepLorentzVector::boostVector() - "
190 <<
"boostVector computed for a non-timelike LorentzVector " << std::endl;
197 HepLorentzVector & HepLorentzVector::boostX (
double bbeta){
198 double b2 = bbeta*bbeta;
200 std::cerr <<
"HepLorentzVector::boostX() - "
201 <<
"boost along X with beta >= 1 (speed of light) -- \n"
202 <<
"no boost done" << std::endl;
204 double ggamma = std::sqrt(1./(1-b2));
206 ee = ggamma*(ee + bbeta*
pp.getX());
207 pp.setX(ggamma*(
pp.getX() + bbeta*tt));
212 HepLorentzVector & HepLorentzVector::boostY (
double bbeta){
213 double b2 = bbeta*bbeta;
215 std::cerr <<
"HepLorentzVector::boostY() - "
216 <<
"boost along Y with beta >= 1 (speed of light) -- \n"
217 <<
"no boost done" << std::endl;
219 double ggamma = std::sqrt(1./(1-b2));
221 ee = ggamma*(ee + bbeta*
pp.getY());
222 pp.setY(ggamma*(
pp.getY() + bbeta*tt));
227 HepLorentzVector & HepLorentzVector::boostZ (
double bbeta){
228 double b2 = bbeta*bbeta;
230 std::cerr <<
"HepLorentzVector::boostZ() - "
231 <<
"boost along Z with beta >= 1 (speed of light) -- \n"
232 <<
"no boost done" << std::endl;
234 double ggamma = std::sqrt(1./(1-b2));
236 ee = ggamma*(ee + bbeta*
pp.getZ());
237 pp.setZ(ggamma*(
pp.getZ() + bbeta*tt));
242 double HepLorentzVector::setTolerance (
double tol ) {
249 double HepLorentzVector::getTolerance ( ) {
HepLorentzVector operator/(const HepLorentzVector &w, double c)
static const G4float tolerance
const G4double w[NPOINTSGL]
std::istream & operator>>(std::istream &is, HepAxisAngle &aa)
std::ostream & operator<<(std::ostream &os, const HepAxisAngle &aa)
const G4double x[NPOINTSGL]