12 #pragma implementation
15 #include "CLHEP/Vector/LorentzVector.h"
25 ZMpvMetric_t HepLorentzVector::setMetric( ZMpvMetric_t met ) {
26 ZMpvMetric_t oldMetric = (metric > 0) ? TimePositive : TimeNegative;
27 if ( met == TimeNegative ) {
35 ZMpvMetric_t HepLorentzVector::getMetric() {
36 return ( (metric > 0) ? TimePositive : TimeNegative );
44 double HepLorentzVector::plus (
const Hep3Vector & ref)
const {
47 std::cerr <<
"HepLorentzVector::plus() - "
48 <<
"A zero vector used as reference to LorentzVector plus-part"
52 return ee +
pp.dot(ref)/r;
55 double HepLorentzVector::minus (
const Hep3Vector & ref)
const {
58 std::cerr <<
"HepLorentzVector::minus() - "
59 <<
"A zero vector used as reference to LorentzVector minus-part"
63 return ee -
pp.dot(ref)/r;
66 HepLorentzVector HepLorentzVector::rest4Vector()
const {
67 return HepLorentzVector (0, 0, 0, (t() < 0.0 ? -
m() :
m()));
75 double HepLorentzVector::beta()
const {
80 std::cerr <<
"HepLorentzVector::beta() - "
81 <<
"beta computed for HepLorentzVector with t=0 -- infinite result"
91 return std::sqrt (
pp.mag2() / (ee*ee)) ;
94 double HepLorentzVector::gamma()
const {
95 double v2 =
pp.mag2();
101 std::cerr <<
"HepLorentzVector::gamma() - "
102 <<
"gamma computed for HepLorentzVector with t=0 -- zero result"
108 std::cerr <<
"HepLorentzVector::gamma() - "
109 <<
"gamma computed for a spacelike HepLorentzVector -- imaginary result"
118 return 1./std::sqrt(1. - v2/t2 );
128 double HepLorentzVector::rapidity()
const {
129 register double z1 =
pp.getZ();
135 if (std::fabs(ee) < std::fabs(z1)) {
136 std::cerr <<
"HepLorentzVector::rapidity() - "
137 <<
"rapidity for spacelike 4-vector with |E| < |Pz| -- undefined"
141 double q = (ee + z1) / (ee - z1);
144 return .5 * std::log(q);
147 double HepLorentzVector::rapidity(
const Hep3Vector & ref)
const {
148 register double r = ref.mag2();
150 std::cerr <<
"HepLorentzVector::rapidity() - "
151 <<
"A zero vector used as reference to LorentzVector rapidity"
155 register double vdotu =
pp.dot(ref)/std::sqrt(r);
161 if (std::fabs(ee) < std::fabs(vdotu)) {
162 std::cerr <<
"HepLorentzVector::rapidity() - "
163 <<
"rapidity for spacelike 4-vector with |E| < |P*ref| -- undefined "
167 double q = (ee + vdotu) / (ee - vdotu);
168 return .5 * std::log(q);
171 double HepLorentzVector::coLinearRapidity()
const {
172 register double v1 =
pp.mag();
178 if (std::fabs(ee) < std::fabs(v1)) {
179 std::cerr <<
"HepLorentzVector::coLinearRapidity() - "
180 <<
"co-linear rapidity for spacelike 4-vector -- undefined"
184 double q = (ee + v1) / (ee - v1);
185 return .5 * std::log(q);
193 double m1 = invariantMass2(w);
196 if ( ee * w.ee < 0 ) {
197 std::cerr <<
"HepLorentzVector::invariantMass() - "
198 <<
"invariant mass meaningless: \n"
199 <<
"a negative-mass input led to spacelike 4-vector sum" << std::endl;
201 }
else if ( (isSpacelike() && !isLightlike()) ||
202 (w.isSpacelike() && !w.isLightlike()) ) {
203 std::cerr <<
"HepLorentzVector::invariantMass() - "
204 <<
"invariant mass meaningless because of spacelike input"
216 return (ee+w.ee >=0 ) ? std::sqrt(m1) : -
std::sqrt(m1);
223 Hep3Vector HepLorentzVector::findBoostToCM()
const {
224 return -boostVector();
227 Hep3Vector HepLorentzVector::findBoostToCM (
const HepLorentzVector & w)
const {
228 double t1 = ee + w.ee;
229 Hep3Vector v1 =
pp + w.pp;
231 if (v1.mag2() == 0) {
232 return Hep3Vector(0,0,0);
234 std::cerr <<
"HepLorentzVector::findBoostToCM() - "
235 <<
"boostToCM computed for two 4-vectors with combined t=0 -- "
236 <<
"infinite result" << std::endl;
237 return Hep3Vector(v1*(1./t1));
246 return Hep3Vector(v1 * (-1./t1));
G4double invariantMass(const G4double E, const ThreeVector &p)