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