diff --git a/CMakeLists.txt b/CMakeLists.txt index 0785c02b4..7fdf3fb31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,8 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/edm4hep/edm4hep/EDM4hepVersion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/edm4hep ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/python/edm4hep/__version__.py.in ${CMAKE_CURRENT_SOURCE_DIR}/python/edm4hep/__version__.py) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/edm4hep + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) #--- add CMake infrastructure -------------------------------------------------- include(cmake/EDM4HEPCreateConfig.cmake) diff --git a/edm4hep.yaml b/edm4hep.yaml index bb30857b2..2ee6dedc6 100644 --- a/edm4hep.yaml +++ b/edm4hep.yaml @@ -132,22 +132,8 @@ components: constexpr CovMatrix2f& operator=(std::array v) { values = v; return *this; }\n bool operator==(const CovMatrix2f& v) const { return v.values == values; }\n bool operator!=(const CovMatrix2f& v) const { return v.values != values; }\n - constexpr float operator[](unsigned i) const { return values[i]; }\n - constexpr float& operator[](unsigned i) { return values[i]; }\n - constexpr auto begin() const { return values.begin(); }\n - constexpr auto begin() { return values.begin(); }\n - constexpr auto end() const { return values.begin(); }\n - constexpr auto end() { return values.begin(); }\n - float* data() { return values.data(); }\n - const float* data() const { return values.data(); }\n - /// Get the value of the covariance matrix for the two passed dimensions\n - template\n - constexpr float getValue(DimEnum dimI, DimEnum dimJ) const { return utils::get_cov_value(values, dimI, dimJ); }\n - /// Set a value in the covariance matrix for the two passed dimensions\n - template\n - constexpr void setValue(float value, DimEnum dimI, DimEnum dimJ) { utils::set_cov_value(value, values, dimI, dimJ); }\n - " - + #include + " edm4hep::CovMatrix3f: Description: "A generic 3 dimensional covariance matrix with values stored in lower triangular form" Members: @@ -160,20 +146,7 @@ components: constexpr CovMatrix3f& operator=(std::array v) { values = v; return *this; }\n bool operator==(const CovMatrix3f& v) const { return v.values == values; }\n bool operator!=(const CovMatrix3f& v) const { return v.values != values; }\n - constexpr float operator[](unsigned i) const { return values[i]; }\n - constexpr float& operator[](unsigned i) { return values[i]; }\n - constexpr auto begin() const { return values.begin(); }\n - constexpr auto begin() { return values.begin(); }\n - constexpr auto end() const { return values.begin(); }\n - constexpr auto end() { return values.begin(); }\n - float* data() { return values.data(); }\n - const float* data() const { return values.data(); }\n - /// Get the value of the covariance matrix for the two passed dimensions\n - template\n - constexpr float getValue(DimEnum dimI, DimEnum dimJ) const { return utils::get_cov_value(values, dimI, dimJ); }\n - /// Set a value in the covariance matrix for the two passed dimensions\n - template\n - constexpr void setValue(float value, DimEnum dimI, DimEnum dimJ) { utils::set_cov_value(value, values, dimI, dimJ); }\n + #include " edm4hep::CovMatrix4f: @@ -188,21 +161,8 @@ components: constexpr CovMatrix4f& operator=(std::array v) { values = v; return *this; }\n bool operator==(const CovMatrix4f& v) const { return v.values == values; }\n bool operator!=(const CovMatrix4f& v) const { return v.values != values; }\n - constexpr float operator[](unsigned i) const { return values[i]; }\n - constexpr float& operator[](unsigned i) { return values[i]; }\n - constexpr auto begin() const { return values.begin(); }\n - constexpr auto begin() { return values.begin(); }\n - constexpr auto end() const { return values.begin(); }\n - constexpr auto end() { return values.begin(); }\n - float* data() { return values.data(); }\n - const float* data() const { return values.data(); }\n - /// Get the value of the covariance matrix for the two passed dimensions\n - template\n - constexpr float getValue(DimEnum dimI, DimEnum dimJ) const { return utils::get_cov_value(values, dimI, dimJ); }\n - /// Set a value in the covariance matrix for the two passed dimensions\n - template\n - constexpr void setValue(float value, DimEnum dimI, DimEnum dimJ) { utils::set_cov_value(value, values, dimI, dimJ); }\n - " + #include + " edm4hep::CovMatrix6f: Description: "A generic 6 dimensional covariance matrix with values stored in lower triangular form" @@ -216,20 +176,7 @@ components: constexpr CovMatrix6f& operator=(std::array v) { values = v; return *this; }\n bool operator==(const CovMatrix6f& v) const { return v.values == values; }\n bool operator!=(const CovMatrix6f& v) const { return v.values != values; }\n - constexpr float operator[](unsigned i) const { return values[i]; }\n - constexpr float& operator[](unsigned i) { return values[i]; }\n - constexpr auto begin() const { return values.begin(); }\n - constexpr auto begin() { return values.begin(); }\n - constexpr auto end() const { return values.begin(); }\n - constexpr auto end() { return values.begin(); }\n - float* data() { return values.data(); }\n - const float* data() const { return values.data(); }\n - /// Get the value of the covariance matrix for the two passed dimensions\n - template\n - constexpr float getValue(DimEnum dimI, DimEnum dimJ) const { return utils::get_cov_value(values, dimI, dimJ); }\n - /// Set a value in the covariance matrix for the two passed dimensions\n - template\n - constexpr void setValue(float value, DimEnum dimI, DimEnum dimJ) { utils::set_cov_value(value, values, dimI, dimJ); }\n + #include \n " # Parametrized description of a particle track diff --git a/include/edm4hep/detail/CovMatrixCommon.ipp b/include/edm4hep/detail/CovMatrixCommon.ipp new file mode 100644 index 000000000..845928a8f --- /dev/null +++ b/include/edm4hep/detail/CovMatrixCommon.ipp @@ -0,0 +1,90 @@ +// This file is meant to be included inside the declaration part of the +// ExtraCode for the CovMatrixNx components. They live in this file because they +// can be written very generically and reduce the clutter and code repetition in +// the edm4hep.yaml file +// +// NOTE: All of these functions are intended to be member functions, and the +// only member of a CovMatrixNx component is an apropriately sized std::array +// named values. +// +// NOTE: It is also assumed that the edm4hep/utils/cov_matrix_utils.h header is +// included via the corresponding ExtraCode: include directive + +/// Get the i-th element of the underlying storage +/// +/// \note The values are stored in a flat array assuming a lower +/// triangular matrix representation +constexpr float operator[](unsigned i) const { + return values[i]; +} + +/// Get the i-th element of the underlying storage +/// +/// \note The values are stored in a flat array assuming a lower +/// triangular matrix representation +constexpr float& operator[](unsigned i) { + return values[i]; +} + +/// Get the begin iterator to the underlying storage +constexpr auto begin() const { + return values.begin(); +} + +/// Get the begin iterator to the underlying storage +constexpr auto begin() { + return values.begin(); +} + +/// Get the end iterator to the underlying storage +constexpr auto end() const { + return values.end(); +} + +/// Get the end iterator to the underlying storage +constexpr auto end() { + return values.end(); +} + +/// Get a pointer to the underlying storage data +auto* data() { + return values.data(); +} + +/// Get a pointer to the underlying storage data +const auto* data() const { + return values.data(); +} + +/// Get the value of the covariance matrix for the passed dimensions +/// +/// @tparam DimEnum The enum (class) type that describes the dimenstions of this +/// covariance matrix. This will be deduced from the passed +/// arguments! +/// +/// @param dimI The first dimension for which the covariance matrix value should +/// be obtained +/// @param dimJ The second dimension for which the covariance matrix value +/// should be obtained +/// +/// @returns The value of the covariance matrix for dimension dimI and dimJ +template +constexpr float getValue(DimEnum dimI, DimEnum dimJ) const { + return edm4hep::utils::get_cov_value(values, dimI, dimJ); +} + +/// Set the value of the covariance matrix for the passed dimensions +/// +/// @tparam DimEnum The enum (class) type that describes the dimenstions of this +/// covariance matrix. This will be deduced from the passed +/// arguments! +/// +/// @param value The value to be set +/// @param dimI The first dimension for which the covariance matrix value +/// should be obtained +/// @param dimJ The second dimension for which the covariance matrix value +/// should be obtained +template +constexpr void setValue(float value, DimEnum dimI, DimEnum dimJ) { + utils::set_cov_value(value, values, dimI, dimJ); +}