From adc47e94d1b611e928cfa9e559e9d96ff9ef0b00 Mon Sep 17 00:00:00 2001 From: Markus Frank <markus.frank@cern.ch> Date: Fri, 4 Mar 2016 13:01:19 +0000 Subject: [PATCH] Fix link trouble reported by Peter for MacOS and Yorgos for the nightlies --- .../include/DD4hep/ComponentProperties_inl.h | 17 +++++++++ DDCore/include/DD4hep/Handle.h | 25 +++++++++++- DDCore/include/DD4hep/Objects.h | 2 +- DDCore/src/ConditonsTypes.cpp | 1 + DDCore/src/Handle.cpp | 38 ++++++++++++++++++- 5 files changed, 79 insertions(+), 4 deletions(-) diff --git a/DDCore/include/DD4hep/ComponentProperties_inl.h b/DDCore/include/DD4hep/ComponentProperties_inl.h index 587fb0d95..895e097d2 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 ef0e4583c..7fa778050 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 aae936eb0..86280e7a7 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 d4400b34d..d277cb3bf 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 0c09ccaa8..b5649de57 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) { -- GitLab