From 012c4558e40f9d06c0918c6d875ce189416ce24f Mon Sep 17 00:00:00 2001 From: tmadlener Date: Fri, 17 Nov 2023 10:12:26 +0100 Subject: [PATCH] Default to reading all collections and allow to limit them --- k4FWCore/components/PodioInput.cpp | 9 ++++++++- k4FWCore/components/PodioInput.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/k4FWCore/components/PodioInput.cpp b/k4FWCore/components/PodioInput.cpp index 949a9053..28d655d7 100644 --- a/k4FWCore/components/PodioInput.cpp +++ b/k4FWCore/components/PodioInput.cpp @@ -193,7 +193,14 @@ void PodioInput::operator()() const { info() << "No EventHeader collection found in the event. Not reading it" << endmsg; } - for (const auto& collName : m_collectionNames) { + const auto& collsToRead = [&]() { + if (m_collectionNames.empty()) { + return m_podioDataSvc->getEventFrame().getAvailableCollections(); + } else { + return m_collectionNames.value(); + }}(); + + for (const auto& collName : collsToRead) { debug() << "Registering collection to read " << collName << endmsg; if (!m_podioDataSvc->hasCollection(collName)) { warning() << "Collection " << collName << " is not available from file." << endmsg; diff --git a/k4FWCore/components/PodioInput.h b/k4FWCore/components/PodioInput.h index 3a41afc6..978d821e 100644 --- a/k4FWCore/components/PodioInput.h +++ b/k4FWCore/components/PodioInput.h @@ -46,7 +46,8 @@ class PodioInput final : public Gaudi::Functional::Consumer template void maybeRead(std::string_view collName) const; void fillReaders(); // Name of collections to read. Set by option collections (this is temporary) - Gaudi::Property> m_collectionNames{this, "collections", {}, "Places of collections to read"}; + Gaudi::Property> m_collectionNames{ + this, "collections", {}, "Collections that should be read (default all)"}; // Data service: needed to register objects and get collection IDs. Just an observing pointer. PodioDataSvc* m_podioDataSvc; mutable std::map> m_readers;