1 | // -*- C++ -*-
|
---|
2 | // $Id: LorentzVector.icc,v 1.1 2008-06-04 14:14:58 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 definitions of the inline member functions of the
|
---|
8 | // HepLorentzVector class.
|
---|
9 | //
|
---|
10 |
|
---|
11 | #include "CLHEP/Vector/ZMxpv.h"
|
---|
12 |
|
---|
13 | #include <cmath>
|
---|
14 |
|
---|
15 | namespace CLHEP {
|
---|
16 |
|
---|
17 | inline double HepLorentzVector::x() const { return pp.x(); }
|
---|
18 | inline double HepLorentzVector::y() const { return pp.y(); }
|
---|
19 | inline double HepLorentzVector::z() const { return pp.z(); }
|
---|
20 | inline double HepLorentzVector::t() const { return ee; }
|
---|
21 |
|
---|
22 | inline HepLorentzVector::
|
---|
23 | HepLorentzVector(double x, double y, double z, double t)
|
---|
24 | : pp(x, y, z), ee(t) {}
|
---|
25 |
|
---|
26 | inline HepLorentzVector:: HepLorentzVector(double x, double y, double z)
|
---|
27 | : pp(x, y, z), ee(0) {}
|
---|
28 |
|
---|
29 | inline HepLorentzVector:: HepLorentzVector(double t)
|
---|
30 | : pp(0, 0, 0), ee(t) {}
|
---|
31 |
|
---|
32 | inline HepLorentzVector:: HepLorentzVector()
|
---|
33 | : pp(0, 0, 0), ee(0) {}
|
---|
34 |
|
---|
35 | inline HepLorentzVector::HepLorentzVector(const Hep3Vector & p, double e)
|
---|
36 | : pp(p), ee(e) {}
|
---|
37 |
|
---|
38 | inline HepLorentzVector::HepLorentzVector(double e, const Hep3Vector & p)
|
---|
39 | : pp(p), ee(e) {}
|
---|
40 |
|
---|
41 | inline HepLorentzVector::HepLorentzVector(const HepLorentzVector & p)
|
---|
42 | : pp(p.x(), p.y(), p.z()), ee(p.t()) {}
|
---|
43 |
|
---|
44 | inline HepLorentzVector::~HepLorentzVector() {}
|
---|
45 |
|
---|
46 | inline HepLorentzVector::operator const Hep3Vector & () const {return pp;}
|
---|
47 | inline HepLorentzVector::operator Hep3Vector & () { return pp; }
|
---|
48 |
|
---|
49 | inline void HepLorentzVector::setX(double a) { pp.setX(a); }
|
---|
50 | inline void HepLorentzVector::setY(double a) { pp.setY(a); }
|
---|
51 | inline void HepLorentzVector::setZ(double a) { pp.setZ(a); }
|
---|
52 | inline void HepLorentzVector::setT(double a) { ee = a;}
|
---|
53 |
|
---|
54 | inline double HepLorentzVector::px() const { return pp.x(); }
|
---|
55 | inline double HepLorentzVector::py() const { return pp.y(); }
|
---|
56 | inline double HepLorentzVector::pz() const { return pp.z(); }
|
---|
57 | inline double HepLorentzVector::e() const { return ee; }
|
---|
58 |
|
---|
59 | inline void HepLorentzVector::setPx(double a) { pp.setX(a); }
|
---|
60 | inline void HepLorentzVector::setPy(double a) { pp.setY(a); }
|
---|
61 | inline void HepLorentzVector::setPz(double a) { pp.setZ(a); }
|
---|
62 | inline void HepLorentzVector::setE(double a) { ee = a;}
|
---|
63 |
|
---|
64 | inline Hep3Vector HepLorentzVector::vect() const { return pp; }
|
---|
65 | inline void HepLorentzVector::setVect(const Hep3Vector &p) { pp = p; }
|
---|
66 |
|
---|
67 | inline double HepLorentzVector::theta() const { return pp.theta(); }
|
---|
68 | inline double HepLorentzVector::cosTheta() const { return pp.cosTheta(); }
|
---|
69 | inline double HepLorentzVector::phi() const { return pp.phi(); }
|
---|
70 | inline double HepLorentzVector::rho() const { return pp.mag(); }
|
---|
71 |
|
---|
72 | inline void HepLorentzVector::setTheta(double a) { pp.setTheta(a); }
|
---|
73 | inline void HepLorentzVector::setPhi(double a) { pp.setPhi(a); }
|
---|
74 | inline void HepLorentzVector::setRho(double a) { pp.setMag(a); }
|
---|
75 |
|
---|
76 | double & HepLorentzVector::operator [] (int i) { return (*this)(i); }
|
---|
77 | double HepLorentzVector::operator [] (int i) const { return (*this)(i); }
|
---|
78 |
|
---|
79 | inline HepLorentzVector &
|
---|
80 | HepLorentzVector::operator = (const HepLorentzVector & q) {
|
---|
81 | pp = q.vect();
|
---|
82 | ee = q.t();
|
---|
83 | return *this;
|
---|
84 | }
|
---|
85 |
|
---|
86 | inline HepLorentzVector
|
---|
87 | HepLorentzVector::operator + (const HepLorentzVector & q) const {
|
---|
88 | return HepLorentzVector(x()+q.x(), y()+q.y(), z()+q.z(), t()+q.t());
|
---|
89 | }
|
---|
90 |
|
---|
91 | inline HepLorentzVector &
|
---|
92 | HepLorentzVector::operator += (const HepLorentzVector & q) {
|
---|
93 | pp += q.vect();
|
---|
94 | ee += q.t();
|
---|
95 | return *this;
|
---|
96 | }
|
---|
97 |
|
---|
98 | inline HepLorentzVector
|
---|
99 | HepLorentzVector::operator - (const HepLorentzVector & q) const {
|
---|
100 | return HepLorentzVector(x()-q.x(), y()-q.y(), z()-q.z(), t()-q.t());
|
---|
101 | }
|
---|
102 |
|
---|
103 | inline HepLorentzVector &
|
---|
104 | HepLorentzVector::operator -= (const HepLorentzVector & q) {
|
---|
105 | pp -= q.vect();
|
---|
106 | ee -= q.t();
|
---|
107 | return *this;
|
---|
108 | }
|
---|
109 |
|
---|
110 | inline HepLorentzVector HepLorentzVector::operator - () const {
|
---|
111 | return HepLorentzVector(-x(), -y(), -z(), -t());
|
---|
112 | }
|
---|
113 |
|
---|
114 | inline HepLorentzVector& HepLorentzVector::operator *= (double a) {
|
---|
115 | pp *= a;
|
---|
116 | ee *= a;
|
---|
117 | return *this;
|
---|
118 | }
|
---|
119 |
|
---|
120 | inline bool
|
---|
121 | HepLorentzVector::operator == (const HepLorentzVector & q) const {
|
---|
122 | return (vect()==q.vect() && t()==q.t());
|
---|
123 | }
|
---|
124 |
|
---|
125 | inline bool
|
---|
126 | HepLorentzVector::operator != (const HepLorentzVector & q) const {
|
---|
127 | return (vect()!=q.vect() || t()!=q.t());
|
---|
128 | }
|
---|
129 |
|
---|
130 | inline double HepLorentzVector::perp2() const { return pp.perp2(); }
|
---|
131 | inline double HepLorentzVector::perp() const { return pp.perp(); }
|
---|
132 | inline void HepLorentzVector::setPerp(double a) { pp.setPerp(a); }
|
---|
133 |
|
---|
134 | inline double HepLorentzVector::perp2(const Hep3Vector &v) const {
|
---|
135 | return pp.perp2(v);
|
---|
136 | }
|
---|
137 |
|
---|
138 | inline double HepLorentzVector::perp(const Hep3Vector &v) const {
|
---|
139 | return pp.perp(v);
|
---|
140 | }
|
---|
141 |
|
---|
142 | inline double HepLorentzVector::angle(const Hep3Vector &v) const {
|
---|
143 | return pp.angle(v);
|
---|
144 | }
|
---|
145 |
|
---|
146 | inline double HepLorentzVector::mag2() const {
|
---|
147 | #if defined USING_VISUAL
|
---|
148 | // kludge for problem building Windows DLL
|
---|
149 | double r = metric*(t()*t() - pp.mag2());
|
---|
150 | return r;
|
---|
151 | #else
|
---|
152 | return metric*(t()*t() - pp.mag2());
|
---|
153 | #endif
|
---|
154 | }
|
---|
155 |
|
---|
156 | inline double HepLorentzVector::mag() const {
|
---|
157 | double mm = m2();
|
---|
158 | return mm < 0.0 ? -std::sqrt(-mm) : std::sqrt(mm);
|
---|
159 | }
|
---|
160 |
|
---|
161 | inline double HepLorentzVector::m2() const {
|
---|
162 | return t()*t() - pp.mag2();
|
---|
163 | }
|
---|
164 |
|
---|
165 | inline double HepLorentzVector::m() const { return mag(); }
|
---|
166 |
|
---|
167 | inline double HepLorentzVector::mt2() const {
|
---|
168 | return e()*e() - pz()*pz();
|
---|
169 | }
|
---|
170 |
|
---|
171 | inline double HepLorentzVector::mt() const {
|
---|
172 | double mm = mt2();
|
---|
173 | return mm < 0.0 ? -std::sqrt(-mm) : std::sqrt(mm);
|
---|
174 | }
|
---|
175 |
|
---|
176 | inline double HepLorentzVector::et2() const {
|
---|
177 | double pt2 = pp.perp2();
|
---|
178 | return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+z()*z());
|
---|
179 | }
|
---|
180 |
|
---|
181 | inline double HepLorentzVector::et() const {
|
---|
182 | double etet = et2();
|
---|
183 | return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
|
---|
184 | }
|
---|
185 |
|
---|
186 | inline double HepLorentzVector::et2(const Hep3Vector & v) const {
|
---|
187 | double pt2 = pp.perp2(v);
|
---|
188 | double pv = pp.dot(v.unit());
|
---|
189 | return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+pv*pv);
|
---|
190 | }
|
---|
191 |
|
---|
192 | inline double HepLorentzVector::et(const Hep3Vector & v) const {
|
---|
193 | double etet = et2(v);
|
---|
194 | return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
|
---|
195 | }
|
---|
196 |
|
---|
197 | inline void
|
---|
198 | HepLorentzVector::setVectMag(const Hep3Vector & spatial, double magnitude) {
|
---|
199 | setVect(spatial);
|
---|
200 | setT(std::sqrt(magnitude * magnitude + spatial * spatial));
|
---|
201 | }
|
---|
202 |
|
---|
203 | inline void
|
---|
204 | HepLorentzVector::setVectM(const Hep3Vector & spatial, double mass) {
|
---|
205 | setVectMag(spatial, mass);
|
---|
206 | }
|
---|
207 |
|
---|
208 | inline double HepLorentzVector::dot(const HepLorentzVector & q) const {
|
---|
209 | #if defined USING_VISUAL
|
---|
210 | // kludge for problem building Windows DLL
|
---|
211 | double r = metric*(t()*q.t() - z()*q.z() - y()*q.y() - x()*q.x());
|
---|
212 | return r;
|
---|
213 | #else
|
---|
214 | return metric*(t()*q.t() - z()*q.z() - y()*q.y() - x()*q.x());
|
---|
215 | #endif
|
---|
216 | }
|
---|
217 |
|
---|
218 | inline double
|
---|
219 | HepLorentzVector::operator * (const HepLorentzVector & q) const {
|
---|
220 | return dot(q);
|
---|
221 | }
|
---|
222 |
|
---|
223 | inline double HepLorentzVector::plus() const {
|
---|
224 | return t() + z();
|
---|
225 | }
|
---|
226 |
|
---|
227 | inline double HepLorentzVector::minus() const {
|
---|
228 | return t() - z();
|
---|
229 | }
|
---|
230 |
|
---|
231 | inline HepLorentzVector & HepLorentzVector::boost(const Hep3Vector & b) {
|
---|
232 | return boost(b.x(), b.y(), b.z());
|
---|
233 | }
|
---|
234 |
|
---|
235 | inline double HepLorentzVector::pseudoRapidity() const {
|
---|
236 | return pp.pseudoRapidity();
|
---|
237 | }
|
---|
238 |
|
---|
239 | inline double HepLorentzVector::eta() const {
|
---|
240 | return pp.pseudoRapidity();
|
---|
241 | }
|
---|
242 |
|
---|
243 | inline double HepLorentzVector::eta( const Hep3Vector & ref ) const {
|
---|
244 | return pp.eta( ref );
|
---|
245 | }
|
---|
246 |
|
---|
247 | inline HepLorentzVector &
|
---|
248 | HepLorentzVector::operator *= (const HepRotation & m) {
|
---|
249 | pp.transform(m);
|
---|
250 | return *this;
|
---|
251 | }
|
---|
252 |
|
---|
253 | inline HepLorentzVector &
|
---|
254 | HepLorentzVector::transform(const HepRotation & m) {
|
---|
255 | pp.transform(m);
|
---|
256 | return *this;
|
---|
257 | }
|
---|
258 |
|
---|
259 | inline HepLorentzVector operator * (const HepLorentzVector & p, double a) {
|
---|
260 | return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
|
---|
261 | }
|
---|
262 |
|
---|
263 | inline HepLorentzVector operator * (double a, const HepLorentzVector & p) {
|
---|
264 | return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
|
---|
265 | }
|
---|
266 |
|
---|
267 | // The following were added when ZOOM PhysicsVectors was merged in:
|
---|
268 |
|
---|
269 | inline HepLorentzVector::HepLorentzVector(
|
---|
270 | double x, double y, double z, Tcomponent t ) :
|
---|
271 | pp(x, y, z), ee(t) {}
|
---|
272 |
|
---|
273 | inline void HepLorentzVector::set(
|
---|
274 | double x, double y, double z, Tcomponent t ) {
|
---|
275 | pp.set(x,y,z);
|
---|
276 | ee = t;
|
---|
277 | }
|
---|
278 |
|
---|
279 | inline void HepLorentzVector::set(
|
---|
280 | double x, double y, double z, double t ) {
|
---|
281 | set (x,y,z,Tcomponent(t));
|
---|
282 | }
|
---|
283 |
|
---|
284 | inline HepLorentzVector::HepLorentzVector(
|
---|
285 | Tcomponent t, double x, double y, double z ) :
|
---|
286 | pp(x, y, z), ee(t) {}
|
---|
287 |
|
---|
288 | inline void HepLorentzVector::set(
|
---|
289 | Tcomponent t, double x, double y, double z ) {
|
---|
290 | pp.set(x,y,z);
|
---|
291 | ee = t;
|
---|
292 | }
|
---|
293 |
|
---|
294 | inline void HepLorentzVector::set( Tcomponent t ) {
|
---|
295 | pp.set(0, 0, 0);
|
---|
296 | ee = t;
|
---|
297 | }
|
---|
298 |
|
---|
299 | inline void HepLorentzVector::set( double t ) {
|
---|
300 | pp.set(0, 0, 0);
|
---|
301 | ee = t;
|
---|
302 | }
|
---|
303 |
|
---|
304 | inline HepLorentzVector::HepLorentzVector( Tcomponent t ) :
|
---|
305 | pp(0, 0, 0), ee(t) {}
|
---|
306 |
|
---|
307 | inline void HepLorentzVector::set( const Hep3Vector & v ) {
|
---|
308 | pp = v;
|
---|
309 | ee = 0;
|
---|
310 | }
|
---|
311 |
|
---|
312 | inline HepLorentzVector::HepLorentzVector( const Hep3Vector & v ) :
|
---|
313 | pp(v), ee(0) {}
|
---|
314 |
|
---|
315 | inline void HepLorentzVector::setV(const Hep3Vector & v) {
|
---|
316 | pp = v;
|
---|
317 | }
|
---|
318 |
|
---|
319 | inline HepLorentzVector & HepLorentzVector::operator=(const Hep3Vector & v) {
|
---|
320 | pp = v;
|
---|
321 | ee = 0;
|
---|
322 | return *this;
|
---|
323 | }
|
---|
324 |
|
---|
325 | inline double HepLorentzVector::getX() const { return pp.x(); }
|
---|
326 | inline double HepLorentzVector::getY() const { return pp.y(); }
|
---|
327 | inline double HepLorentzVector::getZ() const { return pp.z(); }
|
---|
328 | inline double HepLorentzVector::getT() const { return ee; }
|
---|
329 |
|
---|
330 | inline Hep3Vector HepLorentzVector::getV() const { return pp; }
|
---|
331 | inline Hep3Vector HepLorentzVector::v() const { return pp; }
|
---|
332 |
|
---|
333 | inline void HepLorentzVector::set(double t, const Hep3Vector & v) {
|
---|
334 | pp = v;
|
---|
335 | ee = t;
|
---|
336 | }
|
---|
337 |
|
---|
338 | inline void HepLorentzVector::set(const Hep3Vector & v, double t) {
|
---|
339 | pp = v;
|
---|
340 | ee = t;
|
---|
341 | }
|
---|
342 |
|
---|
343 | inline void HepLorentzVector::setV( double x,
|
---|
344 | double y,
|
---|
345 | double z ) { pp.set(x, y, z); }
|
---|
346 |
|
---|
347 | inline void HepLorentzVector::setRThetaPhi
|
---|
348 | ( double r, double theta, double phi )
|
---|
349 | { pp.setRThetaPhi( r, theta, phi ); }
|
---|
350 |
|
---|
351 | inline void HepLorentzVector::setREtaPhi
|
---|
352 | ( double r, double eta, double phi )
|
---|
353 | { pp.setREtaPhi( r, eta, phi ); }
|
---|
354 |
|
---|
355 | inline void HepLorentzVector::setRhoPhiZ
|
---|
356 | ( double rho, double phi, double z )
|
---|
357 | { pp.setRhoPhiZ ( rho, phi, z ); }
|
---|
358 |
|
---|
359 | inline bool HepLorentzVector::isTimelike() const {
|
---|
360 | return restMass2() > 0;
|
---|
361 | }
|
---|
362 |
|
---|
363 | inline bool HepLorentzVector::isSpacelike() const {
|
---|
364 | return restMass2() < 0;
|
---|
365 | }
|
---|
366 |
|
---|
367 | inline bool HepLorentzVector::isLightlike(double epsilon) const {
|
---|
368 | return std::fabs(restMass2()) < 2.0 * epsilon * ee * ee;
|
---|
369 | }
|
---|
370 |
|
---|
371 | inline double HepLorentzVector::diff2( const HepLorentzVector & w ) const {
|
---|
372 | #if defined USING_VISUAL
|
---|
373 | // kludge for problem building Windows DLL
|
---|
374 | double r= metric*( (ee-w.ee)*(ee-w.ee) - (pp-w.pp).mag2() );
|
---|
375 | return r;
|
---|
376 | #else
|
---|
377 | return metric*( (ee-w.ee)*(ee-w.ee) - (pp-w.pp).mag2() );
|
---|
378 | #endif
|
---|
379 | }
|
---|
380 |
|
---|
381 | inline double HepLorentzVector::delta2Euclidean
|
---|
382 | ( const HepLorentzVector & w ) const {
|
---|
383 | return (ee-w.ee)*(ee-w.ee) + (pp-w.pp).mag2();
|
---|
384 | }
|
---|
385 |
|
---|
386 | inline double HepLorentzVector::euclideanNorm2() const {
|
---|
387 | return ee*ee + pp.mag2();
|
---|
388 | }
|
---|
389 |
|
---|
390 | inline double HepLorentzVector::euclideanNorm() const {
|
---|
391 | return std::sqrt(euclideanNorm2());
|
---|
392 | }
|
---|
393 |
|
---|
394 | inline double HepLorentzVector::restMass2() const { return m2(); }
|
---|
395 | inline double HepLorentzVector::invariantMass2() const { return m2(); }
|
---|
396 |
|
---|
397 | inline double HepLorentzVector::restMass() const {
|
---|
398 | if( t() < 0.0 ) ZMthrowC(ZMxpvNegativeMass(
|
---|
399 | "E^2-p^2 < 0 for this particle. Magnitude returned."));
|
---|
400 | return t() < 0.0 ? -m() : m();
|
---|
401 | }
|
---|
402 |
|
---|
403 | inline double HepLorentzVector::invariantMass() const {
|
---|
404 | if( t() < 0.0 ) ZMthrowC(ZMxpvNegativeMass(
|
---|
405 | "E^2-p^2 < 0 for this particle. Magnitude returned."));
|
---|
406 | return t() < 0.0 ? -m() : m();
|
---|
407 | }
|
---|
408 |
|
---|
409 | inline double HepLorentzVector::invariantMass2
|
---|
410 | (const HepLorentzVector & w) const {
|
---|
411 | return (*this + w).m2();
|
---|
412 | } /* invariantMass2 */
|
---|
413 |
|
---|
414 | //-*********
|
---|
415 | // boostOf()
|
---|
416 | //-*********
|
---|
417 |
|
---|
418 | // Each of these is a shell over a boost method.
|
---|
419 |
|
---|
420 | inline HepLorentzVector boostXOf
|
---|
421 | (const HepLorentzVector & vec, double beta) {
|
---|
422 | HepLorentzVector vv (vec);
|
---|
423 | return vv.boostX (beta);
|
---|
424 | }
|
---|
425 |
|
---|
426 | inline HepLorentzVector boostYOf
|
---|
427 | (const HepLorentzVector & vec, double beta) {
|
---|
428 | HepLorentzVector vv (vec);
|
---|
429 | return vv.boostY (beta);
|
---|
430 | }
|
---|
431 |
|
---|
432 | inline HepLorentzVector boostZOf
|
---|
433 | (const HepLorentzVector & vec, double beta) {
|
---|
434 | HepLorentzVector vv (vec);
|
---|
435 | return vv.boostZ (beta);
|
---|
436 | }
|
---|
437 |
|
---|
438 | inline HepLorentzVector boostOf
|
---|
439 | (const HepLorentzVector & vec, const Hep3Vector & betaVector ) {
|
---|
440 | HepLorentzVector vv (vec);
|
---|
441 | return vv.boost (betaVector);
|
---|
442 | }
|
---|
443 |
|
---|
444 | inline HepLorentzVector boostOf
|
---|
445 | (const HepLorentzVector & vec, const Hep3Vector & axis, double beta) {
|
---|
446 | HepLorentzVector vv (vec);
|
---|
447 | return vv.boost (axis, beta);
|
---|
448 | }
|
---|
449 |
|
---|
450 | } // namespace CLHEP
|
---|