Skip to content

Commit

Permalink
Default to reading all collections and allow to limit them
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Nov 17, 2023
1 parent 54a325e commit 012c455
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion k4FWCore/components/PodioInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion k4FWCore/components/PodioInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class PodioInput final : public Gaudi::Functional::Consumer<void(), BaseClass_t>
template <typename T> void maybeRead(std::string_view collName) const;
void fillReaders();
// Name of collections to read. Set by option collections (this is temporary)
Gaudi::Property<std::vector<std::string>> m_collectionNames{this, "collections", {}, "Places of collections to read"};
Gaudi::Property<std::vector<std::string>> 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<std::string_view, std::function<void(std::string_view)>> m_readers;
Expand Down

0 comments on commit 012c455

Please sign in to comment.