Loading...
Searching...
No Matches
exampleGB06.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/// \file GB06/exampleGB06.cc
27/// \brief Main program of the GB06 example
28//
29//
30
31#include "G4Types.hh"
32
33#include "G4RunManagerFactory.hh"
35
36#include "G4UImanager.hh"
37
41
42#include "FTFP_BERT.hh"
43#include "G4GenericBiasingPhysics.hh"
44
45#include "G4VisExecutive.hh"
46#include "G4UIExecutive.hh"
47
48
49//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50
51namespace {
52 void PrintUsage() {
53 G4cerr << " Usage: " << G4endl;
54 G4cerr << " ./exampleGB06 [-m macro ] "
55 << " [-b biasing {'on','off'}]"
56 << "\n or\n ./exampleGB06 [macro.mac]"
57 << G4endl;
58 }
59}
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62
63
64int main(int argc,char** argv)
65{
66 // Evaluate arguments
67 //
68 if ( argc > 5 ) {
69 PrintUsage();
70 return 1;
71 }
72
73 G4String macro("");
74 G4String onOffBiasing("");
75 if ( argc == 2 ) macro = argv[1];
76 else
77 {
78 for ( G4int i=1; i<argc; i=i+2 )
79 {
80 if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
81 else if ( G4String(argv[i]) == "-b" ) onOffBiasing = argv[i+1];
82 else
83 {
84 PrintUsage();
85 return 1;
86 }
87 }
88 }
89
90 if ( onOffBiasing == "" ) onOffBiasing = "on";
91
92 // Instantiate G4UIExecutive if interactive mode
93 G4UIExecutive* ui = nullptr;
94 if ( macro == "" ) {
95 ui = new G4UIExecutive(argc, argv);
96 }
97
98 // -- Construct the run manager : MT or sequential one
99 auto* runManager = G4RunManagerFactory::CreateRunManager();
100 runManager->SetNumberOfThreads(4);
101
102
103 // -- Set mandatory initialization classes
104
105 // -- Create geometry:
107 // -- Create parallel world:
108 GB06ParallelWorldForSlices* parallelWorld =
109 new GB06ParallelWorldForSlices("parallelWorldForSlices");
110 // -- and "augment" detector geometry with the parallelWorld one:
111 detector->RegisterParallelWorld( parallelWorld );
112 runManager->SetUserInitialization(detector);
113
114 // -- Select a physics list:
115 FTFP_BERT* physicsList = new FTFP_BERT;
116 // -- and augment it with biasing facilities:
117 G4GenericBiasingPhysics* biasingPhysics = new G4GenericBiasingPhysics();
118 biasingPhysics->BeVerbose();
119 if ( onOffBiasing == "on" )
120 {
121 // -- We use only the "non physics biasing" functionnality (ie, the ones which don't
122 // -- alter physics processes behavior), and hence we equipe the physics list
123 // -- accordingly:
124 biasingPhysics->NonPhysicsBias("neutron");
125 // -- we activate and configure the parallel geometry facility:
126 biasingPhysics->AddParallelGeometry("neutron","parallelWorldForSlices");
127 physicsList->RegisterPhysics(biasingPhysics);
128 G4cout << " ********************************************************* "
129 << G4endl;
130 G4cout << " ********** processes are wrapped for biasing ************ "
131 << G4endl;
132 G4cout << " ********************************************************* "
133 << G4endl;
134 }
135 else
136 {
137 G4cout << " ************************************************* " << G4endl;
138 G4cout << " ********** processes are not wrapped ************ " << G4endl;
139 G4cout << " ************************************************* " << G4endl;
140 }
141 runManager->SetUserInitialization(physicsList);
142
143 // -- Action initialization:
144 runManager->SetUserInitialization(new GB06ActionInitialization);
145
146 // Initialize G4 kernel
147 runManager->Initialize();
148
149 // Initialize visualization
150 G4VisManager* visManager = new G4VisExecutive;
151 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
152 visManager->Initialize();
153
154 // Get the pointer to the User Interface manager
155 G4UImanager* UImanager = G4UImanager::GetUIpointer();
156
157 if ( macro != "" ) // batch mode
158 {
159 G4String command = "/control/execute ";
160 UImanager->ApplyCommand(command+macro);
161 }
162 else
163 { // interactive mode : define UI session
164 UImanager->ApplyCommand("/control/execute vis.mac");
165 // if (ui->IsGUI())
166 // UImanager->ApplyCommand("/control/execute gui.mac");
167 ui->SessionStart();
168 delete ui;
169 }
170
171 delete visManager;
172 delete runManager;
173
174 return 0;
175}
176
177//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
Definition of the GB06ActionInitialization class.
Definition of the GB06DetectorConstruction class.
Definition of the GB06ParallelWorldForSlices class.
Definition of the GB06PrimaryGeneratorAction class.
Action initialization class.
void PrintUsage()
int main()
Definition testCommon.cc:47

Applications | User Support | Publications | Collaboration