I have a question about the G4cout output using the Qt GUI.
If I have some G4cout in my code, for example in the SteppingAction and other classes, when I execute the command /run/beamOn the simulation starts, but all the cout are printed in the GUI at the end of the run.
And also, the GUI is like “frozen” during the Run (Windows say “not responds”).
Is there a way to get the cout during the Run?
I hope that the problem is clear…
Thank you for your help!
I’m afraid the situation is exactly as you describe at the moment with the Qt GUI. In the past I have worked around it either by using std::out instead of G4cout or by writing to a file, which I can inspect even during a run (e.g., “less” in Unix). But be aware that for either of these workarounds in multithreading mode you have to do the mutex locking yourself (it is done for you in G4cout), as below.
G4Mutex coutMutex = G4MUTEX_INITIALIZER;
std::out << whatever_you_want << std::endl;
G4Mutex outFileMutex = G4MUTEX_INITIALIZER;
outFile << whatever_you_want << std::endl;
I’m sorry for the delay in my answer!
Thanks a lot for this information, it will be very useful, specially for output to file!
I have found that in MT mode the G4cout works fine with the Qt GUI, in fact the output is printed during the simulation in the terminal window (I don’t know why not in the Qt GUI as in sequential mode, but that’s ok).
You’re right about the Qt GUI. G4cout from worker threads is not captured by the GUI. I have just raised a bug report.