CLHEP  2.4.7.2
C++ Class Library for High Energy Physics
LorentzVector.icc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: LorentzVector.icc,v 1.3 2010/06/16 17:15:57 garren 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 x1, double y1, double z1, double t1)
24  : pp(x1, y1, z1), ee(t1) {}
25 
26 inline HepLorentzVector:: HepLorentzVector(double x1, double y1, double z1)
27  : pp(x1, y1, z1), ee(0) {}
28 
29 inline HepLorentzVector:: HepLorentzVector(double t1)
30  : pp(0, 0, 0), ee(t1) {}
31 
32 inline HepLorentzVector:: HepLorentzVector()
33  : pp(0, 0, 0), ee(0) {}
34 
35 inline HepLorentzVector::HepLorentzVector(const Hep3Vector & p, double e1)
36  : pp(p), ee(e1) {}
37 
38 inline HepLorentzVector::HepLorentzVector(double e1, const Hep3Vector & p)
39  : pp(p), ee(e1) {}
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 &v1) const {
135  return pp.perp2(v1);
136 }
137 
138 inline double HepLorentzVector::perp(const Hep3Vector &v1) const {
139  return pp.perp(v1);
140 }
141 
142 inline double HepLorentzVector::angle(const Hep3Vector &v1) const {
143  return pp.angle(v1);
144 }
145 
146 inline double HepLorentzVector::mag2() const {
147  return metric*(t()*t() - pp.mag2());
148 }
149 
150 inline double HepLorentzVector::mag() const {
151  double mmm = m2();
152  return mmm < 0.0 ? -std::sqrt(-mmm) : std::sqrt(mmm);
153 }
154 
155 inline double HepLorentzVector::m2() const {
156  return t()*t() - pp.mag2();
157 }
158 
159 inline double HepLorentzVector::m() const { return mag(); }
160 
161 inline double HepLorentzVector::mt2() const {
162  return e()*e() - pz()*pz();
163 }
164 
165 inline double HepLorentzVector::mt() const {
166  double mmm = mt2();
167  return mmm < 0.0 ? -std::sqrt(-mmm) : std::sqrt(mmm);
168 }
169 
170 inline double HepLorentzVector::et2() const {
171  double pt2 = pp.perp2();
172  return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+z()*z());
173 }
174 
175 inline double HepLorentzVector::et() const {
176  double etet = et2();
177  return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
178 }
179 
180 inline double HepLorentzVector::et2(const Hep3Vector & v1) const {
181  double pt2 = pp.perp2(v1);
182  double pv = pp.dot(v1.unit());
183  return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+pv*pv);
184 }
185 
186 inline double HepLorentzVector::et(const Hep3Vector & v1) const {
187  double etet = et2(v1);
188  return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
189 }
190 
191 inline void
192 HepLorentzVector::setVectMag(const Hep3Vector & spatial, double magnitude) {
193  setVect(spatial);
194  setT(std::sqrt(magnitude * magnitude + spatial * spatial));
195 }
196 
197 inline void
198 HepLorentzVector::setVectM(const Hep3Vector & spatial, double mass) {
199  setVectMag(spatial, mass);
200 }
201 
202 inline double HepLorentzVector::dot(const HepLorentzVector & q) const {
203  return metric*(t()*q.t() - z()*q.z() - y()*q.y() - x()*q.x());
204 }
205 
206 inline double
207 HepLorentzVector::operator * (const HepLorentzVector & q) const {
208  return dot(q);
209 }
210 
211 inline double HepLorentzVector::plus() const {
212  return t() + z();
213 }
214 
215 inline double HepLorentzVector::minus() const {
216  return t() - z();
217 }
218 
219 inline HepLorentzVector & HepLorentzVector::boost(const Hep3Vector & b) {
220  return boost(b.x(), b.y(), b.z());
221 }
222 
223 inline double HepLorentzVector::pseudoRapidity() const {
224  return pp.pseudoRapidity();
225 }
226 
227 inline double HepLorentzVector::eta() const {
228  return pp.pseudoRapidity();
229 }
230 
231 inline double HepLorentzVector::eta( const Hep3Vector & ref ) const {
232  return pp.eta( ref );
233 }
234 
235 inline HepLorentzVector &
236 HepLorentzVector::operator *= (const HepRotation & m1) {
237  pp.transform(m1);
238  return *this;
239 }
240 
241 inline HepLorentzVector &
242 HepLorentzVector::transform(const HepRotation & m1) {
243  pp.transform(m1);
244  return *this;
245 }
246 
247 inline HepLorentzVector operator * (const HepLorentzVector & p, double a) {
248  return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
249 }
250 
251 inline HepLorentzVector operator * (double a, const HepLorentzVector & p) {
252  return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
253 }
254 
255 // The following were added when ZOOM PhysicsVectors was merged in:
256 
257 inline HepLorentzVector::HepLorentzVector(
258  double x1, double y1, double z1, Tcomponent t1 ) :
259  pp(x1, y1, z1), ee(t1) {}
260 
261 inline void HepLorentzVector::set(
262  double x1, double y1, double z1, Tcomponent t1 ) {
263  pp.set(x1,y1,z1);
264  ee = t1;
265 }
266 
267 inline void HepLorentzVector::set(
268  double x1, double y1, double z1, double t1 ) {
269  set (x1,y1,z1,Tcomponent(t1));
270 }
271 
272 inline HepLorentzVector::HepLorentzVector(
273  Tcomponent t1, double x1, double y1, double z1 ) :
274  pp(x1, y1, z1), ee(t1) {}
275 
276 inline void HepLorentzVector::set(
277  Tcomponent t1, double x1, double y1, double z1 ) {
278  pp.set(x1,y1,z1);
279  ee = t1;
280 }
281 
282 inline void HepLorentzVector::set( Tcomponent t1 ) {
283  pp.set(0, 0, 0);
284  ee = t1;
285 }
286 
287 inline void HepLorentzVector::set( double t1 ) {
288  pp.set(0, 0, 0);
289  ee = t1;
290 }
291 
292 inline HepLorentzVector::HepLorentzVector( Tcomponent t1 ) :
293  pp(0, 0, 0), ee(t1) {}
294 
295 inline void HepLorentzVector::set( const Hep3Vector & v1 ) {
296  pp = v1;
297  ee = 0;
298 }
299 
300 inline HepLorentzVector::HepLorentzVector( const Hep3Vector & v1 ) :
301  pp(v1), ee(0) {}
302 
303 inline void HepLorentzVector::setV(const Hep3Vector & v1) {
304  pp = v1;
305 }
306 
307 inline HepLorentzVector & HepLorentzVector::operator=(const Hep3Vector & v1) {
308  pp = v1;
309  ee = 0;
310  return *this;
311 }
312 
313 inline double HepLorentzVector::getX() const { return pp.x(); }
314 inline double HepLorentzVector::getY() const { return pp.y(); }
315 inline double HepLorentzVector::getZ() const { return pp.z(); }
316 inline double HepLorentzVector::getT() const { return ee; }
317 
318 inline Hep3Vector HepLorentzVector::getV() const { return pp; }
319 inline Hep3Vector HepLorentzVector::v() const { return pp; }
320 
321 inline void HepLorentzVector::set(double t1, const Hep3Vector & v1) {
322  pp = v1;
323  ee = t1;
324 }
325 
326 inline void HepLorentzVector::set(const Hep3Vector & v1, double t1) {
327  pp = v1;
328  ee = t1;
329 }
330 
331 inline void HepLorentzVector::setV( double x1,
332  double y1,
333  double z1 ) { pp.set(x1, y1, z1); }
334 
335 inline void HepLorentzVector::setRThetaPhi
336  ( double r, double ttheta, double phi1 )
337  { pp.setRThetaPhi( r, ttheta, phi1 ); }
338 
339 inline void HepLorentzVector::setREtaPhi
340  ( double r, double eta1, double phi1 )
341  { pp.setREtaPhi( r, eta1, phi1 ); }
342 
343 inline void HepLorentzVector::setRhoPhiZ
344  ( double rho1, double phi1, double z1 )
345  { pp.setRhoPhiZ ( rho1, phi1, z1 ); }
346 
347 inline bool HepLorentzVector::isTimelike() const {
348  return restMass2() > 0;
349 }
350 
351 inline bool HepLorentzVector::isSpacelike() const {
352  return restMass2() < 0;
353 }
354 
355 inline bool HepLorentzVector::isLightlike(double epsilon) const {
356  return std::fabs(restMass2()) < 2.0 * epsilon * ee * ee;
357 }
358 
359 inline double HepLorentzVector::diff2( const HepLorentzVector & w ) const {
360  return metric*( (ee-w.ee)*(ee-w.ee) - (pp-w.pp).mag2() );
361 }
362 
363 inline double HepLorentzVector::delta2Euclidean
364  ( const HepLorentzVector & w ) const {
365  return (ee-w.ee)*(ee-w.ee) + (pp-w.pp).mag2();
366 }
367 
368 inline double HepLorentzVector::euclideanNorm2() const {
369  return ee*ee + pp.mag2();
370 }
371 
372 inline double HepLorentzVector::euclideanNorm() const {
373  return std::sqrt(euclideanNorm2());
374 }
375 
376 inline double HepLorentzVector::restMass2() const { return m2(); }
377 inline double HepLorentzVector::invariantMass2() const { return m2(); }
378 
379 inline double HepLorentzVector::restMass() const {
380  if( t() < 0.0 ) ZMthrowC(ZMxpvNegativeMass(
381  "E^2-p^2 < 0 for this particle. Magnitude returned."));
382  return t() < 0.0 ? -m() : m();
383 }
384 
385 inline double HepLorentzVector::invariantMass() const {
386  if( t() < 0.0 ) ZMthrowC(ZMxpvNegativeMass(
387  "E^2-p^2 < 0 for this particle. Magnitude returned."));
388  return t() < 0.0 ? -m() : m();
389 }
390 
391 inline double HepLorentzVector::invariantMass2
392  (const HepLorentzVector & w) const {
393  return (*this + w).m2();
394 } /* invariantMass2 */
395 
396 //-*********
397 // boostOf()
398 //-*********
399 
400 // Each of these is a shell over a boost method.
401 
402 inline HepLorentzVector boostXOf
403  (const HepLorentzVector & vec, double bbeta) {
404  HepLorentzVector vv (vec);
405  return vv.boostX (bbeta);
406 }
407 
408 inline HepLorentzVector boostYOf
409  (const HepLorentzVector & vec, double bbeta) {
410  HepLorentzVector vv (vec);
411  return vv.boostY (bbeta);
412 }
413 
414 inline HepLorentzVector boostZOf
415  (const HepLorentzVector & vec, double bbeta) {
416  HepLorentzVector vv (vec);
417  return vv.boostZ (bbeta);
418 }
419 
420 inline HepLorentzVector boostOf
421  (const HepLorentzVector & vec, const Hep3Vector & betaVector ) {
422  HepLorentzVector vv (vec);
423  return vv.boost (betaVector);
424 }
425 
426 inline HepLorentzVector boostOf
427  (const HepLorentzVector & vec, const Hep3Vector & aaxis, double bbeta) {
428  HepLorentzVector vv (vec);
429  return vv.boost (aaxis, bbeta);
430 }
431 
432 } // namespace CLHEP
HepLorentzVector operator*(double a, const HepLorentzVector &p)
Hep3Vector operator-(const Hep3Vector &a, const Hep3Vector &b)
Definition: ThreeVector.icc:57
HepLorentzVector boostXOf(const HepLorentzVector &vec, double bbeta)
STL namespace.
HepLorentzVector boostYOf(const HepLorentzVector &vec, double bbeta)
std::complex< double > dot(const SphericalHarmonicCoefficientSet &a, const SphericalHarmonicCoefficientSet &b)
Hep3Vector operator+(const Hep3Vector &a, const Hep3Vector &b)
Definition: ThreeVector.icc:53
HepLorentzVector boostZOf(const HepLorentzVector &vec, double bbeta)
HepLorentzVector boostOf(const HepLorentzVector &vec, const Hep3Vector &aaxis, double bbeta)