Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the colorFlow member from the MCParticle #389

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}" )

Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
22 changes: 0 additions & 22 deletions edm4hep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,6 @@ components:
return *( &x + i ) ; }\n
"


edm4hep::Vector2i:
Members:
- int32_t a
- int32_t b
ExtraCode:
includes: "#include <cstddef>"
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
Expand Down Expand Up @@ -266,7 +245,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
Expand Down
1 change: 0 additions & 1 deletion scripts/createEDM4hepFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
14 changes: 12 additions & 2 deletions test/test_EDM4hepFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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 was 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]
Expand Down
1 change: 0 additions & 1 deletion test/utils/test_kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
27 changes: 8 additions & 19 deletions test/utils/test_vector_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tuple>
#include <type_traits>
using Vector2And3Types = std::tuple<edm4hep::Vector3f, edm4hep::Vector3d, edm4hep::Vector2i, edm4hep::Vector2f>;
using AllVectorTypes =
std::tuple<edm4hep::Vector4f, edm4hep::Vector3f, edm4hep::Vector3d, edm4hep::Vector2i, edm4hep::Vector2f>;
using Vector2And3Types = std::tuple<edm4hep::Vector3f, edm4hep::Vector3d, edm4hep::Vector2f>;
using AllVectorTypes = std::tuple<edm4hep::Vector4f, edm4hep::Vector3f, edm4hep::Vector3d, edm4hep::Vector2f>;

template <typename V>
constexpr V create();
Expand All @@ -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;

Expand All @@ -52,7 +45,7 @@ TEMPLATE_LIST_TEST_CASE("Vector uniform getters", "[vector_utils]", AllVectorTyp
STATIC_REQUIRE(utils::vector_x(vector) == utils::ValueType<TestType>(1.0));
STATIC_REQUIRE(utils::vector_y(vector) == utils::ValueType<TestType>(2.0));
// 2D vectors fill z component with 0
if constexpr (std::is_same_v<TestType, edm4hep::Vector2i> || std::is_same_v<TestType, edm4hep::Vector2f>) {
if constexpr (std::is_same_v<TestType, edm4hep::Vector2f>) {
STATIC_REQUIRE(utils::vector_z(vector) == utils::ValueType<TestType>(0.0));
} else if constexpr (std::is_same_v<TestType, edm4hep::Vector4f>) {
STATIC_REQUIRE(utils::vector_t(vector) == utils::ValueType<TestType>(4.0));
Expand All @@ -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<int32_t, utils::ValueType<Vector2i>>);
STATIC_REQUIRE(std::is_same_v<float, utils::ValueType<Vector2f>>);
STATIC_REQUIRE(std::is_same_v<float, utils::ValueType<Vector3f>>);
STATIC_REQUIRE(std::is_same_v<double, utils::ValueType<Vector3d>>);
Expand All @@ -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<TestType, edm4hep::Vector2i> || std::is_same_v<TestType, edm4hep::Vector2f>) {
if constexpr (std::is_same_v<TestType, edm4hep::Vector2f>) {
STATIC_REQUIRE(vector1 * vector2 == utils::ValueType<TestType>(5));
} else if constexpr (std::is_same_v<TestType, edm4hep::Vector3f> || std::is_same_v<TestType, edm4hep::Vector3d>) {
STATIC_REQUIRE(vector1 * vector2 == utils::ValueType<TestType>(14));
Expand All @@ -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<TestType, Vector2i>) {
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<TestType, Vector2i> || std::is_same_v<TestType, Vector2f>) {
if constexpr (std::is_same_v<TestType, Vector2f>) {
REQUIRE(utils::magnitude(vector) == Catch::Approx(std::sqrt(5)));

const auto otherVec = TestType(3, 4);
Expand Down
Loading