Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  char Force[] = "G4FORCENUMBEROFTHREADS";
101  if(getenv(Force) != NULL) {
102  char doNotForce[]="G4FORCENUMBEROFTHREADS=1";
103  putenv(doNotForce);
104  }
105 
106  // Indicate the example is starting
107  G4cout << "#### Starting: " << argv[0] << " ####" << G4endl;
108 
109  // Verify that NeutronHP is going to create fission fragments
110  // Throw and error if it isn't.
111  if(getenv(makeFissionFragments) == NULL)
112  {
113  G4cerr << G4endl << "!!!!" << G4endl;
114  G4cerr << "!!!! Error in example" << argv[0] << G4endl;
115  G4cerr << "!!!! The \"" << makeFissionFragments << "\" "
116  "environment variable is not set!" << G4endl;
117  G4cerr << "!!!! Please set it in order to use this example." << G4endl;
118  G4cerr << "!!!!" << G4endl << G4endl;
119 
120  return EXIT_FAILURE;
121  }
122 
123  // We are trying to use the Wendt fission model in Neutron_HP
124  // Warn the user if the appropriate environment variable is not set up
125  if(getenv(useWendtFission) == NULL)
126  {
127  G4cout << G4endl << "!!!!" << G4endl;
128  G4cout << "!!!! Warning in example" << argv[0] << G4endl;
129  G4cout << "!!!! The \"" << useWendtFission << "\" "
130  "environment variable is not set!" << G4endl;
131  G4cout << "!!!! Please set it if you wish to use this fission model, "
132  "otherwise the default fission model will be used" << G4endl;
133  G4cout << "!!!!" << G4endl << G4endl;
134  }
135 
136  // Parse the command line arguments, if any
137  for(int i = 1;
138  i < argc;
139  i += 2)
140  {
141  // Ensure that this is actually a command
142  if(argv[i][0] != '-')
143  {
144  G4cerr << G4endl << "!!!!" << G4endl;
145  G4cerr << "!!!! Error in argument " << i + 1 << G4endl;
146  G4cerr << "!!!! A command-line option was expected, but \""
147  << argv[i] << "\" was found" << G4endl;
148  G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl;
149  G4cerr << "!!!!" << G4endl << G4endl;
150 
151  return EXIT_FAILURE;
152  }
153 
154  // Ensure that the command-line option has an associated argument
155  if(!(i + 1 < argc))
156  {
157  G4cerr << G4endl << "!!!!" << G4endl;
158  G4cerr << "!!!! Error in argument " << i + 2 << G4endl;
159  G4cerr << "!!!! An argument was expected, but \"" << argv[i + 1]
160  << "\" was found" << G4endl;
161  G4cerr << "!!!! Ensure that a space is used to separate the "
162  "option and argument" << G4endl;
163  G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl;
164  G4cerr << "!!!!" << G4endl << G4endl;
165 
166  return EXIT_FAILURE;
167  }
168 
169  switch(argv[i][1])
170  {
171  case 'i':
172  scriptFileName = "/control/execute ";
173  scriptFileName.append(argv[i + 1]);
174  break;
175 
176  case 'o':
177  outputFileName = argv[i + 1];
178  break;
179 
180  case 'n':
181  result = sscanf(argv[i + 1],
182  "%u",
183  &numberOfThreads);
184  if(result != 1)
185  {
186  G4cerr << G4endl << "!!!!" << G4endl;
187  G4cerr << "!!!! Error in argument " << i + 2 << G4endl;
188  G4cerr << "!!!! An positive number was expected, but \""
189  << argv[i + 1] << "\" was found" << G4endl;
190  G4cerr << "!!!! " << argv[0] << " will now terminate"
191  << G4endl;
192  G4cerr << "!!!!" << G4endl << G4endl;
193 
194  return EXIT_FAILURE;
195  }
196  break;
197 
198  default:
199  G4cout << G4endl << "!!!!" << G4endl;
200  G4cout << "!!!! Warning for command " << i + 1 << G4endl;
201  G4cout << "!!!! \"" << argv[i] << "\" is not a valid command"
202  << G4endl;
203  G4cout << "!!!! " << argv[0] << " will ignore \"" << argv[i]
204  << "\" and \"" << argv[i + 1] << "\"" << G4endl;
205  G4cout << "!!!!" << G4endl << G4endl;
206  }
207  }
208 
209  // Set the Random engine
210  // A seed of 62737819 produced a maximum number of 67 events on the
211  // author's system before timing out the nightly test
212  const G4long seed = 62737819;
213 #ifndef NDEBUG
214  G4cout << "MT RNG Seed: " << seed << G4endl;
215 #endif // NDEBUG
216  G4Random::setTheEngine(new CLHEP::MTwistEngine(seed));
217 
218 // The 'runManger' type must be declared here at initialization to provide for
219 // 'SetNumberOfThreads()' method required for multithreading
220 #ifdef G4MULTITHREADED
221  // Initialize the multithreaded run manager
222  G4MTRunManager* const runManager = new G4MTRunManager();
223  runManager->SetNumberOfThreads(numberOfThreads);
224 
225  G4cout << "Multithreading enabled" << G4endl;
226  G4cout << " Threads requested: " << numberOfThreads << G4endl;
227  G4cout << " Threads started: " << runManager->GetNumberOfThreads()
228  << G4endl;
229 #else
230  // Multithreading not available
231  G4RunManager* const runManager = new G4RunManager();
232 #endif // G4MULTITHREADED
233 
234  // Set mandatory initialization classes
236  runManager->SetUserInitialization(new QGSP_BIC_HP());
238 
239  // Initialize the Geant4 kernel
240  runManager->Initialize();
241 
242 #ifdef G4VIS_USE
243  // Initialize visualization
244  G4VisManager* visManager = new G4VisExecutive();
245  visManager->Initialize();
246 #endif
247 
248  // Get the pointer to the User Interface manager
249  UIManager = G4UImanager::GetUIpointer();
250 
251  if(scriptFileName.length() != 0)
252  {
253  // Batch mode
254  UIManager->ApplyCommand(scriptFileName);
255  } else
256  {
257  // Interactive mode
258 #ifdef G4UI_USE
259  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
260  ui->SessionStart();
261  delete ui;
262 #endif
263  }
264 
265  // Job termination
266  // Free the store: user actions, physics_list and detector_description are
267  // owned and deleted by the run manager, so they should not be deleted
268  // in the main() program !
269 #ifdef G4VIS_USE
270  delete visManager;
271 #endif
272  delete runManager;
273 
274  return 0;
275 }
276 
277 
G4double G4ParticleHPJENDLHEData::G4double result
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
int main(int argc, char **argv)
Definition: genwindef.cpp:30
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4GLOB_DLL std::ostream G4cout
long seed
Definition: chem4.cc:68
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:447
Definition of the FFActionInitialization class.
G4GLOB_DLL std::ostream G4cerr