Skip to content

Commit

Permalink
Make PodioInput not crash on non-existant collections
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Nov 17, 2023
1 parent 8a1aa92 commit 54a325e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion k4FWCore/components/PodioInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,12 @@ void PodioInput::operator()() const {
info() << "No EventHeader collection found in the event. Not reading it" << endmsg;
}

for (auto& collName : m_collectionNames) {
for (const auto& collName : m_collectionNames) {
debug() << "Registering collection to read " << collName << endmsg;
if (!m_podioDataSvc->hasCollection(collName)) {
warning() << "Collection " << collName << " is not available from file." << endmsg;
continue;
}
auto type = m_podioDataSvc->getCollectionType(collName);
if (m_readers.find(type) != m_readers.end()) {
m_readers[type](collName);
Expand Down
1 change: 1 addition & 0 deletions k4FWCore/src/PodioDataSvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const std::string_view PodioDataSvc::getCollectionType(const std::string& collNa
const auto coll = m_eventframe.get(collName);
if (coll == nullptr) {
error() << "Collection " << collName << " does not exist." << endmsg;
return "";
}
return coll->getTypeName();
}
Expand Down

0 comments on commit 54a325e

Please sign in to comment.