Loading...
Searching...
No Matches
Functions
exampleB5.cc File Reference

Main program of the basic B5 example. More...

#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "G4RunManagerFactory.hh"
#include "G4SteppingVerbose.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the basic B5 example.

Definition in file exampleB5.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 44 of file exampleB5.cc.

45{
46 // Detect interactive mode (if no arguments) and define UI session
47 //
48 G4UIExecutive* ui = nullptr;
49 if ( argc == 1 ) { ui = new G4UIExecutive(argc, argv); }
50
51 // Use G4SteppingVerboseWithUnits
52 G4int precision = 4;
53 G4SteppingVerbose::UseBestUnit(precision);
54
55 // Construct the default run manager
56 //
57 auto runManager =
58 G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
59
60 // Mandatory user initialization classes
61 runManager->SetUserInitialization(new B5::DetectorConstruction);
62
63 auto physicsList = new FTFP_BERT;
64 physicsList->RegisterPhysics(new G4StepLimiterPhysics());
65 runManager->SetUserInitialization(physicsList);
66
67 // User action initialization
68 runManager->SetUserInitialization(new B5::ActionInitialization());
69
70 // Visualization manager construction
71 auto visManager = new G4VisExecutive;
72 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
73 // auto visManager = new G4VisExecutive("Quiet");
74 visManager->Initialize();
75
76 // Get the pointer to the User Interface manager
77 auto UImanager = G4UImanager::GetUIpointer();
78
79 if ( !ui ) {
80 // execute an argument macro file if exist
81 G4String command = "/control/execute ";
82 G4String fileName = argv[1];
83 UImanager->ApplyCommand(command+fileName);
84 }
85 else {
86 UImanager->ApplyCommand("/control/execute init_vis.mac");
87 if (ui->IsGUI()) {
88 UImanager->ApplyCommand("/control/execute gui.mac");
89 }
90 // start interactive session
91 ui->SessionStart();
92 delete ui;
93 }
94
95 // Job termination
96 // Free the store: user actions, physics_list and detector_description are
97 // owned and deleted by the run manager, so they should not be deleted
98 // in the main() program !
99
100 delete visManager;
101 delete runManager;
102}
Action initialization class.
Detector construction.

Applications | User Support | Publications | Collaboration