#include #include "G4RunManager.hh" #include "G4UImanager.hh" #include "G4VisManager.hh" #include "G4VisExecutive.hh" #include "G4UIExecutive.hh" #include "construction.hh" // we have to include our detector file, otherwise it will not find the class MyDetectorConstruction #include "construction.cc" #include "physics.hh" #include "physics.cc" #include "action.hh" #include "action.cc" #include "generator.hh" #include "generator.cc" #include "MyElectricField.hh" #include "MyElectricField.cc" // ~~~~ this is where the program starts executing int main(int argc, char**argv) { // to generate random events, that don't repeat at the start of every job // CLHEP::HepRandom::setTheSeed(time(NULL)); //detect interactive mode (if no arguments) and define UI session G4UIExecutive* ui = nullptr; if (argc == 1) { ui = new G4UIExecutive(argc,argv); } G4RunManager *runManager = new G4RunManager(); runManager->SetUserInitialization(new MyDetectorConstruction()); runManager->SetUserInitialization(new MyPhysicsList()); runManager->SetUserInitialization(new MyActionInitialization()); runManager->Initialize(); //G4VisManager *visManager = new G4VisExecutive(); //initialize visualization G4VisManager* visManager = nullptr; G4UImanager *UImanager = G4UImanager::GetUIpointer(); // decide wether or not to start in interactive mode if (ui) { //interactive mode visManager = new G4VisExecutive; visManager->Initialize(); // G4 visualisation commands UImanager->ApplyCommand("/vis/open OGL"); UImanager->ApplyCommand("/vis/drawVolume"); UImanager->ApplyCommand("/vis/viewer/set/autoRefresh true"); UImanager->ApplyCommand("/vis/scene/add/trajectories smooth"); UImanager->ApplyCommand("/vis/scene/endOfEventAction accumulate"); ui->SessionStart(); delete ui; } else { // run by executing a macro file e.g: $ ./sim vis_alex.mac G4String command = "/control/execute "; G4String fileName = argv[1]; UImanager->ApplyCommand(command+fileName); } // terminate jobs delete visManager; delete UImanager; return 0; }