LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
exampleGB04.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 "GB04ActionInitialization.hh"
38 
39 #include "G4UImanager.hh"
40 
41 #include "GB04DetectorConstruction.hh"
42 #include "GB04PrimaryGeneratorAction.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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
57 namespace {
58  void PrintUsage() {
59  G4cerr << " Usage: " << G4endl;
60  G4cerr << " ./exampleGB04 [-m macro ] "
61  << " [-b biasing {'on','off'}]"
62  << "\n or\n ./exampleGB04 [macro.mac]"
63  << G4endl;
64  }
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
69 int main(int argc,char** argv)
70 {
71  // Evaluate arguments
72  //
73  if ( argc > 5 ) {
74  PrintUsage();
75  return 1;
76  }
77 
78  G4String macro("");
79  G4String onOffBiasing("");
80  if ( argc == 2 ) macro = argv[1];
81  else
82  {
83  for ( G4int i=1; i<argc; i=i+2 )
84  {
85  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
86  else if ( G4String(argv[i]) == "-b" ) onOffBiasing = argv[i+1];
87  else
88  {
89  PrintUsage();
90  return 1;
91  }
92  }
93  }
94 
95  if ( onOffBiasing == "" ) onOffBiasing = "on";
96 
97  // -- Construct the run manager : MT or sequential one
98 #ifdef G4MULTITHREADED
99  G4MTRunManager * runManager = new G4MTRunManager;
100  G4cout << " ********** Run Manager constructed in MT mode ************ "
101  << G4endl;
102  // -- Choose 4 threads:
103  runManager->SetNumberOfThreads(4);
104 #else
105  G4RunManager * runManager = new G4RunManager;
106  G4cout << " ********** Run Manager constructed in sequential mode ************ "
107  << G4endl;
108 #endif
109 
110 
111  // -- Set mandatory initialization classes
112  GB04DetectorConstruction* detector = new GB04DetectorConstruction();
113  runManager->SetUserInitialization(detector);
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  if ( onOffBiasing == "on" )
119  {
120  // -- Create list of physics processes to be biased: only brem. in this case:
121  std::vector< G4String > processToBias;
122  processToBias.push_back("eBrem");
123  // -- Pass the list to the G4GenericBiasingPhysics, which will wrap the eBrem
124  // -- process of e- and e+ to activate the biasing of it:
125  biasingPhysics->PhysicsBias("e-", processToBias);
126  biasingPhysics->PhysicsBias("e+", processToBias);
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  // -- Action initialization:
143  runManager->SetUserInitialization(new GB04ActionInitialization);
144 
145  // Initialize G4 kernel
146  runManager->Initialize();
147 
148 
149 #ifdef G4VIS_USE
150  // Initialize visualization
151  G4VisManager* visManager = new G4VisExecutive;
152  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
153  visManager->Initialize();
154 #endif
155 
156  // Get the pointer to the User Interface manager
157  G4UImanager* UImanager = G4UImanager::GetUIpointer();
158 
159  if ( macro != "" ) // batch mode
160  {
161  G4String command = "/control/execute ";
162  UImanager->ApplyCommand(command+macro);
163  }
164  else
165  { // interactive mode : define UI session
166 #ifdef G4UI_USE
167  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
168 #ifdef G4VIS_USE
169  // UImanager->ApplyCommand("/control/execute vis.mac");
170 #endif
171  // if (ui->IsGUI())
172  // UImanager->ApplyCommand("/control/execute gui.mac");
173  ui->SessionStart();
174  delete ui;
175 #endif
176  }
177 
178 #ifdef G4VIS_USE
179  delete visManager;
180 #endif
181  delete runManager;
182 
183 
184  return 0;
185 }
186 
187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
void PrintUsage()
int main(int argc, char **argv)
Definition: exampleGB04.cc:69