Skip to content

Commit

Permalink
Change link name to follow edm4hep convention (#140)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tmadlener authored Dec 3, 2024
1 parent c79aaf7 commit a3c5b0e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T> std::ostream& operator<<(std::ostream& os, std::vector<T> const& container) {
Expand Down Expand Up @@ -160,7 +160,7 @@ namespace k4SimDelphes {
}

settings.RecoMCParticleLinkCollectionName =
confReader->GetString("EDM4HepOutput::RecoMCParticleLinkCollectionName", "MCRecoAssociations");
confReader->GetString("EDM4HepOutput::RecoMCParticleLinkCollectionName", "RecoMCLink");

return settings;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/edm4hep_output_config.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ module EDM4HepOutput EDM4HepOutput {
add MissingETCollections MissingET
add ScalarHTCollections ScalarHT
set RecoParticleCollectionName ReconstructedParticles
set RecoMCParticleLinkCollectionName MCRecoAssociations
set RecoMCParticleLinkCollectionName RecoMCLink
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ module EDM4HepOutput EDM4HepOutput {
add MissingETCollections MissingET
add ScalarHTCollections ScalarHT
set RecoParticleCollectionName ReconstructedParticles
set MCRecoAssociationCollectionName MCRecoAssociations
set MCRecoAssociationCollectionName RecoMCLink
}
10 changes: 5 additions & 5 deletions framework/k4SimDelphes/src/k4SimDelphesAlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ StatusCode k4SimDelphesAlg::initialize() {
m_eventDataSvc.retrieve().ignore();
m_podioDataSvc = dynamic_cast<PodioDataSvc*>(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<k4SimDelphes::DelphesEDM4HepConverter>(
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<k4SimDelphes::DelphesEDM4HepConverter>(
branches, m_outputConfig, m_confReader->GetDouble("ParticlePropagator::Bz", 0));

return StatusCode::SUCCESS;
}
Expand Down Expand Up @@ -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<podio::CollectionBase>* wrapper = new DataWrapper<podio::CollectionBase>();
wrapper->setData(new_c);
Expand Down
1 change: 1 addition & 0 deletions framework/k4SimDelphes/src/k4SimDelphesAlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class k4SimDelphesAlg : public Gaudi::Algorithm {
Gaudi::Property<std::string> m_DelphesOutputSettings{
this, "DelphesOutputSettings", "", "Name of config file with k4simdelphes specific output settings"};

k4SimDelphes::OutputSettings m_outputConfig{};
std::unique_ptr<Delphes> m_Delphes{nullptr};
std::unique_ptr<ExRootConfReader> m_confReader{nullptr};
std::unique_ptr<k4SimDelphes::DelphesEDM4HepConverter> m_edm4hepConverter{nullptr};
Expand Down
2 changes: 1 addition & 1 deletion tests/src/compare_delphes_converter_outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ int main(int, char* argv[]) {
return 1;
}

auto& mcRecoAssocColl = frame.get<edm4hep::RecoMCParticleLinkCollection>("MCRecoAssociations");
auto& mcRecoAssocColl = frame.get<edm4hep::RecoMCParticleLinkCollection>("RecoMCLink");

compareCollectionElements<Track>(tracks, recoColl, "EFlowTrack", 0, mcRecoAssocColl);
compareCollectionElements<Tower>(ecalClusters, recoColl, "EFlowPhoton", tracks->GetEntries(), mcRecoAssocColl);
Expand Down

0 comments on commit a3c5b0e

Please sign in to comment.