Skip to content

Commit

Permalink
PodioDataSvc: only check event count when n = -1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zehvogel committed Aug 11, 2023
1 parent 867dd28 commit 3c1a3c2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions k4FWCore/include/k4FWCore/PodioDataSvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,7 @@ class PodioDataSvc : public DataSvc {
/// Jump to nth events at the beginning. Set by option FirstEventEntry
/// This option is helpful when we want to debug an event in the middle of a file
unsigned m_1stEvtEntry{0};
/// If running with --num-event=-1
bool m_unbounded{false};
};
#endif // CORE_PODIODATASVC_H
22 changes: 21 additions & 1 deletion k4FWCore/src/PodioDataSvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "GaudiKernel/IConversionSvc.h"
#include "GaudiKernel/IEventProcessor.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/IProperty.h"

#include "k4FWCore/DataWrapper.h"

Expand Down Expand Up @@ -44,6 +45,18 @@ StatusCode PodioDataSvc::initialize() {
m_metadataframe = podio::Frame();
}

IProperty* property;
auto sc = service("ApplicationMgr", property);
if (sc == StatusCode::FAILURE) {
error() << "Could not get ApplicationMgr properties" << std::endl;
}
Gaudi::Property<int> evtMax;
evtMax.assign(property->getProperty("EvtMax"));

if (evtMax == -1) {
m_unbounded = true;
}

return status;
}
/// Service reinitialisation
Expand Down Expand Up @@ -91,9 +104,16 @@ StatusCode PodioDataSvc::i_setRoot(std::string root_path, DataObject* pRootObj)
}

void PodioDataSvc::endOfRead() {
m_eventNum++;

// Only check if we read the last available event when running with n = -1
if (!m_unbounded) {
return;
}

StatusCode sc;
if (m_eventMax != -1) {
if (m_eventNum++ >= m_eventMax - 1) { // we start counting at 0 thus the -1.
if (m_eventNum >= m_eventMax - 1) { // we start counting at 0 thus the -1.
info() << "Reached end of file with event " << m_eventMax << endmsg;
IEventProcessor* eventProcessor;
sc = service("ApplicationMgr", eventProcessor);
Expand Down

0 comments on commit 3c1a3c2

Please sign in to comment.