Skip to content

Commit

Permalink
ReadEDM4hep: make metadata and runs frame optional
Browse files Browse the repository at this point in the history
  • Loading branch information
andresailer committed Dec 17, 2024
1 parent 0e84b3a commit 818d1f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
20 changes: 16 additions & 4 deletions DDG4/edm4hep/EDM4hepFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,22 @@ namespace dd4hep::sim {
void EDM4hepFileReader::registerRunParameters() {
try {
auto *parameters = new RunParameters();
podio::Frame runFrame = m_reader.readEntry("runs", 0);
parameters->ingestParameters(runFrame.getParameters());
podio::Frame metaFrame = m_reader.readEntry("metadata", 0);
parameters->ingestParameters(metaFrame.getParameters());
try {
podio::Frame runFrame = m_reader.readEntry("runs", 0);
parameters->ingestParameters(runFrame.getParameters());
} catch (std::runtime_error& e) {
// we ignore if we do not have runs information
} catch(std::invalid_argument&) {
// we ignore if we do not have runs information
}
try {
podio::Frame metaFrame = m_reader.readEntry("metadata", 0);
parameters->ingestParameters(metaFrame.getParameters());
} catch (std::runtime_error& e) {
// we ignore if we do not have metadata information
} catch(std::invalid_argument&) {
// we ignore if we do not have metadata information
}
context()->run().addExtension<RunParameters>(parameters);
} catch(std::exception &e) {
printout(ERROR,"EDM4hepFileReader::registerRunParameters","Failed to register run parameters: %s", e.what());
Expand Down
9 changes: 9 additions & 0 deletions DDTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ if (DD4HEP_USE_GEANT4)
PASS_REGULAR_EXPRESSION "Deleting object StepActionCLI1"
)

if(DD4HEP_USE_EDM4HEP)
add_test( t_ddsimEDM4hepPlugins "${CMAKE_INSTALL_PREFIX}/bin/run_test.sh"
ddsim --compactFile=${CMAKE_INSTALL_PREFIX}/DDDetectors/compact/SiD.xml --runType=batch -N=3
--outputFile=ddsim_edm4hep_ZH.root
--inputFiles=${CMAKE_CURRENT_SOURCE_DIR}/inputFiles/ZH250_ISR.edm4hep.root
--part.userParticleHandler=
)
endif()

endif()
install(DIRECTORY include/DD4hep DESTINATION include)

Expand Down

0 comments on commit 818d1f6

Please sign in to comment.