Geant4 Version: 11.4.0
Operating System: Ubuntu 24.04.3 LTS
Compiler/Version: gcc 13.3.0
CMake Version: 3.28.3
Dear Geant4 users,
I’m new to Geant4. I started with the Geant4-DNA example molcounters-basic which I slightly modified. I would like to validate this changes with visualization but it seems that I’m having trouble getting DNA chemistry and visualization to work together.
With the original molcounter-basic main file I managed to get the chemical part working but not the visualization. I wrote another main file and I managed this time to get the visualization to work but not the chemical part. This is perhaps an obvious problem. But if anyone has any ideas to help me, I would be very grateful !
Original molcounter-basic main file :
#include "ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "G4DNAChemistryManager.hh"
#include "G4RunManagerFactory.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
int main(int argc, char** argv)
{
G4UIExecutive* ui = 0;
if (argc == 1) {
ui = new G4UIExecutive(argc, argv);
}
auto* runManager = G4RunManagerFactory::CreateRunManager();
// Set mandatory initialization classes
runManager->SetUserInitialization(new PhysicsList);
runManager->SetUserInitialization(new DetectorConstruction);
runManager->SetUserInitialization(new ActionInitialization);
// get the pointer to the User Interface manager
auto UI = G4UImanager::GetUIpointer();
if (argc > 1) // batch mode
{
G4String command = "/control/execute ";
G4String fileName = argv[1];
UI->ApplyCommand(command + fileName);
}
else // define visualization and UI terminal for interactive mode
{
UI->ApplyCommand("/control/execute simple_sbs.in");
delete ui;
}
delete runManager;
return 0;
}
I tried ./molcounters_basic vis.mac with the following mac file :
# ============================== # Visualization macro for DetectorConstruction # ============================== # Ouvre la fenêtre OpenGL /vis/open OGL 800x800-0+0 /run/initialize # Style général de la géométrie : surface ou wireframe pour tester /vis/viewer/set/style surface /vis/viewer/set/autoRefresh true # Dessine tous les volumes physiques à partir du world /vis/drawVolume # Ajouter des axes pour repère (0,0,0) ; longueur 10 um /vis/scene/add/axes 0 0 0 50 um # Affiche les trajectoires (smooth) et les accumule à la fin de l'événement /vis/scene/add/trajectories smooth /vis/scene/endOfEventAction accumulate # Couleur par type de particule /vis/modeling/trajectories/create/drawByParticleID /vis/modeling/trajectories/drawByParticleID-0/set e- cyan /vis/modeling/trajectories/drawByParticleID-0/set e_aq magenta /vis/modeling/trajectories/drawByParticleID-0/set °OH red /vis/modeling/trajectories/drawByParticleID-0/set H green # Vue de départ /vis/viewer/set/viewpointThetaPhi 60 30 /vis/viewer/zoom 2 # Rafraîchissement automatique /vis/viewer/set/autoRefresh true
Which gave me the error below :
sarah@sarah-Precision-7560:~/Documents/Projet_PEPR/Gate-simulations/Passage-Geant4/basic/build$ ./molcounters_basic vis.mac
**************************************************************
Geant4 version Name: geant4-11-04 [MT] (5-December-2025)
<< in Multi-threaded mode >>
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
: NIM A 835 (2016), 186-225
WWW : http://geant4.org/
**************************************************************
***** COMMAND NOT FOUND </vis/open OGL 800x800-0+0> *****
***** Batch is interrupted!! *****
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : UIMAN0123
issued by : G4UImanager::ApplyCommand
Command aborted (100)
Error code : 100
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------
Hence I tried my own main file :
#include “ActionInitialization.hh” #include “DetectorConstruction.hh” #include “PhysicsList.hh” #include “G4DNAChemistryManager.hh” #include “G4RunManagerFactory.hh” #include “G4UIExecutive.hh” #include “G4UImanager.hh” #include “G4VisExecutive.hh” int main(int argc, char** argv) { // ---- REDIRECTION DE G4cout VERS UN FICHIER ---- std::ofstream out(“molecules.txt”); G4cout.rdbuf(out.rdbuf()); // tout G4cout ira dans le fichier G4UIExecutive* ui = 0; if (argc == 1) { ui = new G4UIExecutive(argc, argv); } auto* runManager = G4RunManagerFactory::CreateRunManager(); // Set mandatory initialization classes runManager->SetUserInitialization(new PhysicsList); runManager->SetUserInitialization(new DetectorConstruction); runManager->SetUserInitialization(new ActionInitialization); // Initialize visualization auto visManager = new G4VisExecutive(); visManager->Initialize(); // get the pointer to the User Interface manager G4UImanager* UI = G4UImanager::GetUIpointer(); if (argc > 1) // batch mode { // Execute the batch macro (argv[1]) const G4String command = “/control/execute “; const G4String fileName = argv[1]; UI->ApplyCommand(command + fileName); } else // interactive mode { // Execute the visualization macro first UI->ApplyCommand(”/control/execute vis.mac”); // Start the interactive session ui->SessionStart(); delete ui; } delete runManager; delete visManager; return 0; }
Here the visualization is working but I have no chemistry anymore.
Thank you very much for the help!
Regards,
Sarah