16 #pragma implementation
19 #include "CLHEP/Vector/LorentzVector.h"
29 int HepLorentzVector::compare (
const HepLorentzVector & w)
const {
32 }
else if ( ee < w.ee ) {
35 return (
pp.compare(w.pp) );
39 bool HepLorentzVector::operator > (
const HepLorentzVector & w)
const {
40 return (compare(w) > 0);
43 return (compare(w) < 0);
45 bool HepLorentzVector::operator>= (
const HepLorentzVector & w)
const {
46 return (compare(w) >= 0);
48 bool HepLorentzVector::operator<= (
const HepLorentzVector & w)
const {
49 return (compare(w) <= 0);
57 bool HepLorentzVector::isNear(
const HepLorentzVector & w,
58 double epsilon)
const {
59 double limit = std::fabs(
pp.dot(w.pp));
60 limit += .25*((ee+w.ee)*(ee+w.ee));
61 limit *= epsilon*epsilon;
62 double delta = (
pp - w.pp).mag2();
63 delta += (ee-w.ee)*(ee-w.ee);
64 return (delta <= limit );
67 double HepLorentzVector::howNear(
const HepLorentzVector & w)
const {
68 double wdw = std::fabs(
pp.dot(w.pp)) + .25*((ee+w.ee)*(ee+w.ee));
69 double delta = (
pp - w.pp).mag2() + (ee-w.ee)*(ee-w.ee);
70 if ( (wdw > 0) && (delta < wdw) ) {
71 return std::sqrt (delta/wdw);
72 }
else if ( (wdw == 0) && (delta == 0) ) {
84 bool HepLorentzVector::isNearCM
85 (
const HepLorentzVector & w,
double epsilon)
const {
87 double tTotal = (ee + w.ee);
88 Hep3Vector vTotal (
pp + w.pp);
89 double vTotal2 = vTotal.mag2();
91 if ( vTotal2 >= tTotal*tTotal ) {
100 return (isNear(w, epsilon));
105 double tRecip = 1./tTotal;
106 Hep3Vector bboost ( vTotal * (-tRecip) );
116 double b2 = vTotal2*tRecip*tRecip;
118 register double ggamma = std::sqrt(1./(1.-b2));
119 register double boostDotV1 = bboost.dot(
pp);
120 register double gm1_b2 = (ggamma-1)/b2;
122 HepLorentzVector w1 (
pp + ((gm1_b2)*boostDotV1+ggamma*ee) * bboost,
123 ggamma * (ee + boostDotV1) );
125 register double boostDotV2 = bboost.dot(w.pp);
126 HepLorentzVector w2 ( w.pp + ((gm1_b2)*boostDotV2+ggamma*w.ee) * bboost,
127 ggamma * (w.ee + boostDotV2) );
129 return (w1.isNear(w2, epsilon));
133 double HepLorentzVector::howNearCM(
const HepLorentzVector & w)
const {
135 double tTotal = (ee + w.ee);
136 Hep3Vector vTotal (
pp + w.pp);
137 double vTotal2 = vTotal.mag2();
139 if ( vTotal2 >= tTotal*tTotal ) {
151 if ( vTotal2 == 0 ) {
157 double tRecip = 1./tTotal;
158 Hep3Vector bboost ( vTotal * (-tRecip) );
168 double b2 = vTotal2*tRecip*tRecip;
173 register double ggamma = std::sqrt(1./(1.-b2));
174 register double boostDotV1 = bboost.dot(
pp);
175 register double gm1_b2 = (ggamma-1)/b2;
177 HepLorentzVector w1 (
pp + ((gm1_b2)*boostDotV1+ggamma*ee) * bboost,
178 ggamma * (ee + boostDotV1) );
180 register double boostDotV2 = bboost.dot(w.pp);
181 HepLorentzVector w2 ( w.pp + ((gm1_b2)*boostDotV2+ggamma*w.ee) * bboost,
182 ggamma * (w.ee + boostDotV2) );
184 return (w1.howNear(w2));
195 double HepLorentzVector::deltaR (
const HepLorentzVector & w )
const {
197 double a = eta() - w.eta();
198 double b =
pp.deltaPhi(w.getV());
200 return std::sqrt ( a*a + b*b );
208 bool HepLorentzVector::isParallel (
const HepLorentzVector & w,
double epsilon)
const {
209 double norm = euclideanNorm();
210 double wnorm = w.euclideanNorm();
221 HepLorentzVector w1 = *
this / norm;
222 HepLorentzVector w2 = w / wnorm;
223 return ( (w1-w2).euclideanNorm2() <= epsilon*epsilon );
227 double HepLorentzVector::howParallel (
const HepLorentzVector & w)
const {
229 double norm = euclideanNorm();
230 double wnorm = w.euclideanNorm();
242 HepLorentzVector w1 = *
this / norm;
243 HepLorentzVector w2 = w / wnorm;
244 double x1 = (w1-w2).euclideanNorm();
245 return (x1 < 1) ? x1 : 1;
249 double HepLorentzVector::howLightlike()
const {
250 double m1 = std::fabs(restMass2());
251 double twoT2 = 2*ee*ee;
bool operator<(const CexmcAngularRange &left, const CexmcAngularRange &right)