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

Main program of the field/field06 example. More...

#include <unistd.h>
#include "G4Types.hh"
#include "F06PhysicsList.hh"
#include "G4Transportation.hh"
#include "F06DetectorConstruction.hh"
#include "F06ActionInitialization.hh"
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "Randomize.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 field/field06 example.

Definition in file field06.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 71 of file field06.cc.

72{
73 // Evaluate arguments
74 //
75 if ( argc > 9 ) {
76 PrintUsage();
77 return 1;
78 }
79
80 G4String macro;
81 G4String session;
82 G4int nThreads = 0;
83
84 G4long randomSeed = 1234;
85 for ( G4int i=1; i<argc; i=i+2 ) {
86 if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
87 else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
88 else if ( G4String(argv[i]) == "-r" ) randomSeed = atoi(argv[i+1]);
89 else if ( G4String(argv[i]) == "-t" ) {
90 nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
91 }
92 else {
93 PrintUsage();
94 return 1;
95 }
96 }
97
98 // Instantiate G4UIExecutive for interactive mode
99 G4UIExecutive* ui = nullptr;
100 if ( macro.size() == 0 ) {
101 ui = new G4UIExecutive(argc, argv, session);
102 }
103
104 // Choose the Random engine
105 //
106 G4Random::setTheEngine(new CLHEP::RanecuEngine);
107
108 // Construct the default run manager
109 //
110 auto* runManager = G4RunManagerFactory::CreateRunManager();
111 if ( nThreads > 0 ) runManager->SetNumberOfThreads(nThreads);
112
113 // Seed the random number generator manually
114 G4Random::setTheSeed(randomSeed);
115
116 // Set mandatory initialization classes
117 //
118 // Detector construction
119 runManager->SetUserInitialization(new F06DetectorConstruction());
120 // Physics list
121 runManager->SetUserInitialization(new F06PhysicsList());
122
123 // Ensure that Transportation considers gravity fields.
124 G4Transportation::EnableGravity(true);
125
126 // User action initialization
127 runManager->SetUserInitialization(new F06ActionInitialization());
128
129 // Initialize visualization
130 //
131 G4VisManager* visManager = new G4VisExecutive;
132 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
133 // G4VisManager* visManager = new G4VisExecutive("Quiet");
134 visManager->Initialize();
135
136 // Get the pointer to the User Interface manager
137 //
138 G4UImanager* UImanager = G4UImanager::GetUIpointer();
139
140 if ( !ui ) {
141 // batch mode
142 G4String command = "/control/execute ";
143 UImanager->ApplyCommand(command+macro);
144 }
145 else
146 {
147 UImanager->ApplyCommand("/control/execute init_vis.mac");
148 if (ui->IsGUI())
149 UImanager->ApplyCommand("/control/execute gui.mac");
150 ui->SessionStart();
151 delete ui;
152 }
153
154 // Job termination
155 // Free the store: user actions, physics_list and detector_description are
156 // owned and deleted by the run manager, so they should not
157 // be deleted in the main() program !
158
159 delete visManager;
160 delete runManager;
161
162 return 0;
163}
Action initialization class.
void PrintUsage()

Applications | User Support | Publications | Collaboration