Commit bd8b096b authored by Lynn Garren's avatar Lynn Garren
Browse files

Merge branch 'release/CLHEP_2_4_1_3'

parents 7062c532 daac2fa5
...@@ -31,7 +31,7 @@ clhep_ensure_out_of_source_build() ...@@ -31,7 +31,7 @@ clhep_ensure_out_of_source_build()
# use cmake 3.2 or later # use cmake 3.2 or later
cmake_minimum_required(VERSION 3.2) cmake_minimum_required(VERSION 3.2)
# Project setup # Project setup
project(CLHEP VERSION 2.4.1.2) project(CLHEP VERSION 2.4.1.3)
# - needed for (temporary) back compatibility # - needed for (temporary) back compatibility
set(VERSION ${PROJECT_VERSION}) set(VERSION ${PROJECT_VERSION})
......
==============================
21.10.19 Release CLHEP-2.4.1.3
==============================
2019-10-18 Evgueni Tcherniaev <evgueni.tcherniaev.@cern.ch>
* Vector/Vector/*.h: added move constructor and move assignment
* Geometry/Geometry/*.h: added move constructor and move assignment
============================== ==============================
20.06.19 Release CLHEP-2.4.1.2 20.06.19 Release CLHEP-2.4.1.2
============================== ==============================
......
============================== ==============================
21.10.19 Release CLHEP-2.4.1.3
==============================
==============================
20.06.19 Release CLHEP-2.4.1.2 20.06.19 Release CLHEP-2.4.1.2
============================== ==============================
============================== ==============================
......
============================== ==============================
21.10.19 Release CLHEP-2.4.1.3
==============================
==============================
20.06.19 Release CLHEP-2.4.1.2 20.06.19 Release CLHEP-2.4.1.2
============================== ==============================
============================== ==============================
......
============================== ==============================
21.10.19 Release CLHEP-2.4.1.3
==============================
==============================
20.06.19 Release CLHEP-2.4.1.2 20.06.19 Release CLHEP-2.4.1.2
============================== ==============================
============================== ==============================
......
============================== ==============================
21.10.19 Release CLHEP-2.4.1.3
==============================
==============================
20.06.19 Release CLHEP-2.4.1.2 20.06.19 Release CLHEP-2.4.1.2
============================== ==============================
============================== ==============================
......
============================== ==============================
21.10.19 Release CLHEP-2.4.1.3
==============================
==============================
20.06.19 Release CLHEP-2.4.1.2 20.06.19 Release CLHEP-2.4.1.2
============================== ==============================
============================== ==============================
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define BASIC_VECTOR3D_H #define BASIC_VECTOR3D_H
#include <iosfwd> #include <iosfwd>
#include <type_traits>
#include "CLHEP/Geometry/defs.h" #include "CLHEP/Geometry/defs.h"
#include "CLHEP/Vector/ThreeVector.h" #include "CLHEP/Vector/ThreeVector.h"
...@@ -52,19 +53,24 @@ namespace HepGeom { ...@@ -52,19 +53,24 @@ namespace HepGeom {
BasicVector3D(T x1, T y1, T z1) { v_[0] = x1; v_[1] = y1; v_[2] = z1; } BasicVector3D(T x1, T y1, T z1) { v_[0] = x1; v_[1] = y1; v_[2] = z1; }
/** /**
* Copy constructor. * Copy constructor. */
* Note: BasicVector3D<double> has constructors BasicVector3D(const BasicVector3D<T> &) = default;
* from BasicVector3D<double> (provided by compiler) and
* from BasicVector3D<float> (defined in this file); /**
* BasicVector3D<float> has only the last one. * Constructor for BasicVector3D<double> from BasicVector3D<float>. */
*/ template<typename U = T,
typename = typename std::enable_if<!std::is_same<U,float>::value >::type>
BasicVector3D(const BasicVector3D<float> & v) { BasicVector3D(const BasicVector3D<float> & v) {
v_[0] = v.x(); v_[1] = v.y(); v_[2] = v.z(); v_[0] = v.x(); v_[1] = v.y(); v_[2] = v.z();
} }
/**
* Move constructor. */
BasicVector3D(BasicVector3D<T> &&) = default;
/** /**
* Destructor. */ * Destructor. */
virtual ~BasicVector3D() {} virtual ~BasicVector3D() = default;
// ------------------------- // -------------------------
// Interface to "good old C" // Interface to "good old C"
...@@ -82,7 +88,7 @@ namespace HepGeom { ...@@ -82,7 +88,7 @@ namespace HepGeom {
* Conversion (cast) to CLHEP::Hep3Vector. * Conversion (cast) to CLHEP::Hep3Vector.
* This operator is needed only for backward compatibility and * This operator is needed only for backward compatibility and
* in principle should not exit. * in principle should not exit.
*/ */
operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); } operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
// ----------------------------- // -----------------------------
...@@ -92,6 +98,9 @@ namespace HepGeom { ...@@ -92,6 +98,9 @@ namespace HepGeom {
/** /**
* Assignment. */ * Assignment. */
BasicVector3D<T> & operator= (const BasicVector3D<T> &) = default; BasicVector3D<T> & operator= (const BasicVector3D<T> &) = default;
/**
* Move assignment. */
BasicVector3D<T> & operator= (BasicVector3D<T> &&) = default;
/** /**
* Addition. */ * Addition. */
BasicVector3D<T> & operator+=(const BasicVector3D<T> & v) { BasicVector3D<T> & operator+=(const BasicVector3D<T> & v) {
...@@ -123,36 +132,36 @@ namespace HepGeom { ...@@ -123,36 +132,36 @@ namespace HepGeom {
/** /**
* Gets components by index. */ * Gets components by index. */
T operator[](int i) const { return v_[i]; } T operator[](int i) const { return v_[i]; }
/** /**
* Sets components by index. */ * Sets components by index. */
T & operator()(int i) { return v_[i]; } T & operator()(int i) { return v_[i]; }
/** /**
* Sets components by index. */ * Sets components by index. */
T & operator[](int i) { return v_[i]; } T & operator[](int i) { return v_[i]; }
// ------------------------------------ // ------------------------------------
// Cartesian coordinate system: x, y, z // Cartesian coordinate system: x, y, z
// ------------------------------------ // ------------------------------------
/** /**
* Gets x-component in cartesian coordinate system. */ * Gets x-component in cartesian coordinate system. */
T x() const { return v_[0]; } T x() const { return v_[0]; }
/** /**
* Gets y-component in cartesian coordinate system. */ * Gets y-component in cartesian coordinate system. */
T y() const { return v_[1]; } T y() const { return v_[1]; }
/** /**
* Gets z-component in cartesian coordinate system. */ * Gets z-component in cartesian coordinate system. */
T z() const { return v_[2]; } T z() const { return v_[2]; }
/** /**
* Sets x-component in cartesian coordinate system. */ * Sets x-component in cartesian coordinate system. */
void setX(T a) { v_[0] = a; } void setX(T a) { v_[0] = a; }
/** /**
* Sets y-component in cartesian coordinate system. */ * Sets y-component in cartesian coordinate system. */
void setY(T a) { v_[1] = a; } void setY(T a) { v_[1] = a; }
/** /**
* Sets z-component in cartesian coordinate system. */ * Sets z-component in cartesian coordinate system. */
void setZ(T a) { v_[2] = a; } void setZ(T a) { v_[2] = a; }
/** /**
...@@ -179,7 +188,7 @@ namespace HepGeom { ...@@ -179,7 +188,7 @@ namespace HepGeom {
T factor = perp(); T factor = perp();
if (factor > 0) { if (factor > 0) {
factor = rh/factor; v_[0] *= factor; v_[1] *= factor; factor = rh/factor; v_[0] *= factor; v_[1] *= factor;
} }
} }
// ------------------------------------------ // ------------------------------------------
...@@ -212,10 +221,10 @@ namespace HepGeom { ...@@ -212,10 +221,10 @@ namespace HepGeom {
/** /**
* Gets r-component in spherical coordinate system */ * Gets r-component in spherical coordinate system */
T getR() const { return r(); } T getR() const { return r(); }
/** /**
* Gets phi-component in spherical coordinate system */ * Gets phi-component in spherical coordinate system */
T getPhi() const { return phi(); } T getPhi() const { return phi(); }
/** /**
* Gets theta-component in spherical coordinate system */ * Gets theta-component in spherical coordinate system */
T getTheta() const { return theta(); } T getTheta() const { return theta(); }
...@@ -225,7 +234,7 @@ namespace HepGeom { ...@@ -225,7 +234,7 @@ namespace HepGeom {
T factor = mag(); T factor = mag();
if (factor > 0) { if (factor > 0) {
factor = ma/factor; v_[0] *= factor; v_[1] *= factor; v_[2] *= factor; factor = ma/factor; v_[0] *= factor; v_[1] *= factor; v_[2] *= factor;
} }
} }
/** /**
* Sets r-component in spherical coordinate system. */ * Sets r-component in spherical coordinate system. */
...@@ -246,7 +255,7 @@ namespace HepGeom { ...@@ -246,7 +255,7 @@ namespace HepGeom {
// --------------- // ---------------
/** /**
* Gets pseudo-rapidity: -ln(std::tan(theta/2)) */ * Gets pseudo-rapidity: -ln(tan(theta/2)) */
T pseudoRapidity() const; T pseudoRapidity() const;
/** /**
* Gets pseudo-rapidity. */ * Gets pseudo-rapidity. */
...@@ -299,7 +308,7 @@ namespace HepGeom { ...@@ -299,7 +308,7 @@ namespace HepGeom {
// --------------- // ---------------
/** /**
* Returns unit vector parallel to this. */ * Returns unit vector parallel to this. */
BasicVector3D<T> unit() const { BasicVector3D<T> unit() const {
T len = mag(); T len = mag();
return (len > 0) ? return (len > 0) ?
...@@ -307,7 +316,7 @@ namespace HepGeom { ...@@ -307,7 +316,7 @@ namespace HepGeom {
} }
/** /**
* Returns orthogonal vector. */ * Returns orthogonal vector. */
BasicVector3D<T> orthogonal() const { BasicVector3D<T> orthogonal() const {
T dx = x() < 0 ? -x() : x(); T dx = x() < 0 ? -x() : x();
T dy = y() < 0 ? -y() : y(); T dy = y() < 0 ? -y() : y();
...@@ -340,9 +349,9 @@ namespace HepGeom { ...@@ -340,9 +349,9 @@ namespace HepGeom {
}; };
/************************************************************************* /*************************************************************************
* * * *
* Non-member functions for BasicVector3D<float> * * Non-member functions for BasicVector3D<float> *
* * * *
*************************************************************************/ *************************************************************************/
/** /**
...@@ -428,9 +437,9 @@ namespace HepGeom { ...@@ -428,9 +437,9 @@ namespace HepGeom {
operator/(const BasicVector3D<float> & v, double a) { operator/(const BasicVector3D<float> & v, double a) {
return BasicVector3D<float>(v.x()/static_cast<float>(a), v.y()/static_cast<float>(a), v.z()/static_cast<float>(a)); return BasicVector3D<float>(v.x()/static_cast<float>(a), v.y()/static_cast<float>(a), v.z()/static_cast<float>(a));
} }
/** /**
* Comparison of two vectors for equality. * Comparison of two vectors for equality.
* @relates BasicVector3D * @relates BasicVector3D
*/ */
inline bool inline bool
...@@ -439,7 +448,7 @@ namespace HepGeom { ...@@ -439,7 +448,7 @@ namespace HepGeom {
} }
/** /**
* Comparison of two vectors for inequality. * Comparison of two vectors for inequality.
* @relates BasicVector3D * @relates BasicVector3D
*/ */
inline bool inline bool
...@@ -448,9 +457,9 @@ namespace HepGeom { ...@@ -448,9 +457,9 @@ namespace HepGeom {
} }
/************************************************************************* /*************************************************************************
* * * *
* Non-member functions for BasicVector3D<double> * * Non-member functions for BasicVector3D<double> *
* * * *
*************************************************************************/ *************************************************************************/
/** /**
...@@ -536,9 +545,9 @@ namespace HepGeom { ...@@ -536,9 +545,9 @@ namespace HepGeom {
operator/(const BasicVector3D<double> & v, double a) { operator/(const BasicVector3D<double> & v, double a) {
return BasicVector3D<double>(v.x()/a, v.y()/a, v.z()/a); return BasicVector3D<double>(v.x()/a, v.y()/a, v.z()/a);
} }
/** /**
* Comparison of two vectors for equality. * Comparison of two vectors for equality.
* @relates BasicVector3D * @relates BasicVector3D
*/ */
inline bool inline bool
...@@ -548,7 +557,7 @@ namespace HepGeom { ...@@ -548,7 +557,7 @@ namespace HepGeom {
} }
/** /**
* Comparison of two vectors for inequality. * Comparison of two vectors for inequality.
* @relates BasicVector3D * @relates BasicVector3D
*/ */
inline bool inline bool
......
...@@ -45,7 +45,7 @@ namespace HepGeom { ...@@ -45,7 +45,7 @@ namespace HepGeom {
public: public:
/** /**
* Default constructor. */ * Default constructor. */
Normal3D() {} Normal3D() = default;
/** /**
* Constructor from three numbers. */ * Constructor from three numbers. */
...@@ -58,7 +58,11 @@ namespace HepGeom { ...@@ -58,7 +58,11 @@ namespace HepGeom {
/** /**
* Copy constructor. */ * Copy constructor. */
Normal3D(const Normal3D<float> & v) : BasicVector3D<float>(v) {} Normal3D(const Normal3D<float> &) = default;
/**
* Move constructor. */
Normal3D(Normal3D<float> &&) = default;
/** /**
* Constructor from BasicVector3D<float>. */ * Constructor from BasicVector3D<float>. */
...@@ -66,20 +70,23 @@ namespace HepGeom { ...@@ -66,20 +70,23 @@ namespace HepGeom {
/** /**
* Destructor. */ * Destructor. */
~Normal3D() {} ~Normal3D() = default;
/** /**
* Assignment. */ * Assignment. */
Normal3D<float> & operator=(const Normal3D<float> & v) { Normal3D<float> & operator=(const Normal3D<float> &) = default;
set(v.x(),v.y(),v.z()); return *this;
}
/** /**
* Assignment from BasicVector3D<float>. */ * Assignment from BasicVector3D<float>. */
Normal3D<float> & operator=(const BasicVector3D<float> & v) { Normal3D<float> & operator=(const BasicVector3D<float> & v) {
set(v.x(),v.y(),v.z()); return *this; this->BasicVector3D<float>::operator=(v);
return *this;
} }
/**
* Move assignment. */
Normal3D<float> & operator=(Normal3D<float> &&) = default;
/** /**
* Transformation by Transform3D. */ * Transformation by Transform3D. */
Normal3D<float> & transform(const Transform3D & m); Normal3D<float> & transform(const Transform3D & m);
...@@ -103,7 +110,7 @@ namespace HepGeom { ...@@ -103,7 +110,7 @@ namespace HepGeom {
public: public:
/** /**
* Default constructor. */ * Default constructor. */
Normal3D() {} Normal3D() = default;
/** /**
* Constructor from three numbers. */ * Constructor from three numbers. */
...@@ -121,7 +128,11 @@ namespace HepGeom { ...@@ -121,7 +128,11 @@ namespace HepGeom {
/** /**
* Copy constructor. */ * Copy constructor. */
Normal3D(const Normal3D<double> & v) : BasicVector3D<double>(v) {} Normal3D(const Normal3D<double> &) = default;
/**
* Move constructor. */
Normal3D(Normal3D<double> &&) = default;
/** /**
* Constructor from BasicVector3D<float>. */ * Constructor from BasicVector3D<float>. */
...@@ -133,7 +144,7 @@ namespace HepGeom { ...@@ -133,7 +144,7 @@ namespace HepGeom {
/** /**
* Destructor. */ * Destructor. */
~Normal3D() {} ~Normal3D() = default;
/** /**
* Constructor from CLHEP::Hep3Vector. * Constructor from CLHEP::Hep3Vector.
...@@ -147,27 +158,31 @@ namespace HepGeom { ...@@ -147,27 +158,31 @@ namespace HepGeom {
* Conversion (cast) to CLHEP::Hep3Vector. * Conversion (cast) to CLHEP::Hep3Vector.
* This operator is needed only for backward compatibility and * This operator is needed only for backward compatibility and
* in principle should not exit. * in principle should not exit.
*/ */
operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); } operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
/** /**
* Assignment. */ * Assignment. */
Normal3D<double> & operator=(const Normal3D<double> & v) { Normal3D<double> & operator=(const Normal3D<double> &) = default;
set(v.x(),v.y(),v.z()); return *this;
}
/** /**
* Assignment from BasicVector3D<float>. */ * Assignment from BasicVector3D<float>. */
Normal3D<double> & operator=(const BasicVector3D<float> & v) { Normal3D<double> & operator=(const BasicVector3D<float> & v) {
set(v.x(),v.y(),v.z()); return *this; this->BasicVector3D<double>::operator=(v);
return *this;
} }
/** /**
* Assignment from BasicVector3D<double>. */ * Assignment from BasicVector3D<double>. */
Normal3D<double> & operator=(const BasicVector3D<double> & v) { Normal3D<double> & operator=(const BasicVector3D<double> & v) {
set(v.x(),v.y(),v.z()); return *this; this->BasicVector3D<double>::operator=(v);
return *this;
} }
/**
* Move assignment. */
Normal3D<double> & operator=(Normal3D<double> &&) = default;
/** /**
* Transformation by Transform3D. */ * Transformation by Transform3D. */
Normal3D<double> & transform(const Transform3D & m); Normal3D<double> & transform(const Transform3D & m);
......
...@@ -30,7 +30,7 @@ namespace HepGeom { ...@@ -30,7 +30,7 @@ namespace HepGeom {
class Plane3D { class Plane3D {
protected: protected:
T a_, b_, c_, d_; T a_, b_, c_, d_;
public: public:
/** /**
* Default constructor - creates plane z=0. */ * Default constructor - creates plane z=0. */
...@@ -54,23 +54,33 @@ namespace HepGeom { ...@@ -54,23 +54,33 @@ namespace HepGeom {
a_ = n.x(); b_ = n.y(); c_ = n.z(); d_ = -n*p1; a_ = n.x(); b_ = n.y(); c_ = n.z(); d_ = -n*p1;
} }
/** Copy constructor. /**
* Plane3D<double> has two constructors: * Copy constructor. */
* from Plane3D<double> (provided by compiler) and Plane3D(const Plane3D<T> &) = default;
* from Plane3D<float> (defined in this file).
* Plane3D<float> has only the last one. /**
*/ * Constructor for Plane3D<double> from Plane3D<float>. */
template<typename U = T,
typename = typename std::enable_if<!std::is_same<U,float>::value >::type>
Plane3D(const Plane3D<float> & p) Plane3D(const Plane3D<float> & p)
: a_(p.a_), b_(p.b_), c_(p.c_), d_(p.d_) {} : a_(p.a_), b_(p.b_), c_(p.c_), d_(p.d_) {}