From a3c5b0efdaa071201b863e4bfc3411934107e37c Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Tue, 3 Dec 2024 17:07:44 +0100 Subject: [PATCH] Change link name to follow edm4hep convention (#140) * Change link name to follow edm4hep convention Change the reco - mc link name to follow the EDM4hep convention in the example EDM4hep output configuration. * Change default name in more places * Make framework alg properly take into account configuration --- .../k4SimDelphes/DelphesEDM4HepOutputConfiguration.h | 4 ++-- examples/edm4hep_output_config.tcl | 2 +- .../examples/options/edm4hep_output_config.tcl | 2 +- framework/k4SimDelphes/src/k4SimDelphesAlg.cpp | 10 +++++----- framework/k4SimDelphes/src/k4SimDelphesAlg.h | 1 + tests/src/compare_delphes_converter_outputs.cpp | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/converter/include/k4SimDelphes/DelphesEDM4HepOutputConfiguration.h b/converter/include/k4SimDelphes/DelphesEDM4HepOutputConfiguration.h index ae309607..1b2bfd10 100644 --- a/converter/include/k4SimDelphes/DelphesEDM4HepOutputConfiguration.h +++ b/converter/include/k4SimDelphes/DelphesEDM4HepOutputConfiguration.h @@ -81,7 +81,7 @@ namespace k4SimDelphes { * Name of the RecoMCParticleLinkCollection holding the links of * generated to reconstructed particles. */ - std::string RecoMCParticleLinkCollectionName{"MCRecoAssociations"}; + std::string RecoMCParticleLinkCollectionName{"RecoMCLink"}; }; template std::ostream& operator<<(std::ostream& os, std::vector const& container) { @@ -160,7 +160,7 @@ namespace k4SimDelphes { } settings.RecoMCParticleLinkCollectionName = - confReader->GetString("EDM4HepOutput::RecoMCParticleLinkCollectionName", "MCRecoAssociations"); + confReader->GetString("EDM4HepOutput::RecoMCParticleLinkCollectionName", "RecoMCLink"); return settings; } diff --git a/examples/edm4hep_output_config.tcl b/examples/edm4hep_output_config.tcl index ce7091c5..5fce728a 100644 --- a/examples/edm4hep_output_config.tcl +++ b/examples/edm4hep_output_config.tcl @@ -9,5 +9,5 @@ module EDM4HepOutput EDM4HepOutput { add MissingETCollections MissingET add ScalarHTCollections ScalarHT set RecoParticleCollectionName ReconstructedParticles - set RecoMCParticleLinkCollectionName MCRecoAssociations + set RecoMCParticleLinkCollectionName RecoMCLink } diff --git a/framework/k4SimDelphes/examples/options/edm4hep_output_config.tcl b/framework/k4SimDelphes/examples/options/edm4hep_output_config.tcl index e5e270df..492ae130 100644 --- a/framework/k4SimDelphes/examples/options/edm4hep_output_config.tcl +++ b/framework/k4SimDelphes/examples/options/edm4hep_output_config.tcl @@ -8,5 +8,5 @@ module EDM4HepOutput EDM4HepOutput { add MissingETCollections MissingET add ScalarHTCollections ScalarHT set RecoParticleCollectionName ReconstructedParticles - set MCRecoAssociationCollectionName MCRecoAssociations + set MCRecoAssociationCollectionName RecoMCLink } diff --git a/framework/k4SimDelphes/src/k4SimDelphesAlg.cpp b/framework/k4SimDelphes/src/k4SimDelphesAlg.cpp index 509f1bc7..1313473e 100644 --- a/framework/k4SimDelphes/src/k4SimDelphesAlg.cpp +++ b/framework/k4SimDelphes/src/k4SimDelphesAlg.cpp @@ -38,10 +38,10 @@ StatusCode k4SimDelphesAlg::initialize() { m_eventDataSvc.retrieve().ignore(); m_podioDataSvc = dynamic_cast(m_eventDataSvc.get()); - const auto branches = getBranchSettings(m_confReader->GetParam("TreeWriter::Branch")); - const auto outputSettings = getEDM4hepOutputSettings(m_DelphesOutputSettings.value().c_str()); - m_edm4hepConverter = std::make_unique( - branches, outputSettings, m_confReader->GetDouble("ParticlePropagator::Bz", 0)); + const auto branches = getBranchSettings(m_confReader->GetParam("TreeWriter::Branch")); + m_outputConfig = getEDM4hepOutputSettings(m_DelphesOutputSettings.value().c_str()); + m_edm4hepConverter = std::make_unique( + branches, m_outputConfig, m_confReader->GetDouble("ParticlePropagator::Bz", 0)); return StatusCode::SUCCESS; } @@ -70,7 +70,7 @@ StatusCode k4SimDelphesAlg::execute(const EventContext&) const { auto collections = m_edm4hepConverter->getCollections(); for (auto& c : collections) { - if (c.first == "MCRecoAssociations") { + if (c.first == m_outputConfig.RecoMCParticleLinkCollectionName) { auto new_c = m_edm4hepConverter->createExternalRecoMCLinks(mapSimDelphes); DataWrapper* wrapper = new DataWrapper(); wrapper->setData(new_c); diff --git a/framework/k4SimDelphes/src/k4SimDelphesAlg.h b/framework/k4SimDelphes/src/k4SimDelphesAlg.h index fa0b4569..9f2826ce 100644 --- a/framework/k4SimDelphes/src/k4SimDelphesAlg.h +++ b/framework/k4SimDelphes/src/k4SimDelphesAlg.h @@ -48,6 +48,7 @@ class k4SimDelphesAlg : public Gaudi::Algorithm { Gaudi::Property m_DelphesOutputSettings{ this, "DelphesOutputSettings", "", "Name of config file with k4simdelphes specific output settings"}; + k4SimDelphes::OutputSettings m_outputConfig{}; std::unique_ptr m_Delphes{nullptr}; std::unique_ptr m_confReader{nullptr}; std::unique_ptr m_edm4hepConverter{nullptr}; diff --git a/tests/src/compare_delphes_converter_outputs.cpp b/tests/src/compare_delphes_converter_outputs.cpp index d0684255..b16f9d76 100644 --- a/tests/src/compare_delphes_converter_outputs.cpp +++ b/tests/src/compare_delphes_converter_outputs.cpp @@ -397,7 +397,7 @@ int main(int, char* argv[]) { return 1; } - auto& mcRecoAssocColl = frame.get("MCRecoAssociations"); + auto& mcRecoAssocColl = frame.get("RecoMCLink"); compareCollectionElements(tracks, recoColl, "EFlowTrack", 0, mcRecoAssocColl); compareCollectionElements(ecalClusters, recoColl, "EFlowPhoton", tracks->GetEntries(), mcRecoAssocColl);