From 0d0909c1a050aeff44f1c398a45489e8e36ee70b Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Mon, 11 Jan 2016 15:13:30 +0000 Subject: [PATCH] Fix for event number when using more than one input file at the same time The event number was changed by each input source resulting in wrong behaviour. Now the input sources keep track of the event number themselves. Ideally the event number would be kept track of one level above, but then m_firstEvent is not known. Likewise the output module is not aware of the number of skipped events. --- DDG4/include/DDG4/Geant4InputAction.h | 2 ++ DDG4/src/Geant4InputAction.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DDG4/include/DDG4/Geant4InputAction.h b/DDG4/include/DDG4/Geant4InputAction.h index cff5099f7..f51cee9a0 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 f16c734cd..0a1a7a7d9 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; -- GitLab