LCOV - code coverage report
Current view: top level - TEvtGen/HepMC - SimpleVector.icc (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 37 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 15 0.0 %

          Line data    Source code
       1             : //////////////////////////////////////////////////////////////////////////
       2             : // SimpleVector.icc
       3             : //////////////////////////////////////////////////////////////////////////
       4             : 
       5             : //////////////////////////////////////////////////////////////////////////
       6             : // garren@fnal.gov, July 2006
       7             : //
       8             : //
       9             : //////////////////////////////////////////////////////////////////////////
      10             : 
      11             : #include <cmath>
      12             : #include <algorithm>      // for swap
      13             : 
      14             : namespace HepMC {
      15             : 
      16             : //////////////////////////////////////////////////////////////////////////
      17             : //  FourVector inline methods
      18             : //////////////////////////////////////////////////////////////////////////
      19             : 
      20             : inline void FourVector::swap( FourVector & other ) {
      21           0 :     std::swap( m_x, other.m_x );
      22           0 :     std::swap( m_y, other.m_y );
      23           0 :     std::swap( m_z, other.m_z );
      24           0 :     std::swap( m_t, other.m_t );
      25           0 : }
      26             : 
      27             : inline FourVector & FourVector::operator=(const FourVector & v) {
      28           0 :   m_x = v.x();
      29           0 :   m_y = v.y();
      30           0 :   m_z = v.z();
      31           0 :   m_t = v.t();
      32           0 :   return *this;
      33             : }
      34             : 
      35             : inline void FourVector::set(double xin, double yin, double zin, double  tin) {
      36             :   m_x = xin;
      37             :   m_y = yin;
      38             :   m_z = zin;
      39             :   m_t = tin;
      40             : }
      41             : 
      42             : inline double FourVector::m2() const {
      43           0 :   return m_t*m_t - (m_x*m_x + m_y*m_y + m_z*m_z);
      44             : }
      45             : 
      46             : inline double FourVector::m() const {
      47           0 :   double mm = m2();
      48           0 :   return mm < 0.0 ? -std::sqrt(-mm) : std::sqrt(mm);
      49             : }
      50             : 
      51             : inline double FourVector::perp2() const { return m_x*m_x + m_y*m_y; }
      52             : 
      53             : inline double FourVector::perp() const { return std::sqrt(perp2()); }
      54             : 
      55             : inline double FourVector::theta() const  {
      56             :   return m_x == 0.0 && m_y == 0.0 && m_z == 0.0 ? 0.0 : std::atan2(perp(),m_z);
      57             : }
      58             : 
      59             : inline double FourVector::phi() const {
      60             :   return m_x == 0.0 && m_y == 0.0 ? 0.0 : std::atan2(m_y,m_x);
      61             : }
      62             : 
      63             : inline double  FourVector::rho() const { 
      64             : return std::sqrt( m_x*m_x + m_y*m_y + m_z*m_z );
      65             : }
      66             : 
      67             : inline bool FourVector::operator == (const FourVector & v) const {
      68           0 :   return (v.x()==x() && v.y()==y() && v.z()==z() && v.t()==t()) ? true : false;
      69             : }
      70             : 
      71             : inline bool FourVector::operator != (const FourVector & v) const {
      72           0 :   return (v.x()!=x() || v.y()!=y() || v.z()!=z() || v.t()!=t()) ? true : false;
      73             : }
      74             : 
      75             : inline double FourVector::pseudoRapidity() const {
      76           0 :   double m1 = std::sqrt( m_x*m_x + m_y*m_y + m_z*m_z );
      77           0 :   if ( m1==  0   ) return  0.0;   
      78           0 :   if ( m1==  z() ) return  1.0E72;
      79           0 :   if ( m1== -z() ) return -1.0E72;
      80           0 :   return 0.5*log( (m1+z())/(m1-z()) );
      81           0 : }
      82             : 
      83           0 : inline double FourVector::eta()    const { return pseudoRapidity();}
      84             : 
      85             : 
      86             : //////////////////////////////////////////////////////////////////////////
      87             : //  ThreeVector inline methods
      88             : //////////////////////////////////////////////////////////////////////////
      89             : 
      90             : inline void ThreeVector::swap( ThreeVector & other ) {
      91             :     std::swap( m_x, other.m_x );
      92             :     std::swap( m_y, other.m_y );
      93             :     std::swap( m_z, other.m_z );
      94             : }
      95             : 
      96             : inline double ThreeVector::theta() const         {
      97           0 :   return m_x == 0.0 && m_y == 0.0 && m_z == 0.0 ? 0.0 : std::atan2(perp(),m_z);
      98             : }
      99             : 
     100             : inline double ThreeVector::phi() const {
     101           0 :   return m_x == 0.0 && m_y == 0.0 ? 0.0 : std::atan2(m_y,m_x);
     102             : }
     103             : 
     104             : inline double ThreeVector::r()    const { 
     105           0 : return std::sqrt( m_x*m_x + m_y*m_y + m_z*m_z );
     106             : }
     107             : 
     108             : inline void ThreeVector::set(double xin, double yin, double zin) {
     109             :   m_x = xin;
     110             :   m_y = yin;
     111             :   m_z = zin;
     112             : }
     113             : 
     114             : inline void ThreeVector::setPhi(double ph) { 
     115           0 :   double xy   = perp();
     116           0 :   setX(xy*std::cos(ph));
     117           0 :   setY(xy*std::sin(ph));
     118           0 : }
     119             : 
     120             : inline void ThreeVector::setTheta(double th) { 
     121           0 :   double ma   = r();
     122           0 :   double ph   = phi();
     123           0 :   setX(ma*std::sin(th)*std::cos(ph));
     124           0 :   setY(ma*std::sin(th)*std::sin(ph));
     125           0 :   setZ(ma*std::cos(th));
     126           0 : }
     127             : 
     128           0 : inline double ThreeVector::perp2() const { return m_x*m_x + m_y*m_y; }
     129             : 
     130           0 : inline double ThreeVector::perp() const { return std::sqrt(perp2()); }
     131             : 
     132             : inline ThreeVector & ThreeVector::operator = (const ThreeVector & p) {
     133             :   m_x = p.x();
     134             :   m_y = p.y();
     135             :   m_z = p.z();
     136             :   return *this;
     137             : }
     138             : 
     139             : 
     140             : inline bool ThreeVector::operator == (const ThreeVector& v) const {
     141             :   return (v.x()==x() && v.y()==y() && v.z()==z()) ? true : false;
     142             : }
     143             : 
     144             : inline bool ThreeVector::operator != (const ThreeVector& v) const {
     145             :   return (v.x()!=x() || v.y()!=y() || v.z()!=z()) ? true : false;
     146             : }
     147             : 
     148             : } // HepMC

Generated by: LCOV version 1.11