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