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

Main program of example GB05. More...

#include "G4Types.hh"
#include "G4RunManagerFactory.hh"
#include "GB05ActionInitialization.hh"
#include "G4UImanager.hh"
#include "GB05DetectorConstruction.hh"
#include "GB05PrimaryGeneratorAction.hh"
#include "FTFP_BERT.hh"
#include "G4GenericBiasingPhysics.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 example GB05.

Definition in file exampleGB05.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 62 of file exampleGB05.cc.

63{
64 // Evaluate arguments
65 //
66 if ( argc > 5 ) {
67 PrintUsage();
68 return 1;
69 }
70
71 G4String macro("");
72 G4String onOffBiasing("");
73 if ( argc == 2 ) macro = argv[1];
74 else
75 {
76 for ( G4int i=1; i<argc; i=i+2 )
77 {
78 if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
79 else if ( G4String(argv[i]) == "-b" ) onOffBiasing = argv[i+1];
80 else
81 {
82 PrintUsage();
83 return 1;
84 }
85 }
86 }
87
88 if ( onOffBiasing == "" ) onOffBiasing = "on";
89
90 // Instantiate G4UIExecutive if interactive mode
91 G4UIExecutive* ui = nullptr;
92 if ( macro == "" ) {
93 ui = new G4UIExecutive(argc, argv);
94 }
95
96 // -- Construct the run manager : MT or sequential one
97 auto* runManager = G4RunManagerFactory::CreateRunManager();
98 runManager->SetNumberOfThreads(4);
99
100 // -- Set mandatory initialization classes
102 runManager->SetUserInitialization(detector);
103 // -- Select a physics list:
104 FTFP_BERT* physicsList = new FTFP_BERT;
105 // -- and augment it with biasing facilities:
106 G4GenericBiasingPhysics* biasingPhysics = new G4GenericBiasingPhysics();
107 biasingPhysics->BeVerbose();
108 if ( onOffBiasing == "on" )
109 {
110 biasingPhysics->Bias("neutron");
111 physicsList->RegisterPhysics(biasingPhysics);
112 G4cout << " ********************************************************* "
113 << G4endl;
114 G4cout << " ********** processes are wrapped for biasing ************ "
115 << G4endl;
116 G4cout << " ********************************************************* "
117 << G4endl;
118 }
119 else
120 {
121 G4cout << " ************************************************* " << G4endl;
122 G4cout << " ********** processes are not wrapped ************ " << G4endl;
123 G4cout << " ************************************************* " << G4endl;
124 }
125 runManager->SetUserInitialization(physicsList);
126 // -- Action initialization:
127 runManager->SetUserInitialization(new GB05ActionInitialization);
128
129 // Initialize G4 kernel
130 runManager->Initialize();
131
132 // Initialize visualization
133 G4VisManager* visManager = new G4VisExecutive;
134 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
135 visManager->Initialize();
136
137 // Get the pointer to the User Interface manager
138 G4UImanager* UImanager = G4UImanager::GetUIpointer();
139
140 if ( !ui ) // batch mode
141 {
142 G4String command = "/control/execute ";
143 UImanager->ApplyCommand(command+macro);
144 }
145 else
146 { // interactive mode : define UI session
147 UImanager->ApplyCommand("/control/execute vis.mac");
148 // if (ui->IsGUI())
149 // UImanager->ApplyCommand("/control/execute gui.mac");
150 ui->SessionStart();
151 delete ui;
152 }
153
154 delete visManager;
155 delete runManager;
156
157 return 0;
158}
Action initialization class.
void PrintUsage()

Applications | User Support | Publications | Collaboration