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 /// \file exampleGB05.cc 28 /// \brief Main program of example GB05 29 30 #include "FTFP_BERT.hh" 31 #include "GB05ActionInitialization.hh" 32 #include "GB05DetectorConstruction.hh" 33 #include "GB05PrimaryGeneratorAction.hh" 34 35 #include "G4GenericBiasingPhysics.hh" 36 #include "G4RunManagerFactory.hh" 37 #include "G4Types.hh" 38 #include "G4UIExecutive.hh" 39 #include "G4UImanager.hh" 40 #include "G4VisExecutive.hh" 41 42 //....oooOO0OOooo........oooOO0OOooo........oo 43 44 namespace 45 { 46 void PrintUsage() 47 { 48 G4cerr << " Usage: " << G4endl; 49 G4cerr << " ./exampleGB05 [-m macro ] " 50 << " [-b biasing {'on','off'}]" 51 << "\n or\n ./exampleGB05 [macro.mac] 52 } 53 } // namespace 54 55 //....oooOO0OOooo........oooOO0OOooo........oo 56 57 int main(int argc, char** argv) 58 { 59 // Evaluate arguments 60 // 61 if (argc > 5) { 62 PrintUsage(); 63 return 1; 64 } 65 66 G4String macro(""); 67 G4String onOffBiasing(""); 68 if (argc == 2) 69 macro = argv[1]; 70 else { 71 for (G4int i = 1; i < argc; i = i + 2) { 72 if (G4String(argv[i]) == "-m") 73 macro = argv[i + 1]; 74 else if (G4String(argv[i]) == "-b") 75 onOffBiasing = argv[i + 1]; 76 else { 77 PrintUsage(); 78 return 1; 79 } 80 } 81 } 82 83 if (onOffBiasing == "") onOffBiasing = "on"; 84 85 // Instantiate G4UIExecutive if interactive 86 G4UIExecutive* ui = nullptr; 87 if (macro == "") { 88 ui = new G4UIExecutive(argc, argv); 89 } 90 91 // -- Construct the run manager : MT or sequ 92 auto* runManager = G4RunManagerFactory::Crea 93 runManager->SetNumberOfThreads(4); 94 95 // -- Set mandatory initialization classes 96 GB05DetectorConstruction* detector = new GB0 97 runManager->SetUserInitialization(detector); 98 // -- Select a physics list: 99 FTFP_BERT* physicsList = new FTFP_BERT; 100 // -- and augment it with biasing facilities 101 G4GenericBiasingPhysics* biasingPhysics = ne 102 biasingPhysics->BeVerbose(); 103 if (onOffBiasing == "on") { 104 biasingPhysics->Bias("neutron"); 105 physicsList->RegisterPhysics(biasingPhysic 106 G4cout << " ************************* 107 G4cout << " ********** processes are 108 G4cout << " ************************* 109 } 110 else { 111 G4cout << " ************************* 112 G4cout << " ********** processes are 113 G4cout << " ************************* 114 } 115 runManager->SetUserInitialization(physicsLis 116 // -- Action initialization: 117 runManager->SetUserInitialization(new GB05Ac 118 119 // Initialize G4 kernel 120 runManager->Initialize(); 121 122 // Initialize visualization 123 G4VisManager* visManager = new G4VisExecutiv 124 // G4VisExecutive can take a verbosity argum 125 visManager->Initialize(); 126 127 // Get the pointer to the User Interface man 128 G4UImanager* UImanager = G4UImanager::GetUIp 129 130 if (!ui) // batch mode 131 { 132 G4String command = "/control/execute "; 133 UImanager->ApplyCommand(command + macro); 134 } 135 else { // interactive mode : define UI sess 136 UImanager->ApplyCommand("/control/execute 137 // if (ui->IsGUI()) 138 // UImanager->ApplyCommand("/ 139 ui->SessionStart(); 140 delete ui; 141 } 142 143 delete visManager; 144 delete runManager; 145 146 return 0; 147 } 148 149 //....oooOO0OOooo........oooOO0OOooo........oo 150