HepMC Reference Documentation

HepMC

SimpleVector.h

Go to the documentation of this file.
00001 
00002 // SimpleVector.h
00004 #ifndef  HEPMC_SIMPLEVECTOR_H
00005 #define  HEPMC_SIMPLEVECTOR_H
00006 
00008 // garren@fnal.gov, July 2006
00009 //
00010 // This header provides a place to hold the doubles which are part of one of 
00011 // three types of physics vectors:
00012 //    momentum 4 vector 
00013 //    position or displacement 4 vector
00014 //    position or displacement 3 vector
00015 //
00016 // For compatibility with existing code, 
00017 // the basic expected geometrical access methods are povided 
00018 // Also, both FourVector and ThreeVector have a templated constructor that will 
00019 // take another vector (HepLorentzVector, GenVector, ...)
00020 //    --> this vector must have the following methods: x(), y(), z()
00021 //    -->  FourVector also requires the t() method
00022 //
00024 
00025 
00026 #include "HepMC/enable_if.h"
00027 #include "HepMC/is_arithmetic.h"
00028 
00029 
00030 namespace HepMC {
00031 
00033 
00042 class FourVector {
00043 
00044 public:
00045 
00047   FourVector( double xin, double yin, double zin, double tin=0) 
00048   : m_x(xin), m_y(yin), m_z(zin), m_t(tin) {}
00049 
00051   FourVector(double t)
00052   : m_x(0), m_y(0), m_z(0), m_t(t) {}
00053 
00054   FourVector() 
00055   : m_x(0), m_y(0), m_z(0), m_t(0) {}
00056 
00059   template <class T >
00060   FourVector( const T& v,
00061          typename detail::disable_if< detail::is_arithmetic<T>::value, void >::type * = 0 )
00062   : m_x(v.x()), m_y(v.y()), m_z(v.z()), m_t(v.t()) {}
00063 
00065   FourVector(const FourVector & v)
00066   : m_x(v.x()), m_y(v.y()), m_z(v.z()), m_t(v.t()) {}
00067 
00068   void swap( FourVector & other );  
00069 
00070   double px() const { return m_x; }  
00071   double py() const { return m_y; }  
00072   double pz() const { return m_z; }  
00073   double e()  const { return m_t; }  
00074 
00075   double x() const { return m_x; }  
00076   double y() const { return m_y; }  
00077   double z() const { return m_z; }  
00078   double t() const { return m_t; }  
00079 
00080   double m2() const;  
00081   double m() const;   
00082 
00083   double perp2() const;  
00084   double perp() const;   
00085 
00086   // Get spatial vector components in spherical coordinate system.
00087   double theta() const;  
00088   double phi() const;  
00089   double rho() const;  
00090 
00091   FourVector & operator = (const FourVector &); 
00092 
00093   bool operator == (const FourVector &) const; 
00094   bool operator != (const FourVector &) const; 
00095 
00096   double pseudoRapidity() const;  
00097   double eta() const;             
00098 
00100   void set        (double x, double y, double z, double  t);
00101 
00102   void setX(double x) { m_x=x; }  
00103   void setY(double y) { m_y=y; }  
00104   void setZ(double z) { m_z=z; }  
00105   void setT(double t) { m_t=t; }  
00106 
00107   void setPx(double x) { m_x=x; }  
00108   void setPy(double y) { m_y=y; }  
00109   void setPz(double z) { m_z=z; }  
00110   void setE(double t)  { m_t=t; }  
00111 
00112 private:
00113 
00114   double m_x;
00115   double m_y;
00116   double m_z;
00117   double m_t;
00118   
00119 };
00120 
00122 
00131 class ThreeVector {
00132 
00133 public:
00134 
00136   ThreeVector( double xin, double yin =0, double zin =0 ) 
00137   : m_x(xin), m_y(yin), m_z(zin) {}
00138 
00139   ThreeVector( ) 
00140   : m_x(0), m_y(0), m_z(0) {}
00141   
00144   template <class T >
00145   ThreeVector( const T& v,
00146          typename detail::disable_if< detail::is_arithmetic<T>::value, void >::type * = 0 )
00147   : m_x(v.x()), m_y(v.y()), m_z(v.z()) {}
00148 
00150   ThreeVector(const ThreeVector & v)
00151   : m_x(v.x()), m_y(v.y()), m_z(v.z()) {}
00152 
00153   void swap( ThreeVector & other );  
00154 
00155   double x() const { return m_x; }  
00156   double y() const { return m_y; }  
00157   double z() const { return m_z; }  
00158 
00159   void setX(double x) { m_x=x; }  
00160   void setY(double y) { m_y=y; }  
00161   void setZ(double z) { m_z=z; }  
00162   void set( double x, double y, double z);   
00163 
00164   double phi()   const;  
00165   double theta() const;  
00166   double r()     const;  
00167 
00168   void setPhi(double);  
00169   void setTheta(double);  
00170 
00171   double perp2() const;  
00172   double perp() const;  
00173 
00174   ThreeVector & operator = (const ThreeVector &); 
00175 
00176   bool operator == (const ThreeVector &) const; 
00177   bool operator != (const ThreeVector &) const; 
00178 
00179 private:
00180 
00181   double m_x;
00182   double m_y;
00183   double m_z;
00184 
00185 };  
00186 
00187 
00188 } // HepMC
00189 
00190 #include "HepMC/SimpleVector.icc"
00191 
00192 #endif  // HEPMC_SIMPLEVECTOR_H
00193 

Generated on Thu Jan 7 13:10:16 2010 for HepMC by  doxygen 1.4.7