From 41e53095c7db942f3ca19e61c99a091deee36f20 Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Thu, 25 Mar 2021 18:22:34 +0100
Subject: [PATCH] Geant4: flush the buffer to fix the problem with the garbage
 output at the end

---
 DDG4/src/Geant4Kernel.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp
index fecd4e766..a94f8db22 100644
--- a/DDG4/src/Geant4Kernel.cpp
+++ b/DDG4/src/Geant4Kernel.cpp
@@ -300,7 +300,10 @@ int Geant4Kernel::initialize() {
 
 int Geant4Kernel::run() {
   try  {
-    return Geant4Exec::run(*this);
+    auto result = Geant4Exec::run(*this);
+    // flush the geant4 stream buffer
+    G4cout << G4endl;
+    return result;
   }
   catch(const exception& e)   {
     printout(FATAL,"Geant4Kernel","+++ Exception while simulating:%s",e.what());
-- 
GitLab