diff --git a/DDCore/include/DD4hep/ComponentProperties_inl.h b/DDCore/include/DD4hep/ComponentProperties_inl.h index 587fb0d957d172b34906cf9028097b23668192db..895e097d2607a8cc3e19b2940dd7941751086473 100644 --- a/DDCore/include/DD4hep/ComponentProperties_inl.h +++ b/DDCore/include/DD4hep/ComponentProperties_inl.h @@ -71,6 +71,23 @@ namespace DD4hep { } // End namespace DD4hep +// These operators do not really belong here, but also nowhere else..... +// ....except the proper ROOT headers perhaps? +#include "Math/Point3D.h" +#include "Math/Vector3D.h" +#include "Math/Vector4D.h" + +namespace ROOT { + namespace Math { + /// Allow point insertion of a point in maps + bool operator<(const XYZPoint& a, const XYZPoint& b); + /// Allow 3-vector insertion of a in maps + bool operator<(const XYZVector& a, const XYZVector& b); + /// Allow 4-vector insertion of a in maps + bool operator<(const PxPyPzEVector& a, const PxPyPzEVector& b); + } +} + // Instantiate single property #define DD4HEP_DEFINE_PROPERTY_TYPE(x) \ template x Property::value() const; \ diff --git a/DDCore/include/DD4hep/Handle.h b/DDCore/include/DD4hep/Handle.h index ef0e4583cbbb6e8b6367e7b0bcfcabe6d4b820a4..7fa77805027a46a128b095acab8409b3b3202811 100644 --- a/DDCore/include/DD4hep/Handle.h +++ b/DDCore/include/DD4hep/Handle.h @@ -303,7 +303,30 @@ namespace DD4hep { /// Generic multiplication using the evaluator: result = left * right \ingroup DD4HEP_GEOMETRY template <class T> T _multiply(const std::string& left, const std::string& right); - /** Block for concrete overloads of type: short */ + /** Block for concrete overloads of type: char */ + /// Generic multiplication using the evaluator: result = left * right \ingroup DD4HEP_GEOMETRY + template <> char _multiply<char>(const std::string& left, const std::string& right); + /// Generic multiplication using the evaluator: result = left * right \ingroup DD4HEP_GEOMETRY + template <> inline char _multiply<char>(char left, const std::string& right) { + return left * _toInt(right); + } + /// Generic multiplication using the evaluator: result = left * right \ingroup DD4HEP_GEOMETRY + template <> inline char _multiply<char>(const std::string& left, char right) { + return _toInt(left) * right; + } + + /** Block for concrete overloads of type: unsigned char */ + /// Generic multiplication using the evaluator: result = left * right \ingroup DD4HEP_GEOMETRY + template <> unsigned char _multiply<unsigned char>(const std::string& left, const std::string& right); + /// Generic multiplication using the evaluator: result = left * right \ingroup DD4HEP_GEOMETRY + template <> inline unsigned char _multiply<unsigned char>(unsigned char left, const std::string& right) { + return left * _toInt(right); + } + /// Generic multiplication using the evaluator: result = left * right \ingroup DD4HEP_GEOMETRY + template <> inline unsigned char _multiply<unsigned char>(const std::string& left, unsigned char right) { + return _toInt(left) * right; + } + /// Generic multiplication using the evaluator: result = left * right \ingroup DD4HEP_GEOMETRY template <> short _multiply<short>(const std::string& left, const std::string& right); /// Generic multiplication using the evaluator: result = left * right \ingroup DD4HEP_GEOMETRY diff --git a/DDCore/include/DD4hep/Objects.h b/DDCore/include/DD4hep/Objects.h index aae936eb0d5bbe5b8911c51559701f1961b6f273..86280e7a72ae62eb2f952babb22d206b30ec97f2 100644 --- a/DDCore/include/DD4hep/Objects.h +++ b/DDCore/include/DD4hep/Objects.h @@ -545,6 +545,7 @@ namespace DD4hep { } /* End namespace Geometry */ } /* End namespace DD4hep */ + namespace ROOT { namespace Math { typedef DD4hep::Geometry::Position Position; @@ -560,7 +561,6 @@ namespace ROOT { inline Position mean_direction(const Position& p1, const Position& p2) { return 0.5 * (p1 + p2); } - } } diff --git a/DDCore/src/ConditonsTypes.cpp b/DDCore/src/ConditonsTypes.cpp index d4400b34df85f589a487f3f46ab775341e6ac2de..d277cb3bfe63894348a5fccafc344328cc1e0708 100644 --- a/DDCore/src/ConditonsTypes.cpp +++ b/DDCore/src/ConditonsTypes.cpp @@ -15,6 +15,7 @@ // Framework include files #include "DD4hep/Primitives.h" #include "DD4hep/objects/ConditionsInterna.h" +#include "DD4hep/ComponentProperties_inl.h" #include "Math/Point3D.h" #include "Math/Vector3D.h" diff --git a/DDCore/src/Handle.cpp b/DDCore/src/Handle.cpp index 0c09ccaa82382d209da495e481d4e8ca42d5bfab..b5649de57bd5973c2fed9d64048a6a73ae7cfbd3 100644 --- a/DDCore/src/Handle.cpp +++ b/DDCore/src/Handle.cpp @@ -13,10 +13,12 @@ //========================================================================== #include "DD4hep/InstanceCount.h" +#include "DD4hep/Printout.h" #include "DD4hep/Handle.inl" #include "XML/Evaluator.h" #include <iostream> #include <iomanip> +#include <climits> #include <cstring> #include <cstdio> @@ -108,12 +110,44 @@ double DD4hep::_toDouble(const string& value) { return result; } +template <> char DD4hep::_multiply<char>(const string& left, const string& right) { + double val = _toDouble(left + "*" + right); + if ( val >= double(SCHAR_MIN) && val <= double(SCHAR_MAX) ) + return (char) (int)val; + except("_multiply<char>", + "Multiplication %e = %s * %s out of bounds for conversion to char.", + val, left.c_str(), right.c_str()); + return 0; +} + +template <> unsigned char DD4hep::_multiply<unsigned char>(const string& left, const string& right) { + double val = _toDouble(left + "*" + right); + if ( val >= 0 && val <= double(UCHAR_MAX) ) + return (unsigned char) (int)val; + except("_multiply<char>", + "Multiplication %e = %s * %s out of bounds for conversion to unsigned char.", + val, left.c_str(), right.c_str()); + return 0; +} + template <> short DD4hep::_multiply<short>(const string& left, const string& right) { - return (short) _toDouble(left + "*" + right); + double val = _toDouble(left + "*" + right); + if ( val >= double(SHRT_MIN) && val <= double(SHRT_MAX) ) + return (short) val; + except("_multiply<char>", + "Multiplication %e = %s * %s out of bounds for conversion to short.", + val, left.c_str(), right.c_str()); + return 0; } template <> unsigned short DD4hep::_multiply<unsigned short>(const string& left, const string& right) { - return (unsigned short) _toDouble(left + "*" + right); + double val = _toDouble(left + "*" + right); + if ( val >= 0 && val <= double(USHRT_MAX) ) + return (unsigned short)val; + except("_multiply<char>", + "Multiplication %e = %s * %s out of bounds for conversion to unsigned short.", + val, left.c_str(), right.c_str()); + return 0; } template <> int DD4hep::_multiply<int>(const string& left, const string& right) {