Geant4  10.00.p03
exampleGB02.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 // $Id: $
27 //
28 
29 #ifdef G4MULTITHREADED
30 #include "G4MTRunManager.hh"
31 #else
32 #include "G4RunManager.hh"
33 #endif
35 
36 #include "G4UImanager.hh"
37 
40 
41 #include "FTFP_BERT.hh"
43 
44 #ifdef G4VIS_USE
45 #include "G4VisExecutive.hh"
46 #endif
47 
48 #ifdef G4UI_USE
49 #include "G4UIExecutive.hh"
50 #endif
51 
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
55 namespace {
56  void PrintUsage() {
57  G4cerr << " Usage: " << G4endl;
58  G4cerr << " ./exampleGB02 [-m macro ] "
59  << " [-b biasing {'on','off'}]"
60  << "\n or\n ./exampleGB02 [macro.mac]"
61  << G4endl;
62  }
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
67 
68 int main(int argc,char** argv)
69 {
70  // Evaluate arguments
71  //
72  if ( argc > 5 ) {
73  PrintUsage();
74  return 1;
75  }
76 
77  G4String macro("");
78  G4String onOffBiasing("");
79  if ( argc == 2 ) macro = argv[1];
80  else
81  {
82  for ( G4int i=1; i<argc; i=i+2 )
83  {
84  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
85  else if ( G4String(argv[i]) == "-b" ) onOffBiasing = argv[i+1];
86  else
87  {
88  PrintUsage();
89  return 1;
90  }
91  }
92  }
93 
94  if ( onOffBiasing == "" ) onOffBiasing = "on";
95 
96  // -- Construct the run manager : MT or sequential one
97 #ifdef G4MULTITHREADED
98  G4MTRunManager * runManager = new G4MTRunManager;
99  G4cout << " ********** Run Manager constructed in MT mode ************ " << G4endl;
100  // -- Choose 4 threads:
101  runManager->SetNumberOfThreads(4);
102 #else
103  G4RunManager * runManager = new G4RunManager;
104  G4cout << " ********** Run Manager constructed in sequential mode ************ " << G4endl;
105 #endif
106 
107 
108  // -- Set mandatory initialization classes
110  runManager->SetUserInitialization(detector);
111  // -- Select a physics list
112  FTFP_BERT* physicsList = new FTFP_BERT;
113  // -- And augment it with biasing facilities:
114  G4GenericBiasingPhysics* biasingPhysics = new G4GenericBiasingPhysics();
115  if ( onOffBiasing == "on" )
116  {
117  biasingPhysics->Bias("gamma");
118  biasingPhysics->Bias("neutron");
119  biasingPhysics->Bias("kaon0L");
120  biasingPhysics->Bias("kaon0S");
121  physicsList->RegisterPhysics(biasingPhysics);
122  G4cout << " ********************************************* " << G4endl;
123  G4cout << " ********** processes are wrapped ************ " << G4endl;
124  G4cout << " ********************************************* " << G4endl;
125  }
126  else
127  {
128  G4cout << " ************************************************* " << G4endl;
129  G4cout << " ********** processes are not wrapped ************ " << G4endl;
130  G4cout << " ************************************************* " << G4endl;
131  }
132  runManager->SetUserInitialization(physicsList);
133  // -- Action initialization:
135 
136  // runManager->SetUserAction(new SteppingAction);
137  // runManager->SetUserAction(new RunAction(output));
138 
139  // Initialize G4 kernel
140  runManager->Initialize();
141 
142 
143 #ifdef G4VIS_USE
144  // Initialize visualization
145  G4VisManager* visManager = new G4VisExecutive;
146  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
147  visManager->Initialize();
148 #endif
149 
150  // Get the pointer to the User Interface manager
151  G4UImanager* UImanager = G4UImanager::GetUIpointer();
152 
153  if ( macro != "" ) // batch mode
154  {
155  G4String command = "/control/execute ";
156  UImanager->ApplyCommand(command+macro);
157  }
158  else
159  { // interactive mode : define UI session
160 #ifdef G4UI_USE
161  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
162 #ifdef G4VIS_USE
163  // UImanager->ApplyCommand("/control/execute vis.mac");
164 #endif
165  // if (ui->IsGUI())
166  // UImanager->ApplyCommand("/control/execute gui.mac");
167  ui->SessionStart();
168  delete ui;
169 #endif
170  }
171 
172 
173 #ifdef G4VIS_USE
174  delete visManager;
175 #endif
176  delete runManager;
177 
178 
179  return 0;
180 }
181 
182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
int main(int argc, char **argv)
Definition: exampleGB02.cc:68
void Initialize()
TFTFP_BERT< G4VModularPhysicsList > FTFP_BERT
Definition: FTFP_BERT.hh:63
Action initialization class.
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
Definition of the GB02ActionInitialization class.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:432
G4GLOB_DLL std::ostream G4cerr
void Bias(const G4String &particleName)