added missing piece
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
|
||||
#include "SystemBuilder.hh"
|
||||
|
||||
void SystemBuilder::init(ConstructionWrapper &CW, bool gui){
|
||||
|
||||
char* argv[]={(char*)"dummy"};
|
||||
|
||||
// Construct the default run manager
|
||||
//
|
||||
runManager =
|
||||
G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
|
||||
runManager->SetNumberOfThreads(1);
|
||||
|
||||
G4String session;
|
||||
ui = nullptr;
|
||||
if ( gui ) {
|
||||
ui = new G4UIExecutive((int)1, argv, session);
|
||||
}
|
||||
|
||||
// Set mandatory initialization classes
|
||||
//
|
||||
detConstruction = new B4::DetectorConstruction(&CW);
|
||||
|
||||
runManager->SetUserInitialization(detConstruction);
|
||||
|
||||
auto physicsList = new FTFP_BERT;
|
||||
runManager->SetUserInitialization(physicsList);
|
||||
|
||||
actionInitialization = new B4a::ActionInitialization(detConstruction);
|
||||
runManager->SetUserInitialization(actionInitialization);
|
||||
|
||||
actionInitialization->setGeneratorProperties(100, 10000, "e-");
|
||||
|
||||
// Initialize visualization
|
||||
//
|
||||
visManager = new G4VisExecutive;
|
||||
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
|
||||
// G4VisManager* visManager = new G4VisExecutive("Quiet");
|
||||
visManager->Initialize();
|
||||
|
||||
// Get the pointer to the User Interface manager
|
||||
UImanager = G4UImanager::GetUIpointer();
|
||||
|
||||
// Process macro or start UI session
|
||||
//
|
||||
}
|
||||
|
||||
void SystemBuilder::run_gui(){
|
||||
if(ui == nullptr){
|
||||
throw std::runtime_error("GUI not initialized");
|
||||
}
|
||||
if ( true ) {
|
||||
// interactive mode : define UI session
|
||||
UImanager->ApplyCommand("/control/execute init_vis.mac");
|
||||
if (ui->IsGUI()) {
|
||||
UImanager->ApplyCommand("/control/execute gui.mac");
|
||||
}
|
||||
ui->SessionStart();
|
||||
}
|
||||
}
|
||||
|
||||
void SystemBuilder::run_batch(int nEvents, std::string partSpecies, double minEnergy, double maxEnergy){
|
||||
actionInitialization->setGeneratorProperties(minEnergy, maxEnergy, partSpecies);
|
||||
UImanager->ApplyCommand("/run/initialize");
|
||||
runManager->BeamOn(nEvents);
|
||||
}
|
||||
Reference in New Issue
Block a user