diff --git a/Examples/Algorithms/Geant4/src/EventAction.cpp b/Examples/Algorithms/Geant4/src/EventAction.cpp index 1f5d407fe6e..d8657463fbb 100644 --- a/Examples/Algorithms/Geant4/src/EventAction.cpp +++ b/Examples/Algorithms/Geant4/src/EventAction.cpp @@ -58,7 +58,7 @@ void EventAction::EndOfEventAction(const G4Event* event) { /// Clear the recorded data. void EventAction::clear() { - // + m_materialTracks.clear(); } /// Access the recorded material tracks. diff --git a/Examples/Algorithms/Geant4/src/GeantinoRecording.cpp b/Examples/Algorithms/Geant4/src/GeantinoRecording.cpp index 6fb3c94523f..180f751f1d3 100644 --- a/Examples/Algorithms/Geant4/src/GeantinoRecording.cpp +++ b/Examples/Algorithms/Geant4/src/GeantinoRecording.cpp @@ -58,9 +58,9 @@ FW::ProcessCode GeantinoRecording::execute( // start simulation. each track is simulated as a separate Geant4 event. m_runManager->BeamOn(m_cfg.tracksPerEvent); + auto materialTracks = EventAction::instance()->materialTracks(); // Write the recorded material to the event store - ctx.eventStore.add(m_cfg.outputMaterialTracks, - EventAction::instance()->materialTracks()); + ctx.eventStore.add(m_cfg.outputMaterialTracks, move(materialTracks)); return FW::ProcessCode::SUCCESS; } diff --git a/Examples/Run/Geant4/RunSimGeantinoRecording.cpp b/Examples/Run/Geant4/RunSimGeantinoRecording.cpp index b030329b8d3..c2fd29c9d9b 100644 --- a/Examples/Run/Geant4/RunSimGeantinoRecording.cpp +++ b/Examples/Run/Geant4/RunSimGeantinoRecording.cpp @@ -43,6 +43,7 @@ int main(int argc, char* argv[]) { // setup the Geant4 algorithm GeantinoRecording::Config g4; + std::string materialTrackCollection = g4.outputMaterialTracks; g4.detectorConstruction = std::make_unique(*geometrySvc->lcdd()); g4.tracksPerEvent = 100; @@ -57,12 +58,11 @@ int main(int argc, char* argv[]) { RootMaterialTrackWriter::Config materialTrackWriter; materialTrackWriter.prePostStep = true; materialTrackWriter.recalculateTotals = true; - materialTrackWriter.collection = g4.outputMaterialTracks; + materialTrackWriter.collection = materialTrackCollection; materialTrackWriter.filePath = - joinPaths(outputDir, g4.outputMaterialTracks + ".root"); + joinPaths(outputDir, materialTrackCollection + ".root"); sequencer.addWriter(std::make_shared( materialTrackWriter, logLevel)); } - return sequencer.run(); }