Geant4  10.01.p03
FissionFragment.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 // -------------------------------------------------------------
27 // GEANT4 FF_Neutron_HP
28 //
29 // Command line options:
30 // -i ARG : run in batch mode from script file ARG
31 // -o ARG : write output to file ARG
32 // (defaults to FF_Neutron_HP.out)
33 // -n ARG : multithreading with ARG number of threads
34 // (only works if Geant4 was compiled with
35 // multithreading enables)
36 //
37 // =============== Begin Documentation Comments ===============
53 // ================ End Documentation Comments ================
54 //
55 // Modified:
56 //
57 // 23-06-14 BWendt
58 // Added check for NeutronHP fission generator environment variable
59 //
60 // -------------------------------------------------------------
61 
62 #include "globals.hh"
63 
64 #ifdef G4MULTITHREADED
65 #include "G4MTRunManager.hh"
66 #else
67 #include "G4RunManager.hh"
68 #endif // G4MULTITHREADED
69 
70 #include "G4UImanager.hh"
71 #include "QGSP_BIC_HP.hh"
72 #include "Randomize.hh"
73 
76 
77 #ifdef G4VIS_USE
78 #include "G4VisExecutive.hh"
79 #endif
80 
81 #ifdef G4UI_USE
82 #include "G4UIExecutive.hh"
83 #endif
84 
85 
86 // Entry point
87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88 int main(int argc, char* argv[])
89 {
90  int result;
91  unsigned int numberOfThreads = 1;
92 
93  G4String scriptFileName = "";
94  G4String outputFileName = "FF_Neutron_HP.out";
95  G4UImanager* UIManager = NULL;
96 
97  char makeFissionFragments[] = "G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS";
98  char useWendtFission[] = "G4NEUTRON_HP_USE_WENDT_FISSION_MODEL";
99 
100  // Indicate the example is starting
101  G4cout << "#### Starting: " << argv[0] << " ####" << G4endl;
102 
103  // Verify that NeutronHP is going to create fission fragments
104  // Throw and error if it isn't.
105  if(getenv(makeFissionFragments) == NULL)
106  {
107  G4cerr << G4endl << "!!!!" << G4endl;
108  G4cerr << "!!!! Error in example" << argv[0] << G4endl;
109  G4cerr << "!!!! The \"" << makeFissionFragments << "\" "
110  "environment variable is not set!" << G4endl;
111  G4cerr << "!!!! Please set it in order to use this example." << G4endl;
112  G4cerr << "!!!!" << G4endl << G4endl;
113 
114  return EXIT_FAILURE;
115  }
116 
117  // We are trying to use the Wendt fission model in Neutron_HP
118  // Warn the user if the appropriate environment variable is not set up
119  if(getenv(useWendtFission) == NULL)
120  {
121  G4cout << G4endl << "!!!!" << G4endl;
122  G4cout << "!!!! Warning in example" << argv[0] << G4endl;
123  G4cout << "!!!! The \"" << useWendtFission << "\" "
124  "environment variable is not set!" << G4endl;
125  G4cout << "!!!! Please set it if you wish to use this fission model, "
126  "otherwise the default fission model will be used" << G4endl;
127  G4cout << "!!!!" << G4endl << G4endl;
128  }
129 
130  // Parse the command line arguments, if any
131  for(int i = 1;
132  i < argc;
133  i += 2)
134  {
135  // Ensure that this is actually a command
136  if(argv[i][0] != '-')
137  {
138  G4cerr << G4endl << "!!!!" << G4endl;
139  G4cerr << "!!!! Error in argument " << i + 1 << G4endl;
140  G4cerr << "!!!! A command-line option was expected, but \""
141  << argv[i] << "\" was found" << G4endl;
142  G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl;
143  G4cerr << "!!!!" << G4endl << G4endl;
144 
145  return EXIT_FAILURE;
146  }
147 
148  // Ensure that the command-line option has an associated argument
149  if(!(i + 1 < argc))
150  {
151  G4cerr << G4endl << "!!!!" << G4endl;
152  G4cerr << "!!!! Error in argument " << i + 2 << G4endl;
153  G4cerr << "!!!! An argument was expected, but \"" << argv[i + 1]
154  << "\" was found" << G4endl;
155  G4cerr << "!!!! Ensure that a space is used to separate the "
156  "option and argument" << G4endl;
157  G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl;
158  G4cerr << "!!!!" << G4endl << G4endl;
159 
160  return EXIT_FAILURE;
161  }
162 
163  switch(argv[i][1])
164  {
165  case 'i':
166  scriptFileName = "/control/execute ";
167  scriptFileName.append(argv[i + 1]);
168  break;
169 
170  case 'o':
171  outputFileName = argv[i + 1];
172  break;
173 
174  case 'n':
175  result = sscanf(argv[i + 1],
176  "%u",
177  &numberOfThreads);
178  if(result != 1)
179  {
180  G4cerr << G4endl << "!!!!" << G4endl;
181  G4cerr << "!!!! Error in argument " << i + 2 << G4endl;
182  G4cerr << "!!!! An positive number was expected, but \""
183  << argv[i + 1] << "\" was found" << G4endl;
184  G4cerr << "!!!! " << argv[0] << " will now terminate"
185  << G4endl;
186  G4cerr << "!!!!" << G4endl << G4endl;
187 
188  return EXIT_FAILURE;
189  }
190  break;
191 
192  default:
193  G4cout << G4endl << "!!!!" << G4endl;
194  G4cout << "!!!! Warning for command " << i + 1 << G4endl;
195  G4cout << "!!!! \"" << argv[i] << "\" is not a valid command"
196  << G4endl;
197  G4cout << "!!!! " << argv[0] << " will ignore \"" << argv[i]
198  << "\" and \"" << argv[i + 1] << "\"" << G4endl;
199  G4cout << "!!!!" << G4endl << G4endl;
200  }
201  }
202 
203  // Set the Random engine
204  // A seed of 62737819 produced a maximum number of 67 events on the
205  // author's system before timing out the nightly test
206  const G4long seed = 62737819;
207 #ifndef NDEBUG
208  G4cout << "MT RNG Seed: " << seed << G4endl;
209 #endif // NDEBUG
210  G4Random::setTheEngine(new CLHEP::MTwistEngine(seed));
211 
212 // The 'runManger' type must be declared here at initialization to provide for
213 // 'SetNumberOfThreads()' method required for multithreading
214 #ifdef G4MULTITHREADED
215  // Initialize the multithreaded run manager
216  G4MTRunManager* const runManager = new G4MTRunManager();
217  runManager->SetNumberOfThreads(numberOfThreads);
218 
219  G4cout << "Multithreading enabled" << G4endl;
220  G4cout << " Threads requested: " << numberOfThreads << G4endl;
221  G4cout << " Threads started: " << runManager->GetNumberOfThreads()
222  << G4endl;
223 #else
224  // Multithreading not available
225  G4RunManager* const runManager = new G4RunManager();
226 #endif // G4MULTITHREADED
227 
228  // Set mandatory initialization classes
230  runManager->SetUserInitialization(new QGSP_BIC_HP());
232 
233  // Initialize the Geant4 kernel
234  runManager->Initialize();
235 
236 #ifdef G4VIS_USE
237  // Initialize visualization
238  G4VisManager* visManager = new G4VisExecutive();
239  visManager->Initialize();
240 #endif
241 
242  // Get the pointer to the User Interface manager
243  UIManager = G4UImanager::GetUIpointer();
244 
245  if(scriptFileName.length() != 0)
246  {
247  // Batch mode
248  UIManager->ApplyCommand(scriptFileName);
249  } else
250  {
251  // Interactive mode
252 #ifdef G4UI_USE
253  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
254  ui->SessionStart();
255  delete ui;
256 #endif
257  }
258 
259  // Job termination
260  // Free the store: user actions, physics_list and detector_description are
261  // owned and deleted by the run manager, so they should not be deleted
262  // in the main() program !
263 #ifdef G4VIS_USE
264  delete visManager;
265 #endif
266  delete runManager;
267 
268  return 0;
269 }
270 
271 
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
TQGSP_BIC_HP< G4VModularPhysicsList > QGSP_BIC_HP
Definition: QGSP_BIC_HP.hh:63
void SetNumberOfThreads(G4int n)
long G4long
Definition: G4Types.hh:80
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
int main(int argc, char *argv[])
G4GLOB_DLL std::ostream G4cout
G4int GetNumberOfThreads() const
void Initialize()
G4String & append(const G4String &)
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
Definition of the FFDetectorConstruction class.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:432
Definition of the FFActionInitialization class.
G4GLOB_DLL std::ostream G4cerr