diff --git a/k4FWCore/components/PodioInput.cpp b/k4FWCore/components/PodioInput.cpp index 2d336ae6..949a9053 100644 --- a/k4FWCore/components/PodioInput.cpp +++ b/k4FWCore/components/PodioInput.cpp @@ -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); diff --git a/k4FWCore/src/PodioDataSvc.cpp b/k4FWCore/src/PodioDataSvc.cpp index 956ab2da..c93f7f04 100644 --- a/k4FWCore/src/PodioDataSvc.cpp +++ b/k4FWCore/src/PodioDataSvc.cpp @@ -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(); }