Skip to content

Commit

Permalink
Switch to templated links and remove explicit declarations from yaml …
Browse files Browse the repository at this point in the history
…file (#373)

* Replace Link datatypes with type defs

* Implement necessary schema evolution to read old links

* Simplify schema evolution code by reusing buffers

* Use new links category to define links

* Remove legacy association headers

* Re-organize headers slightly

* Fix README links

* Rename old schema (evolution) shared lib
  • Loading branch information
tmadlener authored Dec 18, 2024
1 parent fe5a540 commit d651cd6
Show file tree
Hide file tree
Showing 29 changed files with 267 additions and 447 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ A generic event data model for future HEP collider experiments.
| [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#L813) | [RecDqdx](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L825) | |
| [TimeSeries](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L623) | [RecDqdx](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L635) | |

**Links**

| | | |
|-|-|-|
| [RecoMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L622) | [CaloHitSimCaloHitLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L649) | [TrackerHitSimTrackerHitLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L677) |
| [CaloHitMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L704) | [ClusterMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L731) | [TrackMCParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L758) |
| [VertexRecoParticleLink](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L785) | | |
| [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) | | |

**Generator related (meta-)data**

| | | |
|-|-|-|
| [GeneratorEventParameters](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L837) | | |
| [GeneratorPdfInfo](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L853) | | |
| [GeneratorEventParameters](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L647) | | |
| [GeneratorPdfInfo](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L663) | | |

**Interfaces**

| | | |
|-|-|-|
| [TrackerHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L864) | | |
| [TrackerHit](https://github.com/key4hep/EDM4hep/blob/main/edm4hep.yaml#L674) | | |

The tests and examples in the `tests` directory show how to read, write, and use these types in your code.

Expand Down
235 changes: 44 additions & 191 deletions edm4hep.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
schema_version: 2
schema_version: 3
options:
getSyntax: True
exposePODMembers: False
Expand Down Expand Up @@ -619,196 +619,6 @@ datatypes:
void setCovMatrix(float value, edm4hep::FourMomCoords dimI, edm4hep::FourMomCoords dimJ) { getCovMatrix().setValue(value, dimI, dimJ); }\n
"

edm4hep::RecoMCParticleLink:
Description: "Link between a ReconstructedParticle and the corresponding MCParticle"
Author: "EDM4hep authors"
Members:
- float weight // weight of this link
OneToOneRelations:
- edm4hep::ReconstructedParticle from // reference to the reconstructed particle
- edm4hep::MCParticle to // reference to the Monte-Carlo particle
ExtraCode:
declaration: "
[[deprecated(\"use getFrom instead\")]] edm4hep::ReconstructedParticle getRec() const;\n
[[deprecated(\"use getTo instead\")]] edm4hep::MCParticle getSim() const;\n"
implementation: "
edm4hep::ReconstructedParticle {name}::getRec() const { return getFrom(); }\n
edm4hep::MCParticle {name}::getSim() const { return getTo(); }\n"
MutableExtraCode:
declaration: "
[[deprecated(\"use setFrom instead\")]]\n
void setRec(const edm4hep::ReconstructedParticle& rec);\n
[[deprecated(\"use setTo instead\")]]\n
void setSim(const edm4hep::MCParticle& sim);\n
"
implementation: "
void {name}::setSim(const edm4hep::MCParticle& sim) { setTo(sim); }\n
void {name}::setRec(const edm4hep::ReconstructedParticle& rec) { setFrom(rec); }\n
"

edm4hep::CaloHitSimCaloHitLink:
Description: "Link between a CalorimeterHit and the corresponding SimCalorimeterHit"
Author: "EDM4hep authors"
Members:
- float weight // weight of this link
OneToOneRelations:
- edm4hep::CalorimeterHit from // reference to the reconstructed hit
- edm4hep::SimCalorimeterHit to // reference to the simulated hit
ExtraCode:
declaration: "
[[deprecated(\"use getFrom instead\")]] edm4hep::CalorimeterHit getRec() const;\n
[[deprecated(\"use getTo instead\")]] edm4hep::SimCalorimeterHit getSim() const;\n"
implementation: "
edm4hep::CalorimeterHit {name}::getRec() const { return getFrom(); }\n
edm4hep::SimCalorimeterHit {name}::getSim() const { return getTo(); }\n"
MutableExtraCode:
declaration: "
[[deprecated(\"use setFrom instead\")]]\n
void setRec(const edm4hep::CalorimeterHit& rec);\n
[[deprecated(\"use setTo instead\")]]\n
void setSim(const edm4hep::SimCalorimeterHit& sim);\n
"
implementation: "
void {name}::setSim(const edm4hep::SimCalorimeterHit& sim) { setTo(sim); }\n
void {name}::setRec(const edm4hep::CalorimeterHit& rec) { setFrom(rec); }\n
"


edm4hep::TrackerHitSimTrackerHitLink:
Description: "Link between a TrackerHit and the corresponding SimTrackerHit"
Author: "EDM4hep authors"
Members:
- float weight // weight of this link
OneToOneRelations:
- edm4hep::TrackerHit from // reference to the reconstructed hit
- edm4hep::SimTrackerHit to // reference to the simulated hit
ExtraCode:
declaration: "
[[deprecated(\"use getFrom instead\")]] edm4hep::TrackerHit getRec() const;\n
[[deprecated(\"use getTo instead\")]] edm4hep::SimTrackerHit getSim() const;\n"
implementation: "
edm4hep::TrackerHit {name}::getRec() const { return getFrom(); }\n
edm4hep::SimTrackerHit {name}::getSim() const { return getTo(); }\n"
MutableExtraCode:
declaration: "
[[deprecated(\"use setFrom instead\")]]\n
void setRec(const edm4hep::TrackerHit& rec);\n
[[deprecated(\"use setTo instead\")]]\n
void setSim(const edm4hep::SimTrackerHit& sim);\n
"
implementation: "
void {name}::setSim(const edm4hep::SimTrackerHit& sim) { setTo(sim); }\n
void {name}::setRec(const edm4hep::TrackerHit& rec) { setFrom(rec); }\n
"

edm4hep::CaloHitMCParticleLink:
Description: "Link between a CalorimeterHit and the corresponding MCParticle"
Author: "EDM4hep authors"
Members:
- float weight // weight of this link
OneToOneRelations:
- edm4hep::CalorimeterHit from // reference to the reconstructed hit
- edm4hep::MCParticle to // reference to the Monte-Carlo particle
ExtraCode:
declaration: "
[[deprecated(\"use getFrom instead\")]] edm4hep::CalorimeterHit getRec() const;\n
[[deprecated(\"use getTo instead\")]] edm4hep::MCParticle getSim() const;\n"
implementation: "
edm4hep::CalorimeterHit {name}::getRec() const { return getFrom(); }\n
edm4hep::MCParticle {name}::getSim() const { return getTo(); }\n"
MutableExtraCode:
declaration: "
[[deprecated(\"use setFrom instead\")]]\n
void setRec(const edm4hep::CalorimeterHit& rec);\n
[[deprecated(\"use setTo instead\")]]\n
void setSim(const edm4hep::MCParticle& sim);\n
"
implementation: "
void {name}::setSim(const edm4hep::MCParticle& sim) { setTo(sim); }\n
void {name}::setRec(const edm4hep::CalorimeterHit& rec) { setFrom(rec); }\n
"

edm4hep::ClusterMCParticleLink:
Description: "Link between a Cluster and the corresponding MCParticle"
Author: "EDM4hep authors"
Members:
- float weight // weight of this link
OneToOneRelations:
- edm4hep::Cluster from // reference to the cluster
- edm4hep::MCParticle to // reference to the Monte-Carlo particle
ExtraCode:
declaration: "
[[deprecated(\"use getFrom instead\")]] edm4hep::Cluster getRec() const;\n
[[deprecated(\"use getTo instead\")]] edm4hep::MCParticle getSim() const;\n"
implementation: "
edm4hep::Cluster {name}::getRec() const { return getFrom(); }\n
edm4hep::MCParticle {name}::getSim() const { return getTo(); }\n"
MutableExtraCode:
declaration: "
[[deprecated(\"use setFrom instead\")]]\n
void setRec(const edm4hep::Cluster& rec);\n
[[deprecated(\"use setTo instead\")]]\n
void setSim(const edm4hep::MCParticle& sim);\n
"
implementation: "
void {name}::setSim(const edm4hep::MCParticle& sim) { setTo(sim); }\n
void {name}::setRec(const edm4hep::Cluster& rec) { setFrom(rec); }\n
"

edm4hep::TrackMCParticleLink:
Description: "Link between a Track and the corresponding MCParticle"
Author: "EDM4hep authors"
Members:
- float weight // weight of this link
OneToOneRelations:
- edm4hep::Track from // reference to the track
- edm4hep::MCParticle to // reference to the Monte-Carlo particle
ExtraCode:
declaration: "
[[deprecated(\"use getFrom instead\")]] edm4hep::Track getRec() const;\n
[[deprecated(\"use getTo instead\")]] edm4hep::MCParticle getSim() const;\n"
implementation: "
edm4hep::Track {name}::getRec() const { return getFrom(); }\n
edm4hep::MCParticle {name}::getSim() const { return getTo(); }\n"
MutableExtraCode:
declaration: "
[[deprecated(\"use setFrom instead\")]]\n
void setRec(const edm4hep::Track& rec);\n
[[deprecated(\"use setTo instead\")]]\n
void setSim(const edm4hep::MCParticle& sim);\n
"
implementation: "
void {name}::setSim(const edm4hep::MCParticle& sim) { setTo(sim); }\n
void {name}::setRec(const edm4hep::Track& rec) { setFrom(rec); }\n
"

edm4hep::VertexRecoParticleLink:
Description: "Link between a Vertex and a ReconstructedParticle"
Author: "EDM4hep authors"
Members:
- float weight // weight of this link
OneToOneRelations:
- edm4hep::ReconstructedParticle to // reference to the reconstructed particle
- edm4hep::Vertex from // reference to the vertex
ExtraCode:
declaration: "
[[deprecated(\"use getTo instead\")]] edm4hep::ReconstructedParticle getRec() const;\n
[[deprecated(\"use getFrom instead\")]] edm4hep::Vertex getVertex() const;\n"
implementation: "
edm4hep::ReconstructedParticle {name}::getRec() const { return getTo(); }\n
edm4hep::Vertex {name}::getVertex() const { return getFrom(); }\n"
MutableExtraCode:
declaration: "
[[deprecated(\"use setFrom instead\")]]\n
void setVertex(const edm4hep::Vertex& rec);\n
[[deprecated(\"use setTo instead\")]]\n
void setRec(const edm4hep::ReconstructedParticle& sim);\n
"
implementation: "
void {name}::setVertex(const edm4hep::Vertex& vertex) { setFrom(vertex); }\n
void {name}::setRec(const edm4hep::ReconstructedParticle& rec) { setTo(rec); }\n
"


edm4hep::TimeSeries:
Description: "Calibrated Detector Data"
Expand Down Expand Up @@ -875,3 +685,46 @@ interfaces:
Types:
- edm4hep::TrackerHit3D
- edm4hep::TrackerHitPlane

links:
edm4hep::RecoMCParticleLink:
Description: "Link between a ReconstructedParticle and an MCParticle"
Author: "EDM4hep authors"
From: edm4hep::ReconstructedParticle
To: edm4hep::MCParticle

edm4hep::CaloHitMCParticleLink:
Description: "Link between a CalorimeterHit and an MCParticle"
Author: "EDM4hep authors"
From: edm4hep::CalorimeterHit
To: edm4hep::MCParticle

edm4hep::ClusterMCParticleLink:
Description: "Link between a Cluster and an MCParticle"
Author: "EDM4hep authors"
From: edm4hep::Cluster
To: edm4hep::MCParticle

edm4hep::TrackMCParticleLink:
Description: "Link between a Track and an MCParticle"
Author: "EDM4hep authors"
From: edm4hep::Track
To: edm4hep::MCParticle

edm4hep::CaloHitSimCaloHitLink:
Description: "Link between a CalorimeterHit and a SimCalorimeterHit"
Author: "EDM4hep authors"
From: edm4hep::CalorimeterHit
To: edm4hep::SimCalorimeterHit

edm4hep::TrackerHitSimTrackerHitLink:
Description: "Link between a TrackerHit and a SimTrackerHit"
Author: "EDM4hep authors"
From: edm4hep::TrackerHit
To: edm4hep::SimTrackerHit

edm4hep::VertexRecoParticleLink:
Description: "Link between a Vertex and a ReconstructedParticle"
Author: "EDM4hep authors"
From: edm4hep::Vertex
To: edm4hep::ReconstructedParticle
8 changes: 8 additions & 0 deletions edm4hep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ endif()
PODIO_ADD_ROOT_IO_DICT(edm4hepDict edm4hep "${headers}" src/selection.xml)
add_library(EDM4HEP::edm4hepDict ALIAS edm4hepDict )

add_library(edm4hepOldSchemas SHARED schema_evolution/src/OldLinkEvolution.cc)
target_include_directories(edm4hepOldSchemas PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/edm4hep/schema_evolution/include>
)
target_link_libraries(edm4hepOldSchemas PUBLIC podio::podio EDM4HEP::edm4hep)

PODIO_ADD_ROOT_IO_DICT(edm4hepOldSchemasDict edm4hepOldSchemas ${PROJECT_SOURCE_DIR}/edm4hep/schema_evolution/include/edm4hep/schema_evolution/OldLinkData.h schema_evolution/src/selection.xml)

list(APPEND EDM4HEP_INSTALL_LIBS edm4hep edm4hepDict)

PODIO_ADD_SIO_IO_BLOCKS(edm4hep "${headers}" "${sources}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef EDM4HEP_SCHEMA_EVOLUTION_OLDLINKDATA_H
#define EDM4HEP_SCHEMA_EVOLUTION_OLDLINKDATA_H

#define MAKE_DATA_STRUCT(name) \
struct name { \
float weight{}; \
};

namespace edm4hep {

MAKE_DATA_STRUCT(RecoMCParticleLinkData)
MAKE_DATA_STRUCT(CaloHitMCParticleLinkData)
MAKE_DATA_STRUCT(ClusterMCParticleLinkData)
MAKE_DATA_STRUCT(TrackMCParticleLinkData)
MAKE_DATA_STRUCT(CaloHitSimCaloHitLinkData)
MAKE_DATA_STRUCT(TrackerHitSimTrackerHitLinkData)
MAKE_DATA_STRUCT(VertexRecoParticleLinkData)

} // namespace edm4hep

#undef MAKE_DATA_STRUCT

#endif // EDM4HEP_SCHEMA_EVOLUTION_OLDLINKDATA_H
Loading

0 comments on commit d651cd6

Please sign in to comment.