Loading...
Searching...
No Matches
exampleGB05.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27/// \file exampleGB05.cc
28/// \brief Main program of example GB05
29
30#include "G4Types.hh"
31
32#include "G4RunManagerFactory.hh"
34
35#include "G4UImanager.hh"
36
39
40#include "FTFP_BERT.hh"
41#include "G4GenericBiasingPhysics.hh"
42
43#include "G4VisExecutive.hh"
44#include "G4UIExecutive.hh"
45
46
47//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48
49namespace {
50 void PrintUsage() {
51 G4cerr << " Usage: " << G4endl;
52 G4cerr << " ./exampleGB05 [-m macro ] "
53 << " [-b biasing {'on','off'}]"
54 << "\n or\n ./exampleGB05 [macro.mac]"
55 << G4endl;
56 }
57}
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60
61
62int main(int argc,char** argv)
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}
159
160//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
Definition of the GB05ActionInitialization class.
Definition of the GB05DetectorConstruction class.
Definition of the GB05PrimaryGeneratorAction class.
Action initialization class.
void PrintUsage()
int main()
Definition testCommon.cc:47

Applications | User Support | Publications | Collaboration