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 /// \file electromagnetic/TestEm3/TestEm3.cc << 26 /// \file Hadr05.cc 27 /// \brief Main program of the electromagnetic << 27 /// \brief Main program of the hadronic/Hadr05 example 28 // 28 // >> 29 // $Id$ 29 // 30 // 30 //....oooOO0OOooo........oooOO0OOooo........oo << 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo << 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 33 >> 34 #include "G4RunManager.hh" >> 35 #include "G4MTRunManager.hh" >> 36 #include "G4UImanager.hh" >> 37 #include "Randomize.hh" 32 38 33 #include "ActionInitialization.hh" << 34 #include "DetectorConstruction.hh" 39 #include "DetectorConstruction.hh" 35 #include "PhysicsList.hh" << 40 #include "G4PhysListFactory.hh" >> 41 #include "G4VModularPhysicsList.hh" >> 42 #include "PrimaryGeneratorAction.hh" >> 43 #include "ActionInitialization.hh" 36 44 37 #include "G4ParticleHPManager.hh" << 45 #include "G4GenericPhysicsList.hh" 38 #include "G4RunManagerFactory.hh" << 46 39 #include "G4SteppingVerbose.hh" << 47 #ifdef G4VIS_USE 40 #include "G4Types.hh" << 41 #include "G4UIExecutive.hh" << 42 #include "G4UImanager.hh" << 43 #include "G4VisExecutive.hh" 48 #include "G4VisExecutive.hh" 44 #include "Randomize.hh" << 49 #endif 45 50 46 //....oooOO0OOooo........oooOO0OOooo........oo << 51 #ifdef G4UI_USE >> 52 #include "G4UIExecutive.hh" >> 53 #endif 47 54 48 int main(int argc, char** argv) << 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 49 { << 50 // detect interactive mode (if no arguments) << 51 G4UIExecutive* ui = nullptr; << 52 if (argc == 1) { << 53 ui = new G4UIExecutive(argc, argv); << 54 } << 55 56 56 // Use SteppingVerbose with Unit << 57 int main(int argc,char** argv) { 57 G4int precision = 4; << 58 G4SteppingVerbose::UseBestUnit(precision); << 59 58 60 // Creating run manager << 59 //choose the Random engine 61 auto runManager = G4RunManagerFactory::Creat << 60 G4Random::setTheEngine(new CLHEP::RanecuEngine()); 62 61 63 if (argc == 3) { << 62 #ifdef G4MULTITHREADED 64 G4int nThreads = G4UIcommand::ConvertToInt << 63 G4MTRunManager * runManager = new G4MTRunManager(); >> 64 >> 65 // Number of threads can be defined via 3rd argument >> 66 if (argc==4) { >> 67 G4int nThreads = G4UIcommand::ConvertToInt(argv[3]); 65 runManager->SetNumberOfThreads(nThreads); 68 runManager->SetNumberOfThreads(nThreads); 66 } 69 } >> 70 G4cout << "##### Hadr05 started for " << runManager->GetNumberOfThreads() >> 71 << " threads" << " #####" << G4endl; >> 72 #else >> 73 G4RunManager * runManager = new G4RunManager(); >> 74 G4cout << "##### Hadr05 started in sequential mode" >> 75 << " #####" << G4endl; >> 76 #endif 67 77 68 // set mandatory initialization classes << 78 //set mandatory initialization classes 69 DetectorConstruction* detector = new Detecto << 79 runManager->SetUserInitialization(new DetectorConstruction()); 70 runManager->SetUserInitialization(detector); << 71 runManager->SetUserInitialization(new Physic << 72 << 73 // set user action classes << 74 runManager->SetUserInitialization(new Action << 75 << 76 // Replaced HP environmental variables with << 77 G4ParticleHPManager::GetInstance()->SetSkipM << 78 G4ParticleHPManager::GetInstance()->SetDoNot << 79 G4ParticleHPManager::GetInstance()->SetUseOn << 80 G4ParticleHPManager::GetInstance()->SetNegle << 81 G4ParticleHPManager::GetInstance()->SetProdu << 82 G4ParticleHPManager::GetInstance()->SetUseWe << 83 G4ParticleHPManager::GetInstance()->SetUseNR << 84 << 85 // initialize visualization << 86 G4VisManager* visManager = nullptr; << 87 80 88 // get the pointer to the User Interface man << 81 G4VModularPhysicsList* phys = 0; 89 G4UImanager* UImanager = G4UImanager::GetUIp 82 G4UImanager* UImanager = G4UImanager::GetUIpointer(); >> 83 >> 84 // Physics List name defined via 3nd argument >> 85 if (argc>=3) >> 86 { >> 87 phys = new G4GenericPhysicsList(); >> 88 G4String physListMacro = argv[2]; >> 89 UImanager->ApplyCommand("/control/execute "+physListMacro); >> 90 } >> 91 else >> 92 { >> 93 >> 94 std::vector<G4String>* MyConstr = new std::vector<G4String>; >> 95 >> 96 MyConstr->push_back("G4EmStandardPhysics"); >> 97 MyConstr->push_back("G4EmExtraPhysics"); >> 98 MyConstr->push_back("G4DecayPhysics"); >> 99 MyConstr->push_back("G4HadronElasticPhysics"); >> 100 MyConstr->push_back("G4HadronPhysicsFTFP_BERT"); >> 101 MyConstr->push_back("G4StoppingPhysics"); >> 102 MyConstr->push_back("G4IonPhysics"); >> 103 MyConstr->push_back("G4NeutronTrackingCut"); >> 104 >> 105 phys = new G4GenericPhysicsList(MyConstr); >> 106 } >> 107 >> 108 runManager->SetUserInitialization(phys); >> 109 >> 110 //set user action classes >> 111 runManager->SetUserInitialization(new ActionInitialization()); >> 112 >> 113 #ifdef G4VIS_USE >> 114 G4VisManager* visManager = 0; >> 115 #endif >> 116 >> 117 if (argc==1) // Define UI terminal for interactive mode >> 118 { >> 119 #ifdef G4VIS_USE >> 120 //visualization manager >> 121 visManager = new G4VisExecutive; >> 122 visManager->Initialize(); >> 123 #endif >> 124 #ifdef G4UI_USE >> 125 G4UIExecutive* ui = new G4UIExecutive(argc, argv); >> 126 ui->SessionStart(); >> 127 delete ui; >> 128 #endif >> 129 } >> 130 else // Batch mode >> 131 { >> 132 G4String command = "/control/execute "; >> 133 G4String fileName = argv[1]; >> 134 UImanager->ApplyCommand(command+fileName); >> 135 } 90 136 91 if (ui) { << 137 //job termination 92 // interactive mode << 138 #ifdef G4VIS_USE 93 visManager = new G4VisExecutive(); << 94 visManager->Initialize(); << 95 ui->SessionStart(); << 96 delete ui; << 97 } << 98 else { << 99 // batch mode << 100 G4String command = "/control/execute "; << 101 G4String fileName = argv[1]; << 102 UImanager->ApplyCommand(command + fileName << 103 } << 104 << 105 // job termination << 106 delete visManager; 139 delete visManager; >> 140 #endif 107 delete runManager; 141 delete runManager; >> 142 >> 143 return 0; 108 } 144 } 109 145 110 //....oooOO0OOooo........oooOO0OOooo........oo 146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 111 147