2// ---------------------------------------------------------------------------
4// This file is a part of the CLHEP - a Class Library for High Energy Physics.
6// This is the definitions of the inline member functions of the
7// HepLorentzVector class.
14inline double HepLorentzVector::x() const { return pp.x(); }
15inline double HepLorentzVector::y() const { return pp.y(); }
16inline double HepLorentzVector::z() const { return pp.z(); }
17inline double HepLorentzVector::t() const { return ee; }
19inline HepLorentzVector::
20HepLorentzVector(double x1, double y1, double z1, double t1)
21 : pp(x1, y1, z1), ee(t1) {}
23inline HepLorentzVector:: HepLorentzVector(double x1, double y1, double z1)
24 : pp(x1, y1, z1), ee(0) {}
26inline HepLorentzVector:: HepLorentzVector(double t1)
27 : pp(0, 0, 0), ee(t1) {}
29inline HepLorentzVector:: HepLorentzVector()
30 : pp(0, 0, 0), ee(0) {}
32inline HepLorentzVector::HepLorentzVector(const Hep3Vector & p, double e1)
35inline HepLorentzVector::HepLorentzVector(double e1, const Hep3Vector & p)
38inline HepLorentzVector::HepLorentzVector(const HepLorentzVector & p)
39 : pp(p.x(), p.y(), p.z()), ee(p.t()) {}
41inline HepLorentzVector::~HepLorentzVector() {}
43inline HepLorentzVector::operator const Hep3Vector & () const {return pp;}
44inline HepLorentzVector::operator Hep3Vector & () { return pp; }
46inline void HepLorentzVector::setX(double a) { pp.setX(a); }
47inline void HepLorentzVector::setY(double a) { pp.setY(a); }
48inline void HepLorentzVector::setZ(double a) { pp.setZ(a); }
49inline void HepLorentzVector::setT(double a) { ee = a;}
51inline double HepLorentzVector::px() const { return pp.x(); }
52inline double HepLorentzVector::py() const { return pp.y(); }
53inline double HepLorentzVector::pz() const { return pp.z(); }
54inline double HepLorentzVector::e() const { return ee; }
56inline void HepLorentzVector::setPx(double a) { pp.setX(a); }
57inline void HepLorentzVector::setPy(double a) { pp.setY(a); }
58inline void HepLorentzVector::setPz(double a) { pp.setZ(a); }
59inline void HepLorentzVector::setE(double a) { ee = a;}
61inline Hep3Vector HepLorentzVector::vect() const { return pp; }
62inline void HepLorentzVector::setVect(const Hep3Vector &p) { pp = p; }
64inline double HepLorentzVector::theta() const { return pp.theta(); }
65inline double HepLorentzVector::cosTheta() const { return pp.cosTheta(); }
66inline double HepLorentzVector::phi() const { return pp.phi(); }
67inline double HepLorentzVector::rho() const { return pp.mag(); }
69inline void HepLorentzVector::setTheta(double a) { pp.setTheta(a); }
70inline void HepLorentzVector::setPhi(double a) { pp.setPhi(a); }
71inline void HepLorentzVector::setRho(double a) { pp.setMag(a); }
73double & HepLorentzVector::operator [] (int i) { return (*this)(i); }
74double HepLorentzVector::operator [] (int i) const { return (*this)(i); }
76inline HepLorentzVector &
77HepLorentzVector::operator = (const HepLorentzVector & q) {
83inline HepLorentzVector
84HepLorentzVector::operator + (const HepLorentzVector & q) const {
85 return HepLorentzVector(x()+q.x(), y()+q.y(), z()+q.z(), t()+q.t());
88inline HepLorentzVector &
89HepLorentzVector::operator += (const HepLorentzVector & q) {
95inline HepLorentzVector
96HepLorentzVector::operator - (const HepLorentzVector & q) const {
97 return HepLorentzVector(x()-q.x(), y()-q.y(), z()-q.z(), t()-q.t());
100inline HepLorentzVector &
101HepLorentzVector::operator -= (const HepLorentzVector & q) {
107inline HepLorentzVector HepLorentzVector::operator - () const {
108 return HepLorentzVector(-x(), -y(), -z(), -t());
111inline HepLorentzVector& HepLorentzVector::operator *= (double a) {
118HepLorentzVector::operator == (const HepLorentzVector & q) const {
119 return (vect()==q.vect() && t()==q.t());
123HepLorentzVector::operator != (const HepLorentzVector & q) const {
124 return (vect()!=q.vect() || t()!=q.t());
127inline double HepLorentzVector::perp2() const { return pp.perp2(); }
128inline double HepLorentzVector::perp() const { return pp.perp(); }
129inline void HepLorentzVector::setPerp(double a) { pp.setPerp(a); }
131inline double HepLorentzVector::perp2(const Hep3Vector &v1) const {
135inline double HepLorentzVector::perp(const Hep3Vector &v1) const {
139inline double HepLorentzVector::angle(const Hep3Vector &v1) const {
143inline double HepLorentzVector::mag2() const {
144 return metric*(t()*t() - pp.mag2());
147inline double HepLorentzVector::mag() const {
149 return mmm < 0.0 ? -std::sqrt(-mmm) : std::sqrt(mmm);
152inline double HepLorentzVector::m2() const {
153 return t()*t() - pp.mag2();
156inline double HepLorentzVector::m() const { return mag(); }
158inline double HepLorentzVector::mt2() const {
159 return e()*e() - pz()*pz();
162inline double HepLorentzVector::mt() const {
164 return mmm < 0.0 ? -std::sqrt(-mmm) : std::sqrt(mmm);
167inline double HepLorentzVector::et2() const {
168 double pt2 = pp.perp2();
169 return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+z()*z());
172inline double HepLorentzVector::et() const {
174 return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
177inline double HepLorentzVector::et2(const Hep3Vector & v1) const {
178 double pt2 = pp.perp2(v1);
179 double pv = pp.dot(v1.unit());
180 return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+pv*pv);
183inline double HepLorentzVector::et(const Hep3Vector & v1) const {
184 double etet = et2(v1);
185 return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
189HepLorentzVector::setVectMag(const Hep3Vector & spatial, double magnitude) {
191 setT(std::sqrt(magnitude * magnitude + spatial * spatial));
195HepLorentzVector::setVectM(const Hep3Vector & spatial, double mass) {
196 setVectMag(spatial, mass);
199inline double HepLorentzVector::dot(const HepLorentzVector & q) const {
200 return metric*(t()*q.t() - z()*q.z() - y()*q.y() - x()*q.x());
204HepLorentzVector::operator * (const HepLorentzVector & q) const {
208inline double HepLorentzVector::plus() const {
212inline double HepLorentzVector::minus() const {
216inline HepLorentzVector & HepLorentzVector::boost(const Hep3Vector & b) {
217 return boost(b.x(), b.y(), b.z());
220inline double HepLorentzVector::pseudoRapidity() const {
221 return pp.pseudoRapidity();
224inline double HepLorentzVector::eta() const {
225 return pp.pseudoRapidity();
228inline double HepLorentzVector::eta( const Hep3Vector & ref ) const {
229 return pp.eta( ref );
232inline HepLorentzVector &
233HepLorentzVector::operator *= (const HepRotation & m1) {
238inline HepLorentzVector &
239HepLorentzVector::transform(const HepRotation & m1) {
244inline HepLorentzVector operator * (const HepLorentzVector & p, double a) {
245 return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
248inline HepLorentzVector operator * (double a, const HepLorentzVector & p) {
249 return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
252// The following were added when ZOOM PhysicsVectors was merged in:
254inline HepLorentzVector::HepLorentzVector(
255 double x1, double y1, double z1, Tcomponent t1 ) :
256 pp(x1, y1, z1), ee(t1) {}
258inline void HepLorentzVector::set(
259 double x1, double y1, double z1, Tcomponent t1 ) {
264inline void HepLorentzVector::set(
265 double x1, double y1, double z1, double t1 ) {
266 set (x1,y1,z1,Tcomponent(t1));
269inline HepLorentzVector::HepLorentzVector(
270 Tcomponent t1, double x1, double y1, double z1 ) :
271 pp(x1, y1, z1), ee(t1) {}
273inline void HepLorentzVector::set(
274 Tcomponent t1, double x1, double y1, double z1 ) {
279inline void HepLorentzVector::set( Tcomponent t1 ) {
284inline void HepLorentzVector::set( double t1 ) {
289inline HepLorentzVector::HepLorentzVector( Tcomponent t1 ) :
290 pp(0, 0, 0), ee(t1) {}
292inline void HepLorentzVector::set( const Hep3Vector & v1 ) {
297inline HepLorentzVector::HepLorentzVector( const Hep3Vector & v1 ) :
300inline void HepLorentzVector::setV(const Hep3Vector & v1) {
304inline HepLorentzVector & HepLorentzVector::operator=(const Hep3Vector & v1) {
310inline double HepLorentzVector::getX() const { return pp.x(); }
311inline double HepLorentzVector::getY() const { return pp.y(); }
312inline double HepLorentzVector::getZ() const { return pp.z(); }
313inline double HepLorentzVector::getT() const { return ee; }
315inline Hep3Vector HepLorentzVector::getV() const { return pp; }
316inline Hep3Vector HepLorentzVector::v() const { return pp; }
318inline void HepLorentzVector::set(double t1, const Hep3Vector & v1) {
323inline void HepLorentzVector::set(const Hep3Vector & v1, double t1) {
328inline void HepLorentzVector::setV( double x1,
330 double z1 ) { pp.set(x1, y1, z1); }
332inline void HepLorentzVector::setRThetaPhi
333 ( double r, double ttheta, double phi1 )
334 { pp.setRThetaPhi( r, ttheta, phi1 ); }
336inline void HepLorentzVector::setREtaPhi
337 ( double r, double eta1, double phi1 )
338 { pp.setREtaPhi( r, eta1, phi1 ); }
340inline void HepLorentzVector::setRhoPhiZ
341 ( double rho1, double phi1, double z1 )
342 { pp.setRhoPhiZ ( rho1, phi1, z1 ); }
344inline bool HepLorentzVector::isTimelike() const {
345 return restMass2() > 0;
348inline bool HepLorentzVector::isSpacelike() const {
349 return restMass2() < 0;
352inline bool HepLorentzVector::isLightlike(double epsilon) const {
353 return std::fabs(restMass2()) < 2.0 * epsilon * ee * ee;
356inline double HepLorentzVector::diff2( const HepLorentzVector & w ) const {
357 return metric*( (ee-w.ee)*(ee-w.ee) - (pp-w.pp).mag2() );
360inline double HepLorentzVector::delta2Euclidean
361 ( const HepLorentzVector & w ) const {
362 return (ee-w.ee)*(ee-w.ee) + (pp-w.pp).mag2();
365inline double HepLorentzVector::euclideanNorm2() const {
366 return ee*ee + pp.mag2();
369inline double HepLorentzVector::euclideanNorm() const {
370 return std::sqrt(euclideanNorm2());
373inline double HepLorentzVector::restMass2() const { return m2(); }
374inline double HepLorentzVector::invariantMass2() const { return m2(); }
376inline double HepLorentzVector::restMass() const {
378// std::cerr << "HepLorentzVector::restMass() - "
379// << "E^2-p^2 < 0 for this particle. Magnitude returned."
381 return t() < 0.0 ? -m() : m();
384inline double HepLorentzVector::invariantMass() const {
386// std::cerr << "HepLorentzVector::invariantMass() - "
387// << "E^2-p^2 < 0 for this particle. Magnitude returned."
389 return t() < 0.0 ? -m() : m();
392inline double HepLorentzVector::invariantMass2
393 (const HepLorentzVector & w) const {
394 return (*this + w).m2();
395} /* invariantMass2 */
401// Each of these is a shell over a boost method.
403inline HepLorentzVector boostXOf
404 (const HepLorentzVector & vec, double bbeta) {
405 HepLorentzVector vv (vec);
406 return vv.boostX (bbeta);
409inline HepLorentzVector boostYOf
410 (const HepLorentzVector & vec, double bbeta) {
411 HepLorentzVector vv (vec);
412 return vv.boostY (bbeta);
415inline HepLorentzVector boostZOf
416 (const HepLorentzVector & vec, double bbeta) {
417 HepLorentzVector vv (vec);
418 return vv.boostZ (bbeta);
421inline HepLorentzVector boostOf
422 (const HepLorentzVector & vec, const Hep3Vector & betaVector ) {
423 HepLorentzVector vv (vec);
424 return vv.boost (betaVector);
427inline HepLorentzVector boostOf
428 (const HepLorentzVector & vec, const Hep3Vector & aaxis, double bbeta) {
429 HepLorentzVector vv (vec);
430 return vv.boost (aaxis, bbeta);