/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

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   double mag() const;    
00086 
00087   // Get spatial vector components in spherical coordinate system.
00088   double theta() const;  
00089   double phi() const;  
00090   double rho() const;  
00091 
00092   FourVector & operator = (const FourVector &); 
00093 
00094   bool operator == (const FourVector &) const; 
00095   bool operator != (const FourVector &) const; 
00096 
00097   double pseudoRapidity() const;  
00098   double eta() const;             
00099 
00101   void set        (double x, double y, double z, double  t);
00102 
00103   void setX(double x) { m_x=x; }  
00104   void setY(double y) { m_y=y; }  
00105   void setZ(double z) { m_z=z; }  
00106   void setT(double t) { m_t=t; }  
00107 
00108   void setPx(double x) { m_x=x; }  
00109   void setPy(double y) { m_y=y; }  
00110   void setPz(double z) { m_z=z; }  
00111   void setE(double t)  { m_t=t; }  
00112 
00113 private:
00114 
00115   double m_x;
00116   double m_y;
00117   double m_z;
00118   double m_t;
00119   
00120 };
00121 
00123 
00132 class ThreeVector {
00133 
00134 public:
00135 
00137   ThreeVector( double xin, double yin =0, double zin =0 ) 
00138   : m_x(xin), m_y(yin), m_z(zin) {}
00139 
00140   ThreeVector( ) 
00141   : m_x(0), m_y(0), m_z(0) {}
00142   
00145   template <class T >
00146   ThreeVector( const T& v,
00147          typename detail::disable_if< detail::is_arithmetic<T>::value, void >::type * = 0 )
00148   : m_x(v.x()), m_y(v.y()), m_z(v.z()) {}
00149 
00151   ThreeVector(const ThreeVector & v)
00152   : m_x(v.x()), m_y(v.y()), m_z(v.z()) {}
00153 
00154   void swap( ThreeVector & other );  
00155 
00156   double x() const { return m_x; }  
00157   double y() const { return m_y; }  
00158   double z() const { return m_z; }  
00159 
00160   void setX(double x) { m_x=x; }  
00161   void setY(double y) { m_y=y; }  
00162   void setZ(double z) { m_z=z; }  
00163   void set( double x, double y, double z);   
00164 
00165   double phi()   const;  
00166   double theta() const;  
00167   double r()     const;  
00168 
00169   double mag() const;  
00170 
00171   void setPhi(double);  
00172   void setTheta(double);  
00173 
00174   double perp2() const;  
00175   double perp() const;  
00176 
00177   ThreeVector & operator = (const ThreeVector &); 
00178 
00179   bool operator == (const ThreeVector &) const; 
00180   bool operator != (const ThreeVector &) const; 
00181 
00182 private:
00183 
00184   double m_x;
00185   double m_y;
00186   double m_z;
00187 
00188 };  
00189 
00190 
00191 } // HepMC
00192 
00193 #include "HepMC/SimpleVector.icc"
00194 
00195 #endif  // HEPMC_SIMPLEVECTOR_H
00196 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:49:37 for HepMC by doxygen 1.7.4