From 6f8e8580b0767ce3964096e8b58a2cfc297f74ec Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Tue, 23 Jan 2024 20:19:38 +0100 Subject: [PATCH] Make MCParticle momenta use doubles instead of floats (#237) * Make momentum use doubles instead of floats * Fix python unittests * Add a constructor from Vector3f for Vector3d This direction should not suffer from narrowing --- README.md | 26 +++++++++++++------------- edm4hep.yaml | 7 +++++-- test/utils/test_kinematics.py | 4 ++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 52ce10b38..b8fabfe45 100644 --- a/README.md +++ b/README.md @@ -13,30 +13,30 @@ 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#L26) | [Vector3d](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L41) | -| [Vector2i](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L57) | [Vector2f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L71) | [TrackState](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L85) | -| [ObjectID](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L108) | [Quantity](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L120) | [Hypothesis](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L128) | -| [HitLevelData](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L135) | | | +| [Vector2i](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L60) | [Vector2f](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L74) | [TrackState](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L88) | +| [ObjectID](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L111) | [Quantity](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L123) | [Hypothesis](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L131) | +| [HitLevelData](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L138) | | | **Datatypes** | | | | |-|-|-| -| [EventHeader](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L145) | [MCParticle](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L157) | [SimTrackerHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L226) | -| [CaloHitContribution](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L268) | [SimCalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L280) | [RawCalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L292) | -| [CalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L301) | [ParticleID](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L313) | [Cluster](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L326) | -| [TrackerHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L347) | [TrackerHitPlane](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L364) | [RawTimeSeries](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L385) | -| [Track](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L398) | [Vertex](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L417) | [ReconstructedParticle](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L434) | -| [SimPrimaryIonizationCluster](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L538) | [TrackerPulse](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L572) | [RecIonizationCluster](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L585) | -| [TimeSeries](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L596) | [RecDqdx](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L608) | | +| [EventHeader](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L148) | [MCParticle](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L160) | [SimTrackerHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L229) | +| [CaloHitContribution](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L271) | [SimCalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L283) | [RawCalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L295) | +| [CalorimeterHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L304) | [ParticleID](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L316) | [Cluster](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L329) | +| [TrackerHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L350) | [TrackerHitPlane](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L367) | [RawTimeSeries](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L388) | +| [Track](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L401) | [Vertex](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L420) | [ReconstructedParticle](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L437) | +| [SimPrimaryIonizationCluster](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L541) | [TrackerPulse](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L575) | [RecIonizationCluster](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L588) | +| [TimeSeries](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L599) | [RecDqdx](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L611) | | **Associations** | | | | |-|-|-| -| [MCRecoParticleAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L464) | [MCRecoCaloAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L473) | [MCRecoTrackerAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L482) | -| [MCRecoTrackerHitPlaneAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L491) | [MCRecoCaloParticleAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L500) | [MCRecoClusterParticleAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L509) | -| [MCRecoTrackParticleAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L518) | [RecoParticleVertexAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L527) | | +| [MCRecoParticleAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L467) | [MCRecoCaloAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L476) | [MCRecoTrackerAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L485) | +| [MCRecoTrackerHitPlaneAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L494) | [MCRecoCaloParticleAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L503) | [MCRecoClusterParticleAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L512) | +| [MCRecoTrackParticleAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L521) | [RecoParticleVertexAssociation](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L530) | | The tests and examples in the `tests` directory show how to read, write, and use these types in your code. diff --git a/edm4hep.yaml b/edm4hep.yaml index ea2042af1..b4689a91b 100644 --- a/edm4hep.yaml +++ b/edm4hep.yaml @@ -44,11 +44,14 @@ components: - double y - double z ExtraCode: + includes: "#include " declaration: " constexpr Vector3d() : x(0),y(0),z(0) {}\n constexpr Vector3d(double xx, double yy, double zz) : x(xx),y(yy),z(zz) {}\n constexpr Vector3d(const double* v) : x(v[0]),y(v[1]),z(v[2]) {}\n constexpr Vector3d(const float* v) : x(v[0]),y(v[1]),z(v[2]) {}\n + [[ deprecated(\"This constructor will be removed again it is mainly here for an easier transition\") ]]\n + constexpr Vector3d(const Vector3f& v) : x(v.x), y(v.y), z(v.z) {}\n constexpr bool operator==(const Vector3d& v) const { return (x==v.x&&y==v.y&&z==v.z) ; }\n constexpr double operator[](unsigned i) const { return *( &x + i ) ; }\n " @@ -166,8 +169,8 @@ datatypes: - double mass //mass of the particle in [GeV] - edm4hep::Vector3d vertex //production vertex of the particle in [mm]. - edm4hep::Vector3d endpoint //endpoint of the particle in [mm] - - edm4hep::Vector3f momentum //particle 3-momentum at the production vertex in [GeV] - - edm4hep::Vector3f momentumAtEndpoint //particle 3-momentum at the endpoint in [GeV] + - edm4hep::Vector3d momentum //particle 3-momentum at the production vertex in [GeV] + - edm4hep::Vector3d momentumAtEndpoint //particle 3-momentum at the endpoint in [GeV] - edm4hep::Vector3f spin //spin (helicity) vector of the particle. - edm4hep::Vector2i colorFlow //color flow as defined by the generator OneToManyRelations: diff --git a/test/utils/test_kinematics.py b/test/utils/test_kinematics.py index 80c8c2a99..c563ecf38 100644 --- a/test/utils/test_kinematics.py +++ b/test/utils/test_kinematics.py @@ -31,8 +31,8 @@ def test_p4(self): 125.0, # charge edm4hep.Vector3d(0, 0, 0), # vertex edm4hep.Vector3d(0, 0, 0), # endpoint - edm4hep.Vector3f(1.0, 2.0, 3.0), # momentum - edm4hep.Vector3f(0, 0, 0), # momentumAtEndpoint + 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 )