Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 /// \file exampleGB04.cc 27 /// \file exampleGB04.cc 28 /// \brief Main program of the GB04 example 28 /// \brief Main program of the GB04 example 29 // 29 // 30 30 31 #include "FTFP_BERT.hh" << 31 #include "G4Types.hh" >> 32 >> 33 #include "G4RunManagerFactory.hh" 32 #include "GB04ActionInitialization.hh" 34 #include "GB04ActionInitialization.hh" >> 35 >> 36 #include "G4UImanager.hh" >> 37 33 #include "GB04DetectorConstruction.hh" 38 #include "GB04DetectorConstruction.hh" 34 #include "GB04PrimaryGeneratorAction.hh" 39 #include "GB04PrimaryGeneratorAction.hh" 35 40 >> 41 #include "FTFP_BERT.hh" 36 #include "G4GenericBiasingPhysics.hh" 42 #include "G4GenericBiasingPhysics.hh" 37 #include "G4RunManagerFactory.hh" << 43 38 #include "G4Types.hh" << 39 #include "G4UIExecutive.hh" << 40 #include "G4UImanager.hh" << 41 #include "G4VisExecutive.hh" 44 #include "G4VisExecutive.hh" >> 45 #include "G4UIExecutive.hh" 42 46 43 //....oooOO0OOooo........oooOO0OOooo........oo 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 44 48 45 namespace << 49 namespace { 46 { << 50 void PrintUsage() { 47 void PrintUsage() << 51 G4cerr << " Usage: " << G4endl; 48 { << 52 G4cerr << " ./exampleGB04 [-m macro ] " 49 G4cerr << " Usage: " << G4endl; << 53 << " [-b biasing {'on','off'}]" 50 G4cerr << " ./exampleGB04 [-m macro ] " << 54 << "\n or\n ./exampleGB04 [macro.mac]" 51 << " [-b biasing {'on','off'}]" << 55 << G4endl; 52 << "\n or\n ./exampleGB04 [macro.mac] << 56 } 53 } 57 } 54 } // namespace << 55 58 56 //....oooOO0OOooo........oooOO0OOooo........oo 59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 60 58 int main(int argc, char** argv) << 61 int main(int argc,char** argv) 59 { 62 { 60 // Evaluate arguments 63 // Evaluate arguments 61 // 64 // 62 if (argc > 5) { << 65 if ( argc > 5 ) { 63 PrintUsage(); 66 PrintUsage(); 64 return 1; 67 return 1; 65 } 68 } 66 69 67 G4String macro(""); 70 G4String macro(""); 68 G4String onOffBiasing(""); 71 G4String onOffBiasing(""); 69 if (argc == 2) << 72 if ( argc == 2 ) macro = argv[1]; 70 macro = argv[1]; << 73 else 71 else { << 74 { 72 for (G4int i = 1; i < argc; i = i + 2) { << 75 for ( G4int i=1; i<argc; i=i+2 ) 73 if (G4String(argv[i]) == "-m") << 76 { 74 macro = argv[i + 1]; << 77 if ( G4String(argv[i]) == "-m" ) macro = argv[i+1]; 75 else if (G4String(argv[i]) == "-b") << 78 else if ( G4String(argv[i]) == "-b" ) onOffBiasing = argv[i+1]; 76 onOffBiasing = argv[i + 1]; << 79 else 77 else { << 80 { 78 PrintUsage(); << 81 PrintUsage(); 79 return 1; << 82 return 1; 80 } << 83 } >> 84 } 81 } 85 } 82 } << 83 86 84 if (onOffBiasing == "") onOffBiasing = "on"; << 87 if ( onOffBiasing == "" ) onOffBiasing = "on"; 85 88 86 // Instantiate G4UIExecutive if interactive 89 // Instantiate G4UIExecutive if interactive mode 87 G4UIExecutive* ui = nullptr; 90 G4UIExecutive* ui = nullptr; 88 if (macro == "") { << 91 if ( macro == "" ) { 89 ui = new G4UIExecutive(argc, argv); 92 ui = new G4UIExecutive(argc, argv); 90 } 93 } 91 94 92 // -- Construct the run manager : MT or sequ 95 // -- Construct the run manager : MT or sequential one 93 auto* runManager = G4RunManagerFactory::Crea 96 auto* runManager = G4RunManagerFactory::CreateRunManager(); 94 runManager->SetNumberOfThreads(4); 97 runManager->SetNumberOfThreads(4); 95 98 96 // -- Set mandatory initialization classes 99 // -- Set mandatory initialization classes 97 GB04DetectorConstruction* detector = new GB0 100 GB04DetectorConstruction* detector = new GB04DetectorConstruction(); 98 runManager->SetUserInitialization(detector); 101 runManager->SetUserInitialization(detector); 99 // -- Select a physics list 102 // -- Select a physics list 100 FTFP_BERT* physicsList = new FTFP_BERT; 103 FTFP_BERT* physicsList = new FTFP_BERT; 101 // -- And augment it with biasing facilities 104 // -- And augment it with biasing facilities: 102 G4GenericBiasingPhysics* biasingPhysics = ne 105 G4GenericBiasingPhysics* biasingPhysics = new G4GenericBiasingPhysics(); 103 if (onOffBiasing == "on") { << 106 if ( onOffBiasing == "on" ) 104 // -- Create list of physics processes to << 107 { 105 std::vector<G4String> processToBias; << 108 // -- Create list of physics processes to be biased: only brem. in this case: 106 processToBias.push_back("eBrem"); << 109 std::vector< G4String > processToBias; 107 // -- Pass the list to the G4GenericBiasin << 110 processToBias.push_back("eBrem"); 108 // -- process of e- and e+ to activate the << 111 // -- Pass the list to the G4GenericBiasingPhysics, which will wrap the eBrem 109 biasingPhysics->PhysicsBias("e-", processT << 112 // -- process of e- and e+ to activate the biasing of it: 110 biasingPhysics->PhysicsBias("e+", processT << 113 biasingPhysics->PhysicsBias("e-", processToBias); 111 physicsList->RegisterPhysics(biasingPhysic << 114 biasingPhysics->PhysicsBias("e+", processToBias); 112 G4cout << " ************************* << 115 physicsList->RegisterPhysics(biasingPhysics); 113 G4cout << " ********** processes are << 116 G4cout << " ********************************************************* " 114 G4cout << " ************************* << 117 << G4endl; 115 } << 118 G4cout << " ********** processes are wrapped for biasing ************ " 116 else { << 119 << G4endl; 117 G4cout << " ************************* << 120 G4cout << " ********************************************************* " 118 G4cout << " ********** processes are << 121 << G4endl; 119 G4cout << " ************************* << 122 } 120 } << 123 else >> 124 { >> 125 G4cout << " ************************************************* " << G4endl; >> 126 G4cout << " ********** processes are not wrapped ************ " << G4endl; >> 127 G4cout << " ************************************************* " << G4endl; >> 128 } 121 runManager->SetUserInitialization(physicsLis 129 runManager->SetUserInitialization(physicsList); 122 // -- Action initialization: 130 // -- Action initialization: 123 runManager->SetUserInitialization(new GB04Ac 131 runManager->SetUserInitialization(new GB04ActionInitialization); 124 132 125 // Initialize G4 kernel 133 // Initialize G4 kernel 126 runManager->Initialize(); 134 runManager->Initialize(); 127 135 128 // Initialize visualization 136 // Initialize visualization 129 G4VisManager* visManager = new G4VisExecutiv 137 G4VisManager* visManager = new G4VisExecutive; 130 // G4VisExecutive can take a verbosity argum 138 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance. 131 visManager->Initialize(); 139 visManager->Initialize(); 132 140 133 // Get the pointer to the User Interface man 141 // Get the pointer to the User Interface manager 134 G4UImanager* UImanager = G4UImanager::GetUIp 142 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 135 143 136 if (!ui) // batch mode << 144 if ( !ui ) // batch mode 137 { << 145 { 138 G4String command = "/control/execute "; << 146 G4String command = "/control/execute "; 139 UImanager->ApplyCommand(command + macro); << 147 UImanager->ApplyCommand(command+macro); 140 } << 148 } 141 else { // interactive mode : define UI sess << 149 else 142 // UImanager->ApplyCommand("/control/ << 150 { // interactive mode : define UI session 143 // if (ui->IsGUI()) << 151 // UImanager->ApplyCommand("/control/execute vis.mac"); 144 // UImanager->ApplyCommand("/contro << 152 // if (ui->IsGUI()) 145 ui->SessionStart(); << 153 // UImanager->ApplyCommand("/control/execute gui.mac"); 146 delete ui; << 154 ui->SessionStart(); 147 } << 155 delete ui; >> 156 } 148 157 149 delete visManager; 158 delete visManager; 150 delete runManager; 159 delete runManager; >> 160 151 161 152 return 0; 162 return 0; 153 } 163 } 154 164 155 //....oooOO0OOooo........oooOO0OOooo........oo 165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 156 166