Commit a7ba75d9 authored by Lynn Garren's avatar Lynn Garren

merging Mark Fischler's Vector changes (not yet tested)

parent b7d488e4
Fri Oct 10 2003 Mark Fischler <mf@fnal.gov>
* ZMxpv.h and ZMxpv.cc
Modified the ZZMthrowA and ZMthrowC macros such that the package
never calls exit(), throwing an exception instead. Existing code
in entire package was already instrumented to throw the various
exceptions.
* Boost.h and Boost.icc and Boost.cc
Correct a typo in Boost::vectorMutiplication() [that is, boost*4vector].
This affected off-axis boosts applied to a LorentzVector when the
x- and/or y- components of both the Boost and the LorentzVector are
not small. Boosts in the z-direction are unaffected and Boosts
dominantly in the z-direction suffered only second-order effects.
Repair a bug in LorentzVector::deltaR() which could return large
values when the phi values are close to + and - pi respectively,
for two vectors which are actually near each other.
Rectify misbehaviour when isNear() is taken between a specialized
or general Boost and a general LorentzRotation.
Supply output operator.
* BoostX.cc, BoostY.cc, BoostZ.cc
Rectify misbehaviour when isNear() is taken between a specialized
or general Boost and a general LorentzRotation.
Supply output operators.
* LorentzRotation.cc
Multiplication by specialized rotations
More efficient multiplicatio by a rotation
*LorentzVectorC.cc
Correction in isNear for two vectors both close to -Z axis.
* RotationE.cc
Methods to find EUler angles phi() and psi() now forgiving of
cos phi apparently slightly above 1 due to roundoff error.
Fri Oct 10 2003 Lynn Garren <garren@fnal.gov>
* HepMC 1.24 changes merged with CLHEP/HepMC
Tue Jul 22 17:40:39 CDT 2003 Lynn Garren <garren@fnal.gov>
* Alpha release of the CLHEP split
......
......@@ -70,6 +70,13 @@ public:
inline HepBoost (const Hep3Vector & boost);
// Constructor from a 3-vector of less than unit length
inline HepBoost & set (const HepBoostX & boost);
inline HepBoost & set (const HepBoostY & boost);
inline HepBoost & set (const HepBoostZ & boost);
inline HepBoost (const HepBoostX & boost);
inline HepBoost (const HepBoostY & boost);
inline HepBoost (const HepBoostZ & boost);
// ---------- Accessors:
inline double beta() const;
......@@ -229,6 +236,10 @@ protected:
}; // HepBoost
inline
std::ostream & operator <<
( std::ostream & os, const HepBoost& b ) {return b.print(os);}
} // namespace CLHEP
#include "CLHEP/Vector/Boost.icc"
......
......@@ -46,6 +46,16 @@ inline HepBoost::HepBoost(const Hep3Vector & boost)
set(boost.x(), boost.y(), boost.z());
}
inline HepBoost::HepBoost(const HepBoostX & boost) {set(boost.boostVector());}
inline HepBoost::HepBoost(const HepBoostY & boost) {set(boost.boostVector());}
inline HepBoost::HepBoost(const HepBoostZ & boost) {set(boost.boostVector());}
inline HepBoost & HepBoost::set(const HepBoostX & boost)
{return set(boost.boostVector());}
inline HepBoost & HepBoost::set(const HepBoostY & boost)
{return set(boost.boostVector());}
inline HepBoost & HepBoost::set(const HepBoostZ & boost)
{return set(boost.boostVector());}
// - Protected method:
inline HepBoost::HepBoost (
double xx, double xy, double xz, double xt,
......@@ -229,8 +239,8 @@ HepBoost::vectorMultiplication(const HepLorentzVector & p) const {
register double t = p.t();
return HepLorentzVector( rep_.xx_*x + rep_.xy_*y + rep_.xz_*z + rep_.xt_*t,
rep_.xy_*x + rep_.yy_*y + rep_.yz_*z + rep_.yt_*t,
rep_.xz_*x + rep_.xz_*y + rep_.zz_*z + rep_.zt_*t,
rep_.xt_*x + rep_.xt_*y + rep_.xt_*z + rep_.tt_*t);
rep_.xz_*x + rep_.yz_*y + rep_.zz_*z + rep_.zt_*t,
rep_.xt_*x + rep_.yt_*y + rep_.zt_*z + rep_.tt_*t);
}
inline HepLorentzVector
......
......@@ -167,7 +167,7 @@ public:
// ---------- Operations in the group of 4-Rotations
inline HepBoostX operator * (const HepBoostX & b) const;
HepBoostX operator * (const HepBoostX & b) const;
HepLorentzRotation operator * (const HepBoost & b) const;
HepLorentzRotation operator * (const HepRotation & r) const;
HepLorentzRotation operator * (const HepLorentzRotation & lt) const;
......@@ -210,6 +210,10 @@ protected:
}; // HepBoostX
inline
std::ostream & operator <<
( std::ostream & os, const HepBoostX& b ) {return b.print(os);}
} // namespace CLHEP
#include "CLHEP/Vector/BoostX.icc"
......
......@@ -168,7 +168,7 @@ public:
// ---------- Operations in the group of 4-Rotations
inline HepBoostY operator * (const HepBoostY & b) const;
HepBoostY operator * (const HepBoostY & b) const;
HepLorentzRotation operator * (const HepBoost & b) const;
HepLorentzRotation operator * (const HepRotation & r) const;
HepLorentzRotation operator * (const HepLorentzRotation & lt) const;
......@@ -211,6 +211,10 @@ protected:
}; // HepBoostY
inline
std::ostream & operator <<
( std::ostream & os, const HepBoostY& b ) {return b.print(os);}
} // namespace CLHEP
#include "CLHEP/Vector/BoostY.icc"
......
......@@ -167,7 +167,7 @@ public:
// ---------- Operations in the group of 4-Rotations
inline HepBoostZ operator * (const HepBoostZ & b) const;
HepBoostZ operator * (const HepBoostZ & b) const;
HepLorentzRotation operator * (const HepBoost & b) const;
HepLorentzRotation operator * (const HepRotation & r) const;
HepLorentzRotation operator * (const HepLorentzRotation & lt) const;
......@@ -210,6 +210,10 @@ protected:
}; // HepBoostZ
inline
std::ostream & operator <<
( std::ostream & os, const HepBoostZ& b ) {return b.print(os);}
} // namespace CLHEP
#include "CLHEP/Vector/BoostZ.icc"
......
......@@ -104,7 +104,7 @@ namespace zmpv {
typedef CLHEP::HepEulerAngles EulerAngles;
} // namespace zmpv
} // end of namespace zmpv
#define EULERANGLES_ICC
#include "CLHEP/Vector/EulerAngles.icc"
......
// -*- C++ -*-
// CLASSDOC OFF
// $Id: LorentzRotation.h,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// $Id: LorentzRotation.h,v 1.2 2003/10/10 21:42:35 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -66,7 +66,13 @@ public:
// Copy constructor.
inline HepLorentzRotation (const HepRotation & r);
inline explicit HepLorentzRotation (const HepRotationX & r);
inline explicit HepLorentzRotation (const HepRotationY & r);
inline explicit HepLorentzRotation (const HepRotationZ & r);
inline HepLorentzRotation (const HepBoost & b);
inline explicit HepLorentzRotation (const HepBoostX & b);
inline explicit HepLorentzRotation (const HepBoostY & b);
inline explicit HepLorentzRotation (const HepBoostZ & b);
// Constructors from special cases.
inline HepLorentzRotation & operator = (const HepLorentzRotation & m);
......@@ -76,7 +82,14 @@ public:
HepLorentzRotation & set (double bx, double by, double bz);
inline HepLorentzRotation & set (const Hep3Vector & p);
inline HepLorentzRotation & set (const HepRotation & r);
inline HepLorentzRotation & set (const HepRotationX & r);
inline HepLorentzRotation & set (const HepRotationY & r);
inline HepLorentzRotation & set (const HepRotationZ & r);
inline HepLorentzRotation & set (const HepBoost & boost);
inline HepLorentzRotation & set (const HepBoostX & boost);
inline HepLorentzRotation & set (const HepBoostY & boost);
inline HepLorentzRotation & set (const HepBoostZ & boost);
inline HepLorentzRotation (double bx, double by, double bz);
inline HepLorentzRotation (const Hep3Vector & p);
// Other Constructors giving a Lorentz-boost.
......@@ -295,10 +308,6 @@ public:
inline HepLorentzRotation inverse() const;
// Return the inverse.
inline friend HepLorentzRotation inverseOf
( const Hep4RotationInterface & lt );
// global method to invert.
inline HepLorentzRotation & invert();
// Inverts the LorentzRotation matrix.
......@@ -335,6 +344,36 @@ protected:
}; // HepLorentzRotation
inline std::ostream & operator<<
( std::ostream & os, const HepLorentzRotation& lt )
{return lt.print(os);}
inline bool operator==(const HepRotation &r, const HepLorentzRotation & lt)
{ return lt==r; }
inline bool operator!=(const HepRotation &r, const HepLorentzRotation & lt)
{ return lt!=r; }
inline bool operator<=(const HepRotation &r, const HepLorentzRotation & lt)
{ return lt<=r; }
inline bool operator>=(const HepRotation &r, const HepLorentzRotation & lt)
{ return lt>=r; }
inline bool operator<(const HepRotation &r, const HepLorentzRotation & lt)
{ return lt<r; }
inline bool operator>(const HepRotation &r, const HepLorentzRotation & lt)
{ return lt>r; }
inline bool operator==(const HepBoost &b, const HepLorentzRotation & lt)
{ return lt==b; }
inline bool operator!=(const HepBoost &b, const HepLorentzRotation & lt)
{ return lt!=b; }
inline bool operator<=(const HepBoost &b, const HepLorentzRotation & lt)
{ return lt<=b; }
inline bool operator>=(const HepBoost &b, const HepLorentzRotation & lt)
{ return lt>=b; }
inline bool operator<(const HepBoost &b, const HepLorentzRotation & lt)
{ return lt<b; }
inline bool operator>(const HepBoost &b, const HepLorentzRotation & lt)
{ return lt>b; }
} // namespace CLHEP
#include "CLHEP/Vector/LorentzRotation.icc"
......
// -*- C++ -*-
// $Id: LorentzRotation.icc,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// $Id: LorentzRotation.icc,v 1.2 2003/10/10 21:42:35 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -27,10 +27,28 @@ inline HepLorentzRotation::HepLorentzRotation(const HepLorentzRotation & r) :
inline HepLorentzRotation::HepLorentzRotation(const HepRotation & r) {
set (r.rep4x4());
}
inline HepLorentzRotation::HepLorentzRotation(const HepRotationX & r) {
set (r.rep4x4());
}
inline HepLorentzRotation::HepLorentzRotation(const HepRotationY & r) {
set (r.rep4x4());
}
inline HepLorentzRotation::HepLorentzRotation(const HepRotationZ & r) {
set (r.rep4x4());
}
inline HepLorentzRotation::HepLorentzRotation(const HepBoost & b) {
set (b.rep4x4());
}
inline HepLorentzRotation::HepLorentzRotation(const HepBoostX & b) {
set (b.rep4x4());
}
inline HepLorentzRotation::HepLorentzRotation(const HepBoostY & b) {
set (b.rep4x4());
}
inline HepLorentzRotation::HepLorentzRotation(const HepBoostZ & b) {
set (b.rep4x4());
}
inline HepLorentzRotation &
HepLorentzRotation::operator = (const HepLorentzRotation & r) {
......@@ -55,9 +73,31 @@ HepLorentzRotation & HepLorentzRotation::set (const Hep3Vector & p) {
return set (p.x(), p.y(), p.z());
}
inline HepLorentzRotation & HepLorentzRotation::set (const HepRotation & r) {
return set (r.rep4x4());
}
inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationX & r) {
return set (r.rep4x4());
}
inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationY & r) {
return set (r.rep4x4());
}
inline HepLorentzRotation & HepLorentzRotation::set (const HepRotationZ & r) {
return set (r.rep4x4());
}
inline HepLorentzRotation & HepLorentzRotation::set (const HepBoost & boost) {
return set (boost.rep4x4());
}
inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostX & boost) {
return set (boost.rep4x4());
}
inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostY & boost) {
return set (boost.rep4x4());
}
inline HepLorentzRotation & HepLorentzRotation::set (const HepBoostZ & boost) {
return set (boost.rep4x4());
}
inline HepLorentzRotation::HepLorentzRotation(double bx,
double by,
......
// -*- C++ -*-
// $Id: LorentzVector.icc,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// $Id: LorentzVector.icc,v 1.2 2003/10/10 21:42:35 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -234,7 +234,7 @@ inline double HepLorentzVector::eta( const Hep3Vector & ref ) const {
inline HepLorentzVector &
HepLorentzVector::operator *= (const HepRotation & m) {
pp *= m;
pp.transform(m);
return *this;
}
......
// -*- C++ -*-
// CLASSDOC OFF
// $Id: Rotation.h,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// $Id: Rotation.h,v 1.2 2003/10/10 21:42:35 garren Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
......@@ -405,6 +405,10 @@ private:
Hep3Vector & v3) const;
}; // HepRotation
inline
std::ostream & operator <<
( std::ostream & os, const HepRotation & r ) {return r.print(os);}
} // namespace CLHEP
#include "CLHEP/Vector/Rotation.icc"
......
// -*- C++ -*-
// $Id: Rotation.icc,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// $Id: Rotation.icc,v 1.2 2003/10/10 21:42:35 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -342,7 +342,7 @@ inline HepRotation operator * (const HepRotationZ & rz, const HepRotation & r){
double s = rz.yx();
return HepRotation ( c*m.xx_-s*m.yx_, c*m.xy_-s*m.yy_, c*m.xz_-s*m.yz_,
s*m.xx_+c*m.yx_, s*m.xy_+c*m.yy_, s*m.xz_+c*m.yz_,
m.zx_, m.zy_, m.xz_ );
m.zx_, m.zy_, m.zz_ );
}
} // namespace CLHEP
......@@ -273,6 +273,10 @@ protected:
}; // HepRotationX
// ---------- Free-function operations in the group of Rotations
inline
std::ostream & operator <<
( std::ostream & os, const HepRotationX & r ) {return r.print(os);}
} // namespace CLHEP
#include "CLHEP/Vector/RotationX.icc"
......
......@@ -226,9 +226,6 @@ public:
// ---------- Operations in the group of Rotations
inline HepRotation operator * (const Hep3RotationInterface & r) const;
// Product of two rotations: (this) * r - matrix multiplication
inline HepRotationY operator * (const HepRotationY & ry) const;
// Product of two Y rotations (this) * ry is known to be RotationY.
......@@ -276,6 +273,10 @@ protected:
// ---------- Free-function operations in the group of Rotations
inline
std::ostream & operator <<
( std::ostream & os, const HepRotationY & r ) {return r.print(os);}
} // namespace CLHEP
#include "CLHEP/Vector/RotationY.icc"
......
......@@ -226,9 +226,6 @@ public:
// ---------- Operations in the group of Rotations
inline HepRotation operator * (const Hep3RotationInterface & r) const;
// Product of two rotations (this) * r - matrix multiplication
inline HepRotationZ operator * (const HepRotationZ & rz) const;
// Product of two Z rotations: (this) * rz is known to be RotationZ.
......@@ -276,6 +273,10 @@ protected:
}; // HepRotationZ
inline
std::ostream & operator <<
( std::ostream & os, const HepRotationZ & r ) {return r.print(os);}
// ---------- Free-function operations in the group of Rotations
} // namespace CLHEP
......
......@@ -11,14 +11,18 @@
// With no special defines, this file will produce code for pure CLHEP
// building -- no ZOOM Exceptions are involved.
//
// To force a build using ZOOM Exceptions where the ZMthorw macros appear,
// To force a build using ZOOM Exceptions where the ZMthrow macros appear,
// compile with ENABLE_ZOOM_EXCEPTIONS defined.
//
// ----------------------------------------------------------------------
#undef ENABLE_ZOOM_EXCEPTIONS // For CLHEP builds
//#undef ENABLE_ZOOM_EXCEPTIONS // For CLHEP builds
//#define ENABLE_ZOOM_EXCEPTIONS // For ZOOM builds
// There should be some external way to control this. We haven't found it yet.
// Right now, this must be changed by hand when going between CLHEP and ZOOM.
#undef ENABLE_ZOOM_EXCEPTIONS
// Member functions of the Vector classes are capable of ZMthrow-ing the
// following ZMexception's:
//
......@@ -107,40 +111,74 @@
// This is the CLHEP version. When compiled for CLHEP, the basic CLHEP
// Vector classes will not (at least for now) depend on ZOOM Exceptions.
// Though this header lists the various sorts of Exceptions that could be
// thrown, ZMthrow.h in the pure CLHEP context will make ZMthrowA and
// ZMthrowC do what CLHEP has always done: whine to cerr about the problem
// and exit (or continue in the ZMthrowC case).
// thrown, ZMthrow.h in the pure CLHEP context will make ZMthrowC
// do what CLHEP has always done: whine to cerr about the problem
// and continue.
// ZMthrowA will whine to cerr and throw an exception; by catching the
// exception as a std::exception, the outside code can call e.what() to
// find the message string.
//
// If CLHEP ever embraces the ZOOM Exceptions mechanism, we will simply
// modify this file.
#include <string>
#include <exception>
#define ZMthrowA(A) do { std::cerr << A << "\n" << \
"at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
std::exit(-1); } while (0)
#define ZMthrowA(A) do { std::cerr << A.name() << " thrown:\n" \
<< A.what() << "\n" \
<< "at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
throw A;} while (0)
#define ZMthrowC(A) do { std::cerr << A << "\n" << \
"at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
#define ZMthrowC(A) do { std::cerr << A.name() << ":\n" \
<< A.what() << "\n" \
<< "at line " << __LINE__ << " in file " << __FILE__ << "\n"; \
} while (0)
#define ZMxPhysicsVectors(x) x
#define ZMxpvInfiniteVector(x) x
#define ZMxpvZeroVector(x) x
#define ZMxpvTachyonic(x) x
#define ZMxpvSpacelike(x) x
#define ZMxpvInfinity(x) x
#define ZMxpvNegativeMass(x) x
#define ZMxpvAmbiguousAngle(x) x
#define ZMxpvNegativeR(x) x
#define ZMxpvUnusualTheta(x) x
#define ZMxpvVectorInputFails(x) x
#define ZMxpvParallelCols(x) x
#define ZMxpvImproperRotation(x) x
#define ZMxpvImproperTransformation(x) x
#define ZMxpvIndexRange(x) x
#define ZMxpvNotOrthogonal(x) x
#define ZMxpvNotSymplectic(x) x
#define ZMxpvFixedAxis(x) x
class CLHEP_vector_exception : public std::exception {
public:
CLHEP_vector_exception ( const std::string & s ) throw();
virtual const char* what() const throw();
virtual const char* name() const throw() = 0;
virtual ~CLHEP_vector_exception() throw() {}
private:
std::string message;
};
#define CLHEP_vector_exception_header(NAME) \
class NAME : public CLHEP_vector_exception { \
public: \
NAME ( const std::string & s ) throw(); \
virtual const char* name() const throw(); \
virtual ~NAME() throw() {} \
};
// The following exceptions might be encountered via ZMtrhowA
CLHEP_vector_exception_header( ZMxPhysicsVectors )
CLHEP_vector_exception_header( ZMxpvSpacelike )
CLHEP_vector_exception_header( ZMxpvNegativeMass )
CLHEP_vector_exception_header( ZMxpvVectorInputFails )
CLHEP_vector_exception_header( ZMxpvIndexRange )
CLHEP_vector_exception_header( ZMxpvFixedAxis )
// The following are sometimes ZMthrowA and sometimes ZMthrowC
CLHEP_vector_exception_header( ZMxpvTachyonic )
CLHEP_vector_exception_header( ZMxpvZeroVector )
CLHEP_vector_exception_header( ZMxpvImproperTransformation )
CLHEP_vector_exception_header( ZMxpvInfiniteVector )
CLHEP_vector_exception_header( ZMxpvInfinity )
CLHEP_vector_exception_header( ZMxpvImproperRotation )
CLHEP_vector_exception_header( ZMxpvAmbiguousAngle )
// THe following won't throw; they are encountered via ZMthrowC
CLHEP_vector_exception_header( ZMxpvNegativeR )
CLHEP_vector_exception_header( ZMxpvUnusualTheta )
CLHEP_vector_exception_header( ZMxpvParallelCols )
CLHEP_vector_exception_header( ZMxpvNotOrthogonal )
CLHEP_vector_exception_header( ZMxpvNotSymplectic )
#endif // endif for ifndef ENABLE_ZOOM_EXCEPTIONS
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment