From a192bb549e78127361ad8a0a8f2500a04acc2a99 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Wed, 19 Feb 2025 15:07:27 +0100 Subject: [PATCH] Keep backwards compatibility with older podio versions --- k4FWCore/components/IOSvc.cpp | 7 ++++++- k4FWCore/src/PodioDataSvc.cpp | 17 +++++++++++++++++ test/k4FWCoreTest/scripts/CheckOutputFiles.py | 5 +++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/k4FWCore/components/IOSvc.cpp b/k4FWCore/components/IOSvc.cpp index 2a2b770b..634e9eba 100644 --- a/k4FWCore/components/IOSvc.cpp +++ b/k4FWCore/components/IOSvc.cpp @@ -22,6 +22,7 @@ #include "podio/Frame.h" #include "podio/FrameCategories.h" #include "podio/Reader.h" +#include "podio/podioVersion.h" #include "k4FWCore/FunctionalUtils.h" #include "k4FWCore/KeepDropSwitch.h" @@ -116,7 +117,11 @@ std::tuple, std::vector, podio: if (m_nextEntry < m_entries) { debug() << "Reading event " << m_nextEntry << endmsg; debug() << "Reading collections " << m_collectionNames << endmsg; - frame = podio::Frame(m_reader->readEvent(m_nextEntry, m_collectionNames)); +#if PODIO_BUILD_VERSION <= PODIO_VERSION(1, 2, 0) + frame = m_reader->readEvent(m_nextEntry); +#else + frame = m_reader->readEvent(m_nextEntry, m_collectionNames); +#endif } else { return std::make_tuple(std::vector(), std::vector(), std::move(frame)); } diff --git a/k4FWCore/src/PodioDataSvc.cpp b/k4FWCore/src/PodioDataSvc.cpp index 02bda07b..8b2ba40e 100644 --- a/k4FWCore/src/PodioDataSvc.cpp +++ b/k4FWCore/src/PodioDataSvc.cpp @@ -24,6 +24,7 @@ #include "k4FWCore/DataWrapper.h" #include "podio/CollectionBase.h" +#include "podio/podioVersion.h" /// Service initialisation StatusCode PodioDataSvc::initialize() { @@ -104,7 +105,15 @@ StatusCode PodioDataSvc::i_setRoot(std::string root_path, IOpaqueAddress* pRootA // create a new frame if (m_reading_from_file) { debug() << "Reading event " << m_eventNum + m_1stEvtEntry << ", using collections: " << m_collsToRead << endmsg; +#if PODIO_BUILD_VERSION <= PODIO_VERSION(1, 2, 0) + if (!m_collsToRead.empty()) { + warning() << "Trying to limit collections that are read, but podio does only support this with version > 1.2" + << endmsg; + } + m_eventframe = podio::Frame(m_reader.readEntry("events", m_eventNum + m_1stEvtEntry)); +#else m_eventframe = podio::Frame(m_reader.readEntry("events", m_eventNum + m_1stEvtEntry, m_collsToRead)); +#endif } else { m_eventframe = podio::Frame(); } @@ -115,7 +124,15 @@ StatusCode PodioDataSvc::i_setRoot(std::string root_path, DataObject* pRootObj) // create a new frame if (m_reading_from_file) { debug() << "Reading event " << m_eventNum + m_1stEvtEntry << ", using collections: " << m_collsToRead << endmsg; +#if PODIO_BUILD_VERSION <= PODIO_VERSION(1, 2, 0) + if (!m_collsToRead.empty()) { + warning() << "Trying to limit collections that are read, but podio does only support this with version > 1.2" + << endmsg; + } + m_eventframe = podio::Frame(m_reader.readEntry("events", m_eventNum + m_1stEvtEntry)); +#else m_eventframe = podio::Frame(m_reader.readEntry("events", m_eventNum + m_1stEvtEntry, m_collsToRead)); +#endif } else { m_eventframe = podio::Frame(); } diff --git a/test/k4FWCoreTest/scripts/CheckOutputFiles.py b/test/k4FWCoreTest/scripts/CheckOutputFiles.py index a58e5b31..4639c650 100644 --- a/test/k4FWCoreTest/scripts/CheckOutputFiles.py +++ b/test/k4FWCoreTest/scripts/CheckOutputFiles.py @@ -120,8 +120,9 @@ def check_metadata(filename, expected_metadata): ], ) -check_collections("output_k4test_exampledata_limited.root", ["MCParticles", "Links"]) -check_collections("functional_limited_input.root", ["MCParticles", "Links"]) +if podio.version.build_version > podio.version.parse("1.2.0"): + check_collections("output_k4test_exampledata_limited.root", ["MCParticles", "Links"]) + check_collections("functional_limited_input.root", ["MCParticles", "Links"]) mix_collections = [ # From file