diff --git a/DDG4/include/DDG4/Geant4InputAction.h b/DDG4/include/DDG4/Geant4InputAction.h index cff5099f7d5e81ad7ad8ed8267cb91379fc1ceb6..f51cee9a07bdcfefcb13f588608a5a0d5d7b958b 100644 --- a/DDG4/include/DDG4/Geant4InputAction.h +++ b/DDG4/include/DDG4/Geant4InputAction.h @@ -116,6 +116,8 @@ namespace DD4hep { double m_momScale; /// Event reader object Geant4EventReader* m_reader; + /// current event number without initially skipped events + int m_currentEventNumber; public: /// Read an event and return a LCCollectionVec of MCParticles. diff --git a/DDG4/src/Geant4InputAction.cpp b/DDG4/src/Geant4InputAction.cpp index f16c734cdabe24d0a5645b1bfa17e4625eb3784d..0a1a7a7d98b712460c0204c74deb1d7d82030910 100644 --- a/DDG4/src/Geant4InputAction.cpp +++ b/DDG4/src/Geant4InputAction.cpp @@ -76,7 +76,7 @@ Geant4EventReader::moveToEvent(int event_number) { /// Standard constructor Geant4InputAction::Geant4InputAction(Geant4Context* ctxt, const string& nam) - : Geant4GeneratorAction(ctxt,nam), m_reader(0) + : Geant4GeneratorAction(ctxt,nam), m_reader(0), m_currentEventNumber(0) { declareProperty("Input", m_input); declareProperty("Sync", m_firstEvent=0); @@ -143,9 +143,10 @@ void Geant4InputAction::operator()(G4Event* event) { Geant4Event& evt = context()->event(); Geant4PrimaryEvent* prim = evt.extension<Geant4PrimaryEvent>(); - int result = readParticles(event->GetEventID(),primaries); + int result = readParticles(m_currentEventNumber, primaries); - event->SetEventID( m_firstEvent + event->GetEventID() ); + event->SetEventID(m_firstEvent + m_currentEventNumber); + ++m_currentEventNumber; if ( result != Geant4EventReader::EVENT_READER_OK ) { // handle I/O error, but how? return;