LorentzVector.icc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id:$
00003 // ---------------------------------------------------------------------------
00004 //
00005 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
00006 // 
00007 // This is the definitions of the inline member functions of the
00008 // HepLorentzVector class.
00009 //
00010 
00011 #include <cmath>
00012 
00013 namespace CLHEP {
00014 
00015 inline double HepLorentzVector::x() const { return pp.x(); }
00016 inline double HepLorentzVector::y() const { return pp.y(); }
00017 inline double HepLorentzVector::z() const { return pp.z(); }
00018 inline double HepLorentzVector::t() const { return ee; }
00019 
00020 inline HepLorentzVector::
00021 HepLorentzVector(double x1, double y1, double z1, double t1)
00022   : pp(x1, y1, z1), ee(t1) {}
00023 
00024 inline HepLorentzVector:: HepLorentzVector(double x1, double y1, double z1)
00025   : pp(x1, y1, z1), ee(0) {}
00026 
00027 inline HepLorentzVector:: HepLorentzVector(double t1)
00028   : pp(0, 0, 0), ee(t1) {}
00029 
00030 inline HepLorentzVector:: HepLorentzVector()
00031   : pp(0, 0, 0), ee(0) {}
00032 
00033 inline HepLorentzVector::HepLorentzVector(const Hep3Vector & p, double e1)
00034   : pp(p), ee(e1) {}
00035 
00036 inline HepLorentzVector::HepLorentzVector(double e1, const Hep3Vector & p)
00037   : pp(p), ee(e1) {}
00038 
00039 inline HepLorentzVector::HepLorentzVector(const HepLorentzVector & p)
00040   : pp(p.x(), p.y(), p.z()), ee(p.t()) {}
00041 
00042 inline HepLorentzVector::~HepLorentzVector() {}
00043 
00044 inline HepLorentzVector::operator const Hep3Vector & () const {return pp;}
00045 inline HepLorentzVector::operator Hep3Vector & () { return pp; }
00046 
00047 inline void HepLorentzVector::setX(double a) { pp.setX(a); } 
00048 inline void HepLorentzVector::setY(double a) { pp.setY(a); }
00049 inline void HepLorentzVector::setZ(double a) { pp.setZ(a); }
00050 inline void HepLorentzVector::setT(double a) { ee = a;}
00051 
00052 inline double HepLorentzVector::px() const { return pp.x(); }
00053 inline double HepLorentzVector::py() const { return pp.y(); }
00054 inline double HepLorentzVector::pz() const { return pp.z(); }
00055 inline double HepLorentzVector::e()  const { return ee; }
00056 
00057 inline void HepLorentzVector::setPx(double a) { pp.setX(a); } 
00058 inline void HepLorentzVector::setPy(double a) { pp.setY(a); }
00059 inline void HepLorentzVector::setPz(double a) { pp.setZ(a); }
00060 inline void HepLorentzVector::setE(double a)  { ee = a;}
00061 
00062 inline Hep3Vector HepLorentzVector::vect() const { return pp; } 
00063 inline void HepLorentzVector::setVect(const Hep3Vector &p) { pp = p; } 
00064 
00065 inline double HepLorentzVector::theta() const { return pp.theta(); }
00066 inline double HepLorentzVector::cosTheta() const { return pp.cosTheta(); }
00067 inline double HepLorentzVector::phi() const { return pp.phi(); }
00068 inline double HepLorentzVector::rho() const { return pp.mag(); }
00069 
00070 inline void HepLorentzVector::setTheta(double a) { pp.setTheta(a); }
00071 inline void HepLorentzVector::setPhi(double a) { pp.setPhi(a); }
00072 inline void HepLorentzVector::setRho(double a) { pp.setMag(a); }
00073 
00074 double & HepLorentzVector::operator [] (int i)       { return (*this)(i); }
00075 double   HepLorentzVector::operator [] (int i) const { return (*this)(i); }
00076 
00077 inline HepLorentzVector &
00078 HepLorentzVector::operator = (const HepLorentzVector & q) {
00079   pp = q.vect();
00080   ee = q.t();
00081   return *this;
00082 }
00083 
00084 inline HepLorentzVector
00085 HepLorentzVector::operator + (const HepLorentzVector & q) const {
00086   return HepLorentzVector(x()+q.x(), y()+q.y(), z()+q.z(), t()+q.t());
00087 }
00088 
00089 inline HepLorentzVector &
00090 HepLorentzVector::operator += (const HepLorentzVector & q) {
00091   pp += q.vect();
00092   ee += q.t();
00093   return *this;
00094 }
00095 
00096 inline HepLorentzVector
00097 HepLorentzVector::operator - (const HepLorentzVector & q) const {
00098   return HepLorentzVector(x()-q.x(), y()-q.y(), z()-q.z(), t()-q.t());
00099 }
00100 
00101 inline HepLorentzVector &
00102 HepLorentzVector::operator -= (const HepLorentzVector & q) {
00103   pp -= q.vect();
00104   ee -= q.t();
00105   return *this;
00106 }
00107 
00108 inline HepLorentzVector HepLorentzVector::operator - () const {
00109   return HepLorentzVector(-x(), -y(), -z(), -t());
00110 }
00111 
00112 inline HepLorentzVector& HepLorentzVector::operator *= (double a) {
00113   pp *= a;
00114   ee *= a;
00115   return *this;
00116 }
00117 
00118 inline bool
00119 HepLorentzVector::operator == (const HepLorentzVector & q) const {
00120   return (vect()==q.vect() && t()==q.t());
00121 }
00122 
00123 inline bool
00124 HepLorentzVector::operator != (const HepLorentzVector & q) const {
00125   return (vect()!=q.vect() || t()!=q.t());
00126 }
00127 
00128 inline double HepLorentzVector::perp2() const   { return pp.perp2(); }
00129 inline double HepLorentzVector::perp()  const   { return pp.perp(); }
00130 inline void HepLorentzVector::setPerp(double a) { pp.setPerp(a); }
00131 
00132 inline double HepLorentzVector::perp2(const Hep3Vector &v1) const {
00133   return pp.perp2(v1);
00134 }
00135 
00136 inline double HepLorentzVector::perp(const Hep3Vector &v1) const {
00137   return pp.perp(v1);
00138 }
00139 
00140 inline double HepLorentzVector::angle(const Hep3Vector &v1) const {
00141   return pp.angle(v1);
00142 }
00143 
00144 inline double HepLorentzVector::mag2() const {
00145   return metric*(t()*t() - pp.mag2());
00146 }
00147 
00148 inline double HepLorentzVector::mag() const {
00149   double mmm = m2();
00150   return mmm < 0.0 ? -std::sqrt(-mmm) : std::sqrt(mmm);
00151 }
00152 
00153 inline double HepLorentzVector::m2() const { 
00154   return t()*t() - pp.mag2();
00155 }
00156 
00157 inline double HepLorentzVector::m() const { return mag(); }
00158 
00159 inline double HepLorentzVector::mt2() const {
00160   return e()*e() - pz()*pz();
00161 }
00162 
00163 inline double HepLorentzVector::mt() const {
00164   double mmm = mt2();
00165   return mmm < 0.0 ? -std::sqrt(-mmm) : std::sqrt(mmm);
00166 }
00167 
00168 inline double HepLorentzVector::et2() const {
00169   double pt2 = pp.perp2();
00170   return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+z()*z());
00171 }
00172 
00173 inline double HepLorentzVector::et() const {
00174   double etet = et2();
00175   return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
00176 }
00177 
00178 inline double HepLorentzVector::et2(const Hep3Vector & v1) const {
00179   double pt2 = pp.perp2(v1);
00180   double pv = pp.dot(v1.unit());
00181   return pt2 == 0 ? 0 : e()*e() * pt2/(pt2+pv*pv);
00182 }
00183 
00184 inline double HepLorentzVector::et(const Hep3Vector & v1) const {
00185   double etet = et2(v1);
00186   return e() < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
00187 }
00188 
00189 inline void 
00190 HepLorentzVector::setVectMag(const Hep3Vector & spatial, double magnitude) {
00191   setVect(spatial);
00192   setT(std::sqrt(magnitude * magnitude + spatial * spatial));
00193 }
00194 
00195 inline void 
00196 HepLorentzVector::setVectM(const Hep3Vector & spatial, double mass) {
00197   setVectMag(spatial, mass);
00198 }
00199 
00200 inline double HepLorentzVector::dot(const HepLorentzVector & q) const {
00201   return metric*(t()*q.t() - z()*q.z() - y()*q.y() - x()*q.x());
00202 }
00203 
00204 inline double
00205 HepLorentzVector::operator * (const HepLorentzVector & q) const {
00206   return dot(q);
00207 }
00208 
00209 inline double HepLorentzVector::plus() const {
00210   return t() + z();
00211 }
00212 
00213 inline double HepLorentzVector::minus() const {
00214   return t() - z();
00215 }
00216 
00217 inline HepLorentzVector & HepLorentzVector::boost(const Hep3Vector & b) {
00218   return boost(b.x(), b.y(), b.z());
00219 }
00220 
00221 inline double HepLorentzVector::pseudoRapidity() const {
00222   return pp.pseudoRapidity();
00223 }
00224 
00225 inline double HepLorentzVector::eta() const {
00226   return pp.pseudoRapidity();
00227 }
00228 
00229 inline double HepLorentzVector::eta( const Hep3Vector & ref ) const {
00230   return pp.eta( ref );
00231 }
00232 
00233 inline HepLorentzVector &
00234 HepLorentzVector::operator *= (const HepRotation & m1) {
00235   pp.transform(m1);
00236   return *this;
00237 }
00238 
00239 inline HepLorentzVector &
00240 HepLorentzVector::transform(const HepRotation & m1) {
00241   pp.transform(m1);
00242   return *this;
00243 }
00244 
00245 inline HepLorentzVector operator * (const HepLorentzVector & p, double a) {
00246   return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
00247 }
00248 
00249 inline HepLorentzVector operator * (double a, const HepLorentzVector & p) {
00250   return HepLorentzVector(a*p.x(), a*p.y(), a*p.z(), a*p.t());
00251 }
00252 
00253 // The following were added when ZOOM PhysicsVectors was merged in:
00254 
00255 inline HepLorentzVector::HepLorentzVector( 
00256         double x1, double y1, double z1, Tcomponent t1 ) :
00257         pp(x1, y1, z1), ee(t1) {}
00258 
00259 inline void HepLorentzVector::set(
00260         double x1, double y1, double z1, Tcomponent t1 ) {
00261   pp.set(x1,y1,z1);
00262   ee = t1;
00263 }
00264 
00265 inline void HepLorentzVector::set(
00266         double x1, double y1, double z1, double t1 ) {
00267   set (x1,y1,z1,Tcomponent(t1));
00268 }
00269 
00270 inline HepLorentzVector::HepLorentzVector( 
00271         Tcomponent t1, double x1, double y1, double z1 ) :
00272         pp(x1, y1, z1), ee(t1) {}   
00273 
00274 inline void HepLorentzVector::set(
00275         Tcomponent t1, double x1, double y1, double z1 ) {
00276   pp.set(x1,y1,z1);
00277   ee = t1;
00278 }
00279 
00280 inline void HepLorentzVector::set( Tcomponent t1 ) {
00281   pp.set(0, 0, 0);
00282   ee = t1;
00283 }
00284 
00285 inline void HepLorentzVector::set( double t1 ) {
00286   pp.set(0, 0, 0);
00287   ee = t1;
00288 }
00289 
00290 inline HepLorentzVector::HepLorentzVector( Tcomponent t1 ) : 
00291         pp(0, 0, 0), ee(t1) {}
00292 
00293 inline void HepLorentzVector::set( const Hep3Vector & v1 ) {
00294   pp = v1;
00295   ee = 0;
00296 }
00297 
00298 inline HepLorentzVector::HepLorentzVector( const Hep3Vector & v1 ) : 
00299         pp(v1), ee(0) {}
00300 
00301 inline void HepLorentzVector::setV(const Hep3Vector & v1) {
00302   pp = v1;
00303 }
00304 
00305 inline HepLorentzVector & HepLorentzVector::operator=(const Hep3Vector & v1) {
00306   pp = v1;
00307   ee = 0;
00308   return *this;
00309 }
00310 
00311 inline double HepLorentzVector::getX() const { return pp.x(); }
00312 inline double HepLorentzVector::getY() const { return pp.y(); }
00313 inline double HepLorentzVector::getZ() const { return pp.z(); }
00314 inline double HepLorentzVector::getT() const { return ee; }
00315 
00316 inline Hep3Vector HepLorentzVector::getV() const { return pp; } 
00317 inline Hep3Vector HepLorentzVector::v() const { return pp; } 
00318 
00319 inline void HepLorentzVector::set(double t1, const Hep3Vector & v1) {
00320   pp = v1;
00321   ee = t1;
00322 }
00323 
00324 inline void HepLorentzVector::set(const Hep3Vector & v1, double t1) {
00325   pp = v1;
00326   ee = t1;
00327 }
00328 
00329 inline void HepLorentzVector::setV( double x1,
00330              double y1,
00331              double z1 ) { pp.set(x1, y1, z1); }
00332 
00333 inline void HepLorentzVector::setRThetaPhi 
00334                 ( double r1, double theta1, double phi1 ) 
00335                          { pp.setRThetaPhi( r1, theta1, phi1 ); }
00336 
00337 inline void HepLorentzVector::setREtaPhi 
00338                 ( double r1, double eta1, double phi1 ) 
00339                          { pp.setREtaPhi( r1, eta1, phi1 ); }
00340 
00341 inline void HepLorentzVector::setRhoPhiZ
00342                 ( double rho1, double phi1, double z1 )
00343                          { pp.setRhoPhiZ ( rho1, phi1, z1 ); }
00344 
00345 inline bool HepLorentzVector::isTimelike() const {
00346   return restMass2() > 0;
00347 }  
00348 
00349 inline bool  HepLorentzVector::isSpacelike() const {
00350   return restMass2() < 0;
00351 }
00352 
00353 inline bool  HepLorentzVector::isLightlike(double epsilon) const {
00354   return std::fabs(restMass2()) < 2.0 * epsilon * ee * ee;
00355 }
00356 
00357 inline double HepLorentzVector::diff2( const HepLorentzVector & w ) const {
00358     return metric*( (ee-w.ee)*(ee-w.ee) - (pp-w.pp).mag2() );
00359 }
00360 
00361 inline double HepLorentzVector::delta2Euclidean 
00362                                         ( const HepLorentzVector & w ) const {
00363     return (ee-w.ee)*(ee-w.ee) + (pp-w.pp).mag2();
00364 }
00365 
00366 inline double HepLorentzVector::euclideanNorm2()  const {
00367   return ee*ee + pp.mag2();
00368 }
00369 
00370 inline double HepLorentzVector::euclideanNorm()  const {
00371   return std::sqrt(euclideanNorm2());
00372 }
00373 
00374 inline double HepLorentzVector::restMass2()      const { return m2(); }
00375 inline double HepLorentzVector::invariantMass2() const { return m2(); }
00376 
00377 inline double HepLorentzVector::restMass() const {
00378 //    if( t() < 0.0 )
00379 //      std::cerr << "HepLorentzVector::restMass() - "
00380 //                << "E^2-p^2 < 0 for this particle. Magnitude returned."
00381 //                << std::endl;
00382     return t() < 0.0 ? -m() : m();
00383 }
00384 
00385 inline double HepLorentzVector::invariantMass() const {
00386 //    if( t() < 0.0 )
00387 //      std::cerr << "HepLorentzVector::invariantMass() - "
00388 //                << "E^2-p^2 < 0 for this particle. Magnitude returned."
00389 //                << std::endl;
00390     return t() < 0.0 ? -m() : m();
00391 }
00392 
00393 inline double HepLorentzVector::invariantMass2
00394                                         (const HepLorentzVector & w) const {
00395   return (*this + w).m2();
00396 } /* invariantMass2 */
00397 
00398 //-*********
00399 // boostOf()
00400 //-*********
00401 
00402 // Each of these is a shell over a boost method.
00403 
00404 inline HepLorentzVector boostXOf
00405         (const HepLorentzVector & vec, double bbeta) {
00406   HepLorentzVector vv (vec);
00407   return vv.boostX (bbeta);
00408 }
00409 
00410 inline HepLorentzVector boostYOf
00411         (const HepLorentzVector & vec, double bbeta) {
00412   HepLorentzVector vv (vec);
00413   return vv.boostY (bbeta);
00414 }
00415 
00416 inline HepLorentzVector boostZOf
00417         (const HepLorentzVector & vec, double bbeta) {
00418   HepLorentzVector vv (vec);
00419   return vv.boostZ (bbeta);
00420 }
00421 
00422 inline HepLorentzVector boostOf
00423         (const HepLorentzVector & vec, const Hep3Vector & betaVector ) {
00424   HepLorentzVector vv (vec);
00425   return vv.boost (betaVector);
00426 }
00427 
00428 inline HepLorentzVector boostOf
00429     (const HepLorentzVector & vec, const Hep3Vector & aaxis,  double bbeta) {
00430   HepLorentzVector vv (vec);
00431   return vv.boost (aaxis, bbeta);
00432 }
00433 
00434 }  // namespace CLHEP

Generated on Mon May 27 17:50:31 2013 for Geant4 by  doxygen 1.4.7