hepmc

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/trunk/ @ 385  →  /trunk/ @ 386
/trunk/test/testSimpleVector.cc
@@ -14,6 +14,7 @@
HepMC::ThreeVector v3copy( v3 );
double eps = 1.e-15; // allowed differnce between doubles
int numbad = 0;
double x = v3.x();
@@ -21,10 +22,11 @@
double z = v3.z();
double p2 = v3.perp2();
double pt = v3.perp();
double l = v3.mag();
double r = v3.r();
double th = v3.theta();
double ph = v3.phi();
double mag = std::sqrt(x*x + y*y + z*z);
double pperp = std::sqrt(x*x + y*y);
 
vx.set(1., 2., 3.);
vx.setX(1.1);
@@ -35,6 +37,17 @@
vector3 = v3;
 
if( fabs( mag - r ) > eps ) {
std::cout << "different ThreeVector magnitude: " << mag << " " << r << std::endl;
std::cout << "difference is : " << ( mag - r ) << std::endl;
++numbad;
}
if( fabs( pperp - pt ) > eps ) {
std::cout << "different ThreeVector Pt: " << pperp << " " << pt << std::endl;
std::cout << "difference is : " << ( pperp - pt ) << std::endl;
++numbad;
}
 
if( v3 == vector3 ) {
} else {
++numbad;
@@ -64,7 +77,6 @@
p2 = v4.perp2();
pt = v4.perp();
l = v4.mag();
th = v4.theta();
ph = v4.phi();
r = v4.rho();
@@ -87,6 +99,19 @@
vt.setPz(-1.1);
vt.setE(5.4);
 
mag = std::sqrt(x*x + y*y + z*z);
pperp = std::sqrt(x*x + y*y);
if( fabs( mag - r ) > eps ) {
std::cout << "different FourVector magnitude: " << mag << " " << r << std::endl;
std::cout << "difference is : " << ( mag - r ) << std::endl;
++numbad;
}
if( fabs( pperp - pt ) > eps ) {
std::cout << "different FourVector Pt: " << pperp << " " << pt << std::endl;
std::cout << "difference is : " << ( pperp - pt ) << std::endl;
++numbad;
}
 
if( px != x ) {
std::cout << "different X values: " << px << " " << x << std::endl;
++numbad;
@@ -103,20 +128,24 @@
std::cout << "different E values: " << e << " " << t << std::endl;
++numbad;
}
if( masssq1 != masssq2 ) {
if( fabs( masssq1 - masssq2 ) > eps ) {
std::cout << "different mass sq values: " << masssq1 << " " << masssq2 << std::endl;
std::cout << "difference is : " << ( masssq1 - masssq2 ) << std::endl;
++numbad;
}
if( mass1 != mass2 ) {
if( fabs( mass1 - mass2 ) > eps ) {
std::cout << "different mass values: " << mass1 << " " << mass2 << std::endl;
std::cout << "difference is : " << ( mass1 - mass2 ) << std::endl;
++numbad;
}
if( pr1 != pr2 ) {
std::cout << "different pr values: " << pr1 << " " << pr2 << std::endl;
if( fabs( pr1 - pr2 ) > eps ) {
std::cout << "different pseudorapidity values: " << pr1 << " " << pr2 << std::endl;
std::cout << "difference is : " << ( pr1 - pr2 ) << std::endl;
++numbad;
}
if( eta1 != eta2 ) {
if( fabs( eta1 - eta2 ) > eps ) {
std::cout << "different eta values: " << eta1 << " " << eta2 << std::endl;
std::cout << "difference is : " << ( eta1 - eta2 ) << std::endl;
++numbad;
}
if( v4 == vector ) {
/trunk/ChangeLog
@@ -1,3 +1,9 @@
 
2009-01-29 Lynn Garren
 
* HepMC/SimpleVector: remove FourVector::mag() and ThreeVector::mag()
Change test/testSimpleVector.cc to reflect this.
 
-------------------------- HepMC-2.04.01 --------------------------
 
2008-12-15 Lynn Garren
/trunk/HepMC/SimpleVector.icc
@@ -48,10 +48,6 @@
return mm < 0.0 ? -std::sqrt(-mm) : std::sqrt(mm);
}
 
inline double FourVector::mag() const {
return std::sqrt( m_x*m_x + m_y*m_y + m_z*m_z );
}
 
inline double FourVector::perp2() const { return m_x*m_x + m_y*m_y; }
 
inline double FourVector::perp() const { return std::sqrt(perp2()); }
@@ -77,7 +73,7 @@
}
 
inline double FourVector::pseudoRapidity() const {
double m = mag();
double m = std::sqrt( m_x*m_x + m_y*m_y + m_z*m_z );
if ( m== 0 ) return 0.0;
if ( m== z() ) return 1.0E72;
if ( m== -z() ) return -1.0E72;
@@ -105,12 +101,10 @@
return m_x == 0.0 && m_y == 0.0 ? 0.0 : std::atan2(m_y,m_x);
}
 
inline double ThreeVector::mag() const {
inline double ThreeVector::r() const {
return std::sqrt( m_x*m_x + m_y*m_y + m_z*m_z );
}
 
inline double ThreeVector::r() const { return mag(); }
 
inline void ThreeVector::set(double x, double y, double z) {
m_x = x;
m_y = y;
@@ -124,7 +118,7 @@
}
 
inline void ThreeVector::setTheta(double th) {
double ma = mag();
double ma = r();
double ph = phi();
setX(ma*std::sin(th)*std::cos(ph));
setY(ma*std::sin(th)*std::sin(ph));
/trunk/HepMC/SimpleVector.h
@@ -82,7 +82,6 @@
 
double perp2() const; //!< Transverse component of the spatial vector squared.
double perp() const; //!< Transverse component of the spatial vector (R in cylindrical system).
double mag() const; //!< Magnitude of the spatial vector
 
// Get spatial vector components in spherical coordinate system.
double theta() const; //!< The polar angle.
@@ -166,11 +165,9 @@
double theta() const; //!< The polar angle.
double r() const; //!< The magnitude
 
double mag() const; //!< The magnitude (r in spherical coordinate system).
void setPhi(double); //!< Set phi keeping magnitude and theta constant (BaBar).
void setTheta(double); //!< Set theta keeping magnitude and phi constant (BaBar).
 
void setPhi(double); //!< Set phi keeping mag and theta constant (BaBar).
void setTheta(double); //!< Set theta keeping mag and phi constant (BaBar).
 
double perp2() const; //!< The transverse component squared (rho^2 in cylindrical coordinate system).
double perp() const; //!< The transverse component (rho in cylindrical coordinate system).