LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
FissionFragment.cc File Reference

Main program of the FissionFragment example. More...

#include "globals.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "QGSP_BIC_HP.hh"
#include "Randomize.hh"
#include "FFDetectorConstruction.hh"
#include "FFActionInitialization.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Main program of the FissionFragment example.

Author
B. Wendt (bryce.nosp@m.n.li.nosp@m.nn.we.nosp@m.ndt@.nosp@m.cern..nosp@m.ch)
Date
June 06, 2014

Application demonstrating the Fission Fragment model as used within the neutron_hp model. It demostrates the capability for fission product containment by the cladding in a water moderated sub-critical assembly. It could also be further extended to calculate the effective multiplication factor of the subcritical assembly for various loading schemes.

Definition in file FissionFragment.cc.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 83 of file FissionFragment.cc.

References seed.

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