Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // ------------------------------------------- 27 // GEANT4 FF_Neutron_HP 28 // 29 // Command line options: 30 // -i ARG : run in batch mode from s 31 // -o ARG : write output to file ARG 32 // (defaults to FF_Neutron_ 33 // -n ARG : multithreading with ARG 34 // (only works if Geant4 wa 35 // multithreading enables) 36 // 37 // =============== Begin Documentation Commen 38 //! 39 //! \file FissionFragment.cc 40 //! \author B. Wendt (brycen.linn.wendt@ce 41 //! \date June 06, 2014 42 //! 43 //! \brief Main program of the FissionFra 44 //! 45 //! \details Application demonstrating the 46 //! within the neutron_hp mode 47 //! for fission product contai 48 //! moderated sub-critical ass 49 //! It could also be further exten 50 //! multiplication factor of t 51 //! various loading schemes. 52 //! 53 // ================ End Documentation Comment 54 // 55 // Modified: 56 // 57 // 05-08-20 58 // Replaced deprecated HP environmental varia 59 // 23-06-14 60 // Added check for NeutronHP fission generato 61 // 62 // ------------------------------------------- 63 64 #include "FFActionInitialization.hh" 65 #include "FFDetectorConstruction.hh" 66 #include "QGSP_BIC_HP.hh" 67 68 #include "G4ParticleHPManager.hh" 69 #include "G4RunManagerFactory.hh" 70 #include "G4UIExecutive.hh" 71 #include "G4UImanager.hh" 72 #include "G4VisExecutive.hh" 73 #include "Randomize.hh" 74 #include "globals.hh" 75 76 // Entry point 77 //....oooOO0OOooo........oooOO0OOooo........oo 78 int main(int argc, char* argv[]) 79 { 80 int result; 81 unsigned int numberOfThreads = 1; 82 83 G4String scriptFileName = ""; 84 G4String outputFileName = "FF_Neutron_HP.out 85 G4UImanager* UIManager = NULL; 86 87 // Activate production of fission fragments 88 G4ParticleHPManager::GetInstance()->SetProdu 89 90 char Force[] = "G4FORCENUMBEROFTHREADS"; 91 if (std::getenv(Force) != NULL) { 92 char doNotForce[] = "G4FORCENUMBEROFTHREAD 93 putenv(doNotForce); 94 } 95 96 // Indicate the example is starting 97 G4cout << "#### Starting: " << argv[0] << 98 99 // Parse the command line arguments, if any 100 for (int i = 1; i < argc; i += 2) { 101 // Ensure that this is actually a command 102 if (argv[i][0] != '-') { 103 G4cerr << G4endl << "!!!!" << G4endl; 104 G4cerr << "!!!! Error in argument " << i 105 G4cerr << "!!!! A command-line option wa 106 << G4endl; 107 G4cerr << "!!!! " << argv[0] << " will n 108 G4cerr << "!!!!" << G4endl << G4endl; 109 110 return EXIT_FAILURE; 111 } 112 113 // Ensure that the command-line option has 114 if (!(i + 1 < argc)) { 115 G4cerr << G4endl << "!!!!" << G4endl; 116 G4cerr << "!!!! Error in argument " << i 117 G4cerr << "!!!! An argument was expected 118 G4cerr << "!!!! Ensure that a space is u 119 "option and argument" 120 << G4endl; 121 G4cerr << "!!!! " << argv[0] << " will n 122 G4cerr << "!!!!" << G4endl << G4endl; 123 124 return EXIT_FAILURE; 125 } 126 127 switch (argv[i][1]) { 128 case 'i': 129 scriptFileName = "/control/execute "; 130 scriptFileName.append(argv[i + 1]); 131 break; 132 133 case 'o': 134 outputFileName = argv[i + 1]; 135 break; 136 137 case 'n': 138 result = sscanf(argv[i + 1], "%u", &nu 139 if (result != 1) { 140 G4cerr << G4endl << "!!!!" << G4endl 141 G4cerr << "!!!! Error in argument " 142 G4cerr << "!!!! An positive number w 143 << G4endl; 144 G4cerr << "!!!! " << argv[0] << " wi 145 G4cerr << "!!!!" << G4endl << G4endl 146 147 return EXIT_FAILURE; 148 } 149 break; 150 151 default: 152 G4cout << G4endl << "!!!!" << G4endl; 153 G4cout << "!!!! Warning for command " 154 G4cout << "!!!! \"" << argv[i] << "\" 155 G4cout << "!!!! " << argv[0] << " will 156 << "\"" << G4endl; 157 G4cout << "!!!!" << G4endl << G4endl; 158 } 159 } 160 161 // Instantiate G4UIExecutive if interactive 162 G4UIExecutive* ui = nullptr; 163 if (scriptFileName.length() == 0) { 164 ui = new G4UIExecutive(argc, argv); 165 } 166 167 // Set the Random engine 168 // A seed of 62737819 produced a maximum num 169 // author's system before timing out the nig 170 const G4long seed = 62737819; 171 #ifndef NDEBUG 172 G4cout << "MT RNG Seed: " << seed << G4endl; 173 #endif // NDEBUG 174 G4Random::setTheEngine(new CLHEP::MTwistEngi 175 176 // Initialize the multithreaded run manager 177 auto* runManager = G4RunManagerFactory::Crea 178 runManager->SetNumberOfThreads(numberOfThrea 179 G4cout << " Threads requested: " << nu 180 G4cout << " Threads started: " << ru 181 182 // Set mandatory initialization classes 183 runManager->SetUserInitialization(new FFDete 184 runManager->SetUserInitialization(new QGSP_B 185 runManager->SetUserInitialization(new FFActi 186 187 // Initialize the Geant4 kernel 188 runManager->Initialize(); 189 190 // Initialize visualization 191 G4VisManager* visManager = new G4VisExecutiv 192 visManager->Initialize(); 193 194 // Get the pointer to the User Interface man 195 UIManager = G4UImanager::GetUIpointer(); 196 197 if (!ui) { 198 // Batch mode 199 UIManager->ApplyCommand(scriptFileName); 200 } 201 else { 202 // Interactive mode 203 ui->SessionStart(); 204 delete ui; 205 } 206 207 // Job termination 208 // Free the store: user actions, physics_lis 209 // owned and deleted by the run manager, so 210 // in the main() program ! 211 delete visManager; 212 delete runManager; 213 214 return 0; 215 } 216