From 818d1f619f6773a06b4bc4bd66528fa422684a9c Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Tue, 17 Dec 2024 17:17:26 +0100 Subject: [PATCH] ReadEDM4hep: make metadata and runs frame optional --- DDG4/edm4hep/EDM4hepFileReader.cpp | 20 ++++++++++++++++---- DDTest/CMakeLists.txt | 9 +++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/DDG4/edm4hep/EDM4hepFileReader.cpp b/DDG4/edm4hep/EDM4hepFileReader.cpp index ff68a8c10..1613f14bd 100644 --- a/DDG4/edm4hep/EDM4hepFileReader.cpp +++ b/DDG4/edm4hep/EDM4hepFileReader.cpp @@ -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(parameters); } catch(std::exception &e) { printout(ERROR,"EDM4hepFileReader::registerRunParameters","Failed to register run parameters: %s", e.what()); diff --git a/DDTest/CMakeLists.txt b/DDTest/CMakeLists.txt index 9472aa307..e24d9d623 100644 --- a/DDTest/CMakeLists.txt +++ b/DDTest/CMakeLists.txt @@ -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)