From da2392f8f6a6657e53ba887849563fe23a55414e Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Tue, 17 Dec 2024 20:00:27 +0100 Subject: [PATCH 1/4] Remove the colorFlow member from the MCParticle Not actually used anywhere --- CMakeLists.txt | 2 +- edm4hep.yaml | 1 - scripts/createEDM4hepFile.py | 1 - test/test_EDM4hepFile.py | 14 ++++++++++++-- test/utils/test_kinematics.py | 1 - 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec117a571..f0e27fe29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(EDM4HEP LANGUAGES CXX) # project version SET( ${PROJECT_NAME}_VERSION_MAJOR 0 ) SET( ${PROJECT_NAME}_VERSION_MINOR 99 ) -SET( ${PROJECT_NAME}_VERSION_PATCH 1 ) +SET( ${PROJECT_NAME}_VERSION_PATCH 99 ) SET( ${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}" ) diff --git a/edm4hep.yaml b/edm4hep.yaml index 8c18127ca..0fbcf9e13 100644 --- a/edm4hep.yaml +++ b/edm4hep.yaml @@ -266,7 +266,6 @@ datatypes: - edm4hep::Vector3d momentum [GeV] // particle 3-momentum at the production vertex - edm4hep::Vector3d momentumAtEndpoint [GeV] // particle 3-momentum at the endpoint - edm4hep::Vector3f spin // spin (helicity) vector of the particle - - edm4hep::Vector2i colorFlow // color flow as defined by the generator OneToManyRelations: - edm4hep::MCParticle parents // The parents of this particle - edm4hep::MCParticle daughters // The daughters this particle diff --git a/scripts/createEDM4hepFile.py b/scripts/createEDM4hepFile.py index e7c2af07c..b564af877 100755 --- a/scripts/createEDM4hepFile.py +++ b/scripts/createEDM4hepFile.py @@ -52,7 +52,6 @@ def create_MCParticleCollection(): edm4hep.Vector3d(next(counter), next(counter), next(counter)) ) particle.setSpin(edm4hep.Vector3f(next(counter), next(counter), next(counter))) - particle.setColorFlow(edm4hep.Vector2i(next(counter), next(counter))) p_list[0].addToDaughters(p_list[1]) p_list[0].addToParents(p_list[2]) diff --git a/test/test_EDM4hepFile.py b/test/test_EDM4hepFile.py index 461d1ee99..1a195a56f 100644 --- a/test/test_EDM4hepFile.py +++ b/test/test_EDM4hepFile.py @@ -95,6 +95,11 @@ def track(event): return event.get("TrackCollection")[0] +@pytest.fixture(scope="module") +def edm4hep_version(reader): + return reader.current_file_version("edm4hep") + + def check_cov_matrix(cov_matrix, n_dim): """Check the contents of the passed covariance matrix""" counter = count(COUNT_START) @@ -125,7 +130,7 @@ def test_EventHeaderCollection(event): assert weight == next(counter) -def test_MCParticleCollection(event): +def test_MCParticleCollection(event, edm4hep_version): """Check the MCParticleCollection""" counter = count(COUNT_START) particles = event.get("MCParticleCollection") @@ -151,7 +156,12 @@ def test_MCParticleCollection(event): next(counter), next(counter), next(counter) ) assert particle.getSpin() == edm4hep.Vector3f(next(counter), next(counter), next(counter)) - assert particle.getColorFlow() == edm4hep.Vector2i(next(counter), next(counter)) + + if edm4hep_version < podio.version.parse("0.99.2"): + # The colorFlow as here so we have increase the counter here to + # maintain the expected values for all elements of the collection + next(counter) + next(counter) assert particles[0].getDaughters()[0] == particles[1] assert particles[0].getParents()[0] == particles[2] diff --git a/test/utils/test_kinematics.py b/test/utils/test_kinematics.py index f460ecde0..91873343e 100644 --- a/test/utils/test_kinematics.py +++ b/test/utils/test_kinematics.py @@ -34,7 +34,6 @@ def test_p4(self): edm4hep.Vector3d(1.0, 2.0, 3.0), # momentum edm4hep.Vector3d(0, 0, 0), # momentumAtEndpoint edm4hep.Vector3f(0, 0, 0), # spin - edm4hep.Vector2i(0, 0), # colorFlow ) self.assertEqual(p4(p), LVM(1.0, 2.0, 3.0, 125.0)) From c58812451a8979c35581b956bdebe4c73f157f55 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Wed, 18 Dec 2024 10:39:30 +0100 Subject: [PATCH 2/4] Remove the Vector2i since it is now unused --- edm4hep.yaml | 21 --------------------- test/utils/test_vector_utils.cpp | 27 ++++++++------------------- 2 files changed, 8 insertions(+), 40 deletions(-) diff --git a/edm4hep.yaml b/edm4hep.yaml index 0fbcf9e13..a2afa90da 100644 --- a/edm4hep.yaml +++ b/edm4hep.yaml @@ -80,27 +80,6 @@ components: return *( &x + i ) ; }\n " - - edm4hep::Vector2i: - Members: - - int32_t a - - int32_t b - ExtraCode: - includes: "#include " - declaration: " - constexpr Vector2i() : a(0),b(0) {}\n - constexpr Vector2i(int32_t aa, int32_t bb) : a(aa),b(bb) {}\n - constexpr Vector2i( const int32_t* v) : a(v[0]), b(v[1]) {}\n - constexpr bool operator==(const Vector2i& v) const { return (a==v.a&&b==v.b) ; }\n - constexpr bool operator!=(const Vector2i& v) const { return !(*this == v) ; }\n - constexpr int operator[](unsigned i) const {\n - static_assert(\n - offsetof(Vector2i,a)+sizeof(Vector2i::a) == offsetof(Vector2i,b),\n - \"operator[] requires no padding\");\n - return *( &a + i ) ; }\n - " - - edm4hep::Vector2f: Members: - float a diff --git a/test/utils/test_vector_utils.cpp b/test/utils/test_vector_utils.cpp index c01975c17..89ce7aa93 100644 --- a/test/utils/test_vector_utils.cpp +++ b/test/utils/test_vector_utils.cpp @@ -5,16 +5,14 @@ #include "edm4hep/utils/vector_utils.h" #include "edm4hep/Vector2f.h" -#include "edm4hep/Vector2i.h" #include "edm4hep/Vector3d.h" #include "edm4hep/Vector3f.h" #include "edm4hep/Vector4f.h" #include #include -using Vector2And3Types = std::tuple; -using AllVectorTypes = - std::tuple; +using Vector2And3Types = std::tuple; +using AllVectorTypes = std::tuple; template constexpr V create(); @@ -39,11 +37,6 @@ constexpr edm4hep::Vector2f create() { return edm4hep::Vector2f{1.0f, 2.0f}; } -template <> -constexpr edm4hep::Vector2i create() { - return edm4hep::Vector2i{1, 2}; -} - TEMPLATE_LIST_TEST_CASE("Vector uniform getters", "[vector_utils]", AllVectorTypes) { using namespace edm4hep; @@ -52,7 +45,7 @@ TEMPLATE_LIST_TEST_CASE("Vector uniform getters", "[vector_utils]", AllVectorTyp STATIC_REQUIRE(utils::vector_x(vector) == utils::ValueType(1.0)); STATIC_REQUIRE(utils::vector_y(vector) == utils::ValueType(2.0)); // 2D vectors fill z component with 0 - if constexpr (std::is_same_v || std::is_same_v) { + if constexpr (std::is_same_v) { STATIC_REQUIRE(utils::vector_z(vector) == utils::ValueType(0.0)); } else if constexpr (std::is_same_v) { STATIC_REQUIRE(utils::vector_t(vector) == utils::ValueType(4.0)); @@ -63,7 +56,6 @@ TEMPLATE_LIST_TEST_CASE("Vector uniform getters", "[vector_utils]", AllVectorTyp TEST_CASE("Vector ValueType", "[vector_utils]") { using namespace edm4hep; - STATIC_REQUIRE(std::is_same_v>); STATIC_REQUIRE(std::is_same_v>); STATIC_REQUIRE(std::is_same_v>); STATIC_REQUIRE(std::is_same_v>); @@ -86,7 +78,7 @@ TEMPLATE_LIST_TEST_CASE("Vector operators", "[vector_utils]", AllVectorTypes) { STATIC_REQUIRE(sumV - vector1 == vector2); // Vector product (depends again on whether it is 2D or 3D) - if constexpr (std::is_same_v || std::is_same_v) { + if constexpr (std::is_same_v) { STATIC_REQUIRE(vector1 * vector2 == utils::ValueType(5)); } else if constexpr (std::is_same_v || std::is_same_v) { STATIC_REQUIRE(vector1 * vector2 == utils::ValueType(14)); @@ -100,16 +92,13 @@ TEMPLATE_LIST_TEST_CASE("Vector utility functionality", "[vector_utils]", Vector using namespace edm4hep; - // Can only normalize vectors with floating point numbers - if constexpr (!std::is_same_v) { - const auto normV = utils::normalizeVector(vector); - REQUIRE(utils::magnitude(normV) == Catch::Approx(1)); - REQUIRE(utils::projection(normV, vector) == Catch::Approx(1)); - } + const auto normV = utils::normalizeVector(vector); + REQUIRE(utils::magnitude(normV) == Catch::Approx(1)); + REQUIRE(utils::projection(normV, vector) == Catch::Approx(1)); // Small differences in expectations between 2D and 3D vectors for everything // that involves the z component - if constexpr (std::is_same_v || std::is_same_v) { + if constexpr (std::is_same_v) { REQUIRE(utils::magnitude(vector) == Catch::Approx(std::sqrt(5))); const auto otherVec = TestType(3, 4); From 06871e5184b2d6065d451a8471043dd68c66745a Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Wed, 18 Dec 2024 10:44:37 +0100 Subject: [PATCH 3/4] Update README links --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 45f7a669c..bc6796cfe 100644 --- a/README.md +++ b/README.md @@ -12,43 +12,43 @@ A generic event data model for future HEP collider experiments. | | | | |-|-|-| -| [Vector4f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L9) | [Vector3f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L34) | [Vector3d](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L56) | -| [Vector2i](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L84) | [Vector2f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L104) | [TrackState](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L203) | -| [Quantity](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L233) | [CovMatrix2f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L124) | [CovMatrix3f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L144) | -| [CovMatrix4f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L163) | [CovMatrix6f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L183) | | +| [Vector4f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L9) | [Vector3f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L34) | [Vector3d](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L56) | | +| [Vector2f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L83) | [TrackState](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L182) | [Quantity](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L212) | +| [CovMatrix2f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L103) | [CovMatrix3f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L123) | [CovMatrix4f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L142) | +| [CovMatrix6f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L162) | | | **Datatypes** | | | | |-|-|-| -| [EventHeader](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L242) | [MCParticle](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L254) | [SimTrackerHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L321) | -| [CaloHitContribution](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L362) | [SimCalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L374) | [RawCalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L385) | -| [CalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L394) | [ParticleID](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L405) | [Cluster](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L419) | -| [TrackerHit3D](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L451) | [TrackerHitPlane](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L477) | [RawTimeSeries](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L507) | -| [Track](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L521) | [Vertex](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L538) | [ReconstructedParticle](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L584) | -| [TimeSeries](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L623) | [RecDqdx](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L635) | | +| [EventHeader](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L221) | [MCParticle](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L233) | [SimTrackerHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L299) | +| [CaloHitContribution](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L340) | [SimCalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L352) | [RawCalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L363) | +| [CalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L372) | [ParticleID](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L383) | [Cluster](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L397) | +| [TrackerHit3D](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L429) | [TrackerHitPlane](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L455) | [RawTimeSeries](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L485) | +| [Track](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L499) | [Vertex](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L516) | [ReconstructedParticle](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L562) | +| [TimeSeries](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L601) | [RecDqdx](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L613) | | **Links** | | | | |-|-|-| -| [RecoMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L690) | [CaloHitSimCaloHitLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L714) | [TrackerHitSimTrackerHitLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L720) | -| [CaloHitMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L696) | [ClusterMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L702) | [TrackMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L708) | -| [VertexRecoParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L726) | | | +| [RecoMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L668) | [CaloHitSimCaloHitLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L692) | [TrackerHitSimTrackerHitLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L698) | +| [CaloHitMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L674) | [ClusterMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L680) | [TrackMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L686) | +| [VertexRecoParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L704) | | | **Generator related (meta-)data** | | | | |-|-|-| -| [GeneratorEventParameters](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L647) | | | -| [GeneratorPdfInfo](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L663) | | | +| [GeneratorEventParameters](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L625) | | | +| [GeneratorPdfInfo](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L641) | | | **Interfaces** | | | | |-|-|-| -| [TrackerHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L674) | | | +| [TrackerHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L652) | | | The tests and examples in the `tests` directory show how to read, write, and use these types in your code. From 607629baaeb374016411d68cae1eb02c9bfe2c79 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Wed, 18 Dec 2024 10:45:59 +0100 Subject: [PATCH 4/4] Fix typo --- test/test_EDM4hepFile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_EDM4hepFile.py b/test/test_EDM4hepFile.py index 1a195a56f..d750d38f8 100644 --- a/test/test_EDM4hepFile.py +++ b/test/test_EDM4hepFile.py @@ -158,7 +158,7 @@ def test_MCParticleCollection(event, edm4hep_version): assert particle.getSpin() == edm4hep.Vector3f(next(counter), next(counter), next(counter)) if edm4hep_version < podio.version.parse("0.99.2"): - # The colorFlow as here so we have increase the counter here to + # The colorFlow was here so we have increase the counter here to # maintain the expected values for all elements of the collection next(counter) next(counter)