Skip to content

Commit

Permalink
Check and read the EventHeader every event
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Nov 17, 2023
1 parent ef50161 commit 5f78229
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 6 additions & 5 deletions k4FWCore/components/PodioInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,15 @@ PodioInput::PodioInput(const std::string& name, ISvcLocator* svcLoc) : Consumer(
error() << "Could not get PodioDataSvc" << endmsg;
}
fillReaders();

auto key = edm4hep::EventHeaderName;
if (std::find(m_collectionNames.begin(), m_collectionNames.end(), key) == m_collectionNames.end()) {
m_collectionNames.value().push_back(key);
}
}

void PodioInput::operator()() const {
if (m_podioDataSvc->hasCollection(edm4hep::EventHeaderName)) {
m_readers[edm4hep::EventHeaderCollection::typeName](edm4hep::EventHeaderName);
} else {
info() << "No EventHeader collection found in the event. Not reading it" << endmsg;
}

for (auto& collName : m_collectionNames) {
debug() << "Registering collection to read " << collName << endmsg;
auto type = m_podioDataSvc->getCollectionType(collName);
Expand Down
2 changes: 2 additions & 0 deletions k4FWCore/include/k4FWCore/PodioDataSvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class PodioDataSvc : public DataSvc {
/// TODO: Make this private again after conversions have been properly solved
podio::Frame& getMetaDataFrame() { return m_metadataframe; }

bool hasCollection(const std::string& name) const { return m_eventframe.get(name); }

private:
/// PODIO reader for ROOT files
podio::ROOTFrameReader m_reader;
Expand Down

0 comments on commit 5f78229

Please sign in to comment.