3 // ---------------------------------------------------------------------------
5 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
7 // This is the definitions of the inline member functions of the
8 // HepLorentzVector class.
15 inline double HepLorentzVector::x() const { return pp.x(); }
16 inline double HepLorentzVector::y() const { return pp.y(); }
17 inline double HepLorentzVector::z() const { return pp.z(); }
18 inline double HepLorentzVector::t() const { return ee; }
20 inline HepLorentzVector::
21 HepLorentzVector(double x1, double y1, double z1, double t1)
22 : pp(x1, y1, z1), ee(t1) {}
24 inline HepLorentzVector:: HepLorentzVector(double x1, double y1, double z1)
25 : pp(x1, y1, z1), ee(0) {}
27 inline HepLorentzVector:: HepLorentzVector(double t1)
28 : pp(0, 0, 0), ee(t1) {}
30 inline HepLorentzVector:: HepLorentzVector()
31 : pp(0, 0, 0), ee(0) {}
33 inline HepLorentzVector::HepLorentzVector(const Hep3Vector & p, double e1)
36 inline HepLorentzVector::HepLorentzVector(double e1, const Hep3Vector & p)
39 inline HepLorentzVector::HepLorentzVector(const HepLorentzVector & p)
40 : pp(p.x(), p.y(), p.z()), ee(p.t()) {}
42 inline HepLorentzVector::~HepLorentzVector() {}
44 inline HepLorentzVector::operator const Hep3Vector & () const {return pp;}
45 inline HepLorentzVector::operator Hep3Vector & () { return pp; }
47 inline void HepLorentzVector::setX(double a) { pp.setX(a); }
48 inline void HepLorentzVector::setY(double a) { pp.setY(a); }
49 inline void HepLorentzVector::setZ(double a) { pp.setZ(a); }
50 inline void HepLorentzVector::setT(double a) { ee = a;}
52 inline double HepLorentzVector::px() const { return pp.x(); }
53 inline double HepLorentzVector::py() const { return pp.y(); }
54 inline double HepLorentzVector::pz() const { return pp.z(); }
55 inline double HepLorentzVector::e() const { return ee; }
57 inline void HepLorentzVector::setPx(double a) { pp.setX(a); }
58 inline void HepLorentzVector::setPy(double a) { pp.setY(a); }
59 inline void HepLorentzVector::setPz(double a) { pp.setZ(a); }
60 inline void HepLorentzVector::setE(double a) { ee = a;}
62 inline Hep3Vector HepLorentzVector::vect() const { return pp; }
63 inline void HepLorentzVector::setVect(const Hep3Vector &p) { pp = p; }
65 inline double HepLorentzVector::theta() const { return pp.theta(); }
66 inline double HepLorentzVector::cosTheta() const { return pp.cosTheta(); }
67 inline double HepLorentzVector::phi() const { return pp.phi(); }
68 inline double HepLorentzVector::rho() const { return pp.mag(); }
70 inline void HepLorentzVector::setTheta(double a) { pp.setTheta(a); }
71 inline void HepLorentzVector::setPhi(double a) { pp.setPhi(a); }
72 inline void HepLorentzVector::setRho(double a) { pp.setMag(a); }
74 double & HepLorentzVector::operator [] (int i) { return (*this)(i); }
75 double HepLorentzVector::operator [] (int i) const { return (*this)(i); }
77 inline HepLorentzVector &
78 HepLorentzVector::operator = (const HepLorentzVector & q) {
84 inline HepLorentzVector
85 HepLorentzVector::operator + (const HepLorentzVector & q) const {
86 return HepLorentzVector(x()+q.x(), y()+q.y(), z()+q.z(), t()+q.t());
89 inline HepLorentzVector &
90 HepLorentzVector::operator += (const HepLorentzVector & q) {
96 inline HepLorentzVector
97 HepLorentzVector::operator - (const HepLorentzVector & q) const {
98 return HepLorentzVector(x()-q.x(), y()-q.y(), z()-q.z(), t()-q.t());
101 inline HepLorentzVector &
102 HepLorentzVector::operator -= (const HepLorentzVector & q) {
108 inline HepLorentzVector HepLorentzVector::operator - () const {
109 return HepLorentzVector(-x(), -y(), -z(), -t());
112 inline HepLorentzVector& HepLorentzVector::operator *= (double a) {
119 HepLorentzVector::operator == (const HepLorentzVector & q) const {
120 return (vect()==q.vect() && t()==q.t());
124 HepLorentzVector::operator != (const HepLorentzVector & q) const {
125 return (vect()!=q.vect() || t()!=q.t());
128 inline double HepLorentzVector::perp2() const { return pp.perp2(); }
129 inline double HepLorentzVector::perp() const { return pp.perp(); }
130 inline void HepLorentzVector::setPerp(double a) { pp.setPerp(a); }
132 inline double HepLorentzVector::perp2(const Hep3Vector &v1) const {
136 inline double HepLorentzVector::perp(const Hep3Vector &v1) const {
140 inline double HepLorentzVector::angle(const Hep3Vector &v1) const {
144 inline double HepLorentzVector::mag2() const {
145 return metric*(t()*t() - pp.mag2());
148 inline double HepLorentzVector::mag() const {
150 return mmm < 0.0 ? -std::sqrt(-mmm) : std::sqrt(mmm);
153 inline double HepLorentzVector::m2() const {
154 return t()*t() - pp.mag2();
157 inline double HepLorentzVector::m() const { return mag(); }
159 inline double HepLorentzVector::mt2() const {
160 return e()*e() - pz()*pz();
163 inline double HepLorentzVector::mt() const {
165 return mmm < 0.0 ? -std::sqrt(-mmm) : std::sqrt(mmm);
168 inline double HepLorentzVector::et2() const {
169 double pt2 = pp.perp2();
170 return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+z()*z());
173 inline double HepLorentzVector::et() const {
175 return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
178 inline double HepLorentzVector::et2(const Hep3Vector & v1) const {
179 double pt2 = pp.perp2(v1);
180 double pv = pp.dot(v1.unit());
181 return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+pv*pv);
184 inline double HepLorentzVector::et(const Hep3Vector & v1) const {
185 double etet = et2(v1);
186 return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
190 HepLorentzVector::setVectMag(const Hep3Vector & spatial, double magnitude) {
192 setT(std::sqrt(magnitude * magnitude + spatial * spatial));
196 HepLorentzVector::setVectM(const Hep3Vector & spatial, double mass) {
197 setVectMag(spatial, mass);
200 inline double HepLorentzVector::dot(const HepLorentzVector & q) const {
201 return metric*(t()*q.t() - z()*q.z() - y()*q.y() - x()*q.x());
205 HepLorentzVector::operator * (const HepLorentzVector & q) const {
209 inline double HepLorentzVector::plus() const {
213 inline double HepLorentzVector::minus() const {
217 inline HepLorentzVector & HepLorentzVector::boost(const Hep3Vector & b) {
218 return boost(b.x(), b.y(), b.z());
221 inline double HepLorentzVector::pseudoRapidity() const {
222 return pp.pseudoRapidity();
225 inline double HepLorentzVector::eta() const {
226 return pp.pseudoRapidity();
229 inline double HepLorentzVector::eta( const Hep3Vector & ref ) const {
230 return pp.eta( ref );
233 inline HepLorentzVector &
234 HepLorentzVector::operator *= (const HepRotation & m1) {
239 inline HepLorentzVector &
240 HepLorentzVector::transform(const HepRotation & m1) {
245 inline HepLorentzVector operator * (const HepLorentzVector & p, double a) {
246 return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
249 inline HepLorentzVector operator * (double a, const HepLorentzVector & p) {
250 return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
253 // The following were added when ZOOM PhysicsVectors was merged in:
255 inline HepLorentzVector::HepLorentzVector(
256 double x1, double y1, double z1, Tcomponent t1 ) :
257 pp(x1, y1, z1), ee(t1) {}
259 inline void HepLorentzVector::set(
260 double x1, double y1, double z1, Tcomponent t1 ) {
265 inline void HepLorentzVector::set(
266 double x1, double y1, double z1, double t1 ) {
267 set (x1,y1,z1,Tcomponent(t1));
270 inline HepLorentzVector::HepLorentzVector(
271 Tcomponent t1, double x1, double y1, double z1 ) :
272 pp(x1, y1, z1), ee(t1) {}
274 inline void HepLorentzVector::set(
275 Tcomponent t1, double x1, double y1, double z1 ) {
280 inline void HepLorentzVector::set( Tcomponent t1 ) {
285 inline void HepLorentzVector::set( double t1 ) {
290 inline HepLorentzVector::HepLorentzVector( Tcomponent t1 ) :
291 pp(0, 0, 0), ee(t1) {}
293 inline void HepLorentzVector::set( const Hep3Vector & v1 ) {
298 inline HepLorentzVector::HepLorentzVector( const Hep3Vector & v1 ) :
301 inline void HepLorentzVector::setV(const Hep3Vector & v1) {
305 inline HepLorentzVector & HepLorentzVector::operator=(const Hep3Vector & v1) {
311 inline double HepLorentzVector::getX() const { return pp.x(); }
312 inline double HepLorentzVector::getY() const { return pp.y(); }
313 inline double HepLorentzVector::getZ() const { return pp.z(); }
314 inline double HepLorentzVector::getT() const { return ee; }
316 inline Hep3Vector HepLorentzVector::getV() const { return pp; }
317 inline Hep3Vector HepLorentzVector::v() const { return pp; }
319 inline void HepLorentzVector::set(double t1, const Hep3Vector & v1) {
324 inline void HepLorentzVector::set(const Hep3Vector & v1, double t1) {
329 inline void HepLorentzVector::setV( double x1,
331 double z1 ) { pp.set(x1, y1, z1); }
333 inline void HepLorentzVector::setRThetaPhi
334 ( double r, double ttheta, double phi1 )
335 { pp.setRThetaPhi( r, ttheta, phi1 ); }
337 inline void HepLorentzVector::setREtaPhi
338 ( double r, double eta1, double phi1 )
339 { pp.setREtaPhi( r, eta1, phi1 ); }
341 inline void HepLorentzVector::setRhoPhiZ
342 ( double rho1, double phi1, double z1 )
343 { pp.setRhoPhiZ ( rho1, phi1, z1 ); }
345 inline bool HepLorentzVector::isTimelike() const {
346 return restMass2() > 0;
349 inline bool HepLorentzVector::isSpacelike() const {
350 return restMass2() < 0;
353 inline bool HepLorentzVector::isLightlike(double epsilon) const {
354 return std::fabs(restMass2()) < 2.0 * epsilon * ee * ee;
357 inline double HepLorentzVector::diff2( const HepLorentzVector & w ) const {
358 return metric*( (ee-w.ee)*(ee-w.ee) - (pp-w.pp).mag2() );
361 inline double HepLorentzVector::delta2Euclidean
362 ( const HepLorentzVector & w ) const {
363 return (ee-w.ee)*(ee-w.ee) + (pp-w.pp).mag2();
366 inline double HepLorentzVector::euclideanNorm2() const {
367 return ee*ee + pp.mag2();
370 inline double HepLorentzVector::euclideanNorm() const {
371 return std::sqrt(euclideanNorm2());
374 inline double HepLorentzVector::restMass2() const { return m2(); }
375 inline double HepLorentzVector::invariantMass2() const { return m2(); }
377 inline double HepLorentzVector::restMass() const {
379 // std::cerr << "HepLorentzVector::restMass() - "
380 // << "E^2-p^2 < 0 for this particle. Magnitude returned."
382 return t() < 0.0 ? -m() : m();
385 inline double HepLorentzVector::invariantMass() const {
387 // std::cerr << "HepLorentzVector::invariantMass() - "
388 // << "E^2-p^2 < 0 for this particle. Magnitude returned."
390 return t() < 0.0 ? -m() : m();
393 inline double HepLorentzVector::invariantMass2
394 (const HepLorentzVector & w) const {
395 return (*this + w).m2();
396 } /* invariantMass2 */
402 // Each of these is a shell over a boost method.
404 inline HepLorentzVector boostXOf
405 (const HepLorentzVector & vec, double bbeta) {
406 HepLorentzVector vv (vec);
407 return vv.boostX (bbeta);
410 inline HepLorentzVector boostYOf
411 (const HepLorentzVector & vec, double bbeta) {
412 HepLorentzVector vv (vec);
413 return vv.boostY (bbeta);
416 inline HepLorentzVector boostZOf
417 (const HepLorentzVector & vec, double bbeta) {
418 HepLorentzVector vv (vec);
419 return vv.boostZ (bbeta);
422 inline HepLorentzVector boostOf
423 (const HepLorentzVector & vec, const Hep3Vector & betaVector ) {
424 HepLorentzVector vv (vec);
425 return vv.boost (betaVector);
428 inline HepLorentzVector boostOf
429 (const HepLorentzVector & vec, const Hep3Vector & aaxis, double bbeta) {
430 HepLorentzVector vv (vec);
431 return vv.boost (aaxis, bbeta);