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 // $Id: field02.cc 77484 2013-11-25 10:11:57Z gcosmo $ 26 // 27 // 27 /// \file field/field02/field02.cc 28 /// \file field/field02/field02.cc 28 /// \brief Main program of the field/field02 e 29 /// \brief Main program of the field/field02 example 29 // 30 // >> 31 // >> 32 // >> 33 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 36 33 #include "G4Types.hh" << 37 #ifdef G4MULTITHREADED 34 << 38 #include "G4MTRunManager.hh" 35 #include "G4RunManagerFactory.hh" << 39 #else 36 #include "F02SteppingVerbose.hh" 40 #include "F02SteppingVerbose.hh" >> 41 #include "G4RunManager.hh" >> 42 #endif 37 43 38 #include "F02ActionInitialization.hh" << 44 #include "F02PhysicsList.hh" 39 #include "F02DetectorConstruction.hh" 45 #include "F02DetectorConstruction.hh" 40 #include "FTFP_BERT.hh" << 41 46 42 #include "G4StepLimiterPhysics.hh" << 47 #include "F02ActionInitialization.hh" 43 #include "G4UIExecutive.hh" << 48 44 #include "G4UImanager.hh" 49 #include "G4UImanager.hh" 45 #include "G4VisExecutive.hh" << 50 46 #include "Randomize.hh" 51 #include "Randomize.hh" 47 52 >> 53 #ifdef G4VIS_USE >> 54 #include "G4VisExecutive.hh" >> 55 #endif >> 56 >> 57 #ifdef G4UI_USE >> 58 #include "G4UIExecutive.hh" >> 59 #endif >> 60 48 //....oooOO0OOooo........oooOO0OOooo........oo 61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 49 62 50 int main(int argc, char** argv) << 63 int main(int argc,char** argv) 51 { 64 { 52 // Instantiate G4UIExecutive if there are no << 65 // Choose the Random engine 53 // << 54 G4UIExecutive* ui = nullptr; << 55 if (argc == 1) { << 56 ui = new G4UIExecutive(argc, argv); << 57 } << 58 << 59 // Setting the application-specific Stepping << 60 // 66 // 61 auto verbosity = new F02SteppingVerbose; << 67 G4Random::setTheEngine(new CLHEP::RanecuEngine); 62 68 63 // Construct the default run manager 69 // Construct the default run manager 64 // 70 // 65 auto runManager = G4RunManagerFactory::Creat << 71 #ifdef G4MULTITHREADED >> 72 G4MTRunManager * runManager = new G4MTRunManager; >> 73 #else >> 74 G4VSteppingVerbose::SetInstance(new F02SteppingVerbose); >> 75 G4RunManager * runManager = new G4RunManager; >> 76 #endif 66 77 67 // Set mandatory initialization classes 78 // Set mandatory initialization classes 68 // 79 // 69 // Detector construction 80 // Detector construction 70 auto detector = new F02DetectorConstruction( << 81 F02DetectorConstruction* detector = new F02DetectorConstruction(); 71 runManager->SetUserInitialization(detector); 82 runManager->SetUserInitialization(detector); 72 // Physics list 83 // Physics list 73 G4VModularPhysicsList* physicsList = new FTF << 84 runManager->SetUserInitialization(new F02PhysicsList(detector)); 74 physicsList->RegisterPhysics(new G4StepLimit << 75 runManager->SetUserInitialization(physicsLis << 76 // User action initialization 85 // User action initialization 77 runManager->SetUserInitialization(new F02Act 86 runManager->SetUserInitialization(new F02ActionInitialization(detector)); 78 87 79 // Initialize G4 kernel 88 // Initialize G4 kernel 80 // 89 // 81 runManager->Initialize(); 90 runManager->Initialize(); 82 91 >> 92 #ifdef G4VIS_USE 83 // Initialize visualization 93 // Initialize visualization 84 // 94 // 85 G4VisManager* visManager = new G4VisExecutiv 95 G4VisManager* visManager = new G4VisExecutive; 86 // G4VisExecutive can take a verbosity argum 96 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance. 87 // G4VisManager* visManager = new G4VisExecu 97 // G4VisManager* visManager = new G4VisExecutive("Quiet"); 88 visManager->Initialize(); 98 visManager->Initialize(); >> 99 #endif 89 100 90 // Get the pointer to the User Interface man 101 // Get the pointer to the User Interface manager 91 // 102 // 92 G4UImanager* UImanager = G4UImanager::GetUIp 103 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 93 104 94 if (!ui) // batch mode << 105 if (argc!=1) // batch mode 95 { << 106 { 96 G4String command = "/control/execute "; << 107 G4String command = "/control/execute "; 97 G4String fileName = argv[1]; << 108 G4String fileName = argv[1]; 98 UImanager->ApplyCommand(command + fileName << 109 UImanager->ApplyCommand(command+fileName); 99 } << 110 } 100 else { // interactive mode : define UI sess << 111 else 101 UImanager->ApplyCommand("/control/execute << 112 { // interactive mode : define UI session 102 if (ui->IsGUI()) UImanager->ApplyCommand(" << 113 #ifdef G4UI_USE 103 ui->SessionStart(); << 114 G4UIExecutive* ui = new G4UIExecutive(argc, argv); 104 delete ui; << 115 if (ui->IsGUI()) 105 } << 116 UImanager->ApplyCommand("/control/execute gui.mac"); >> 117 ui->SessionStart(); >> 118 delete ui; >> 119 #endif >> 120 } 106 121 107 // Job termination 122 // Job termination 108 // Free the store: user actions, physics_lis 123 // Free the store: user actions, physics_list and detector_description are 109 // owned and deleted by the 124 // owned and deleted by the run manager, so they should not 110 // be deleted in the main() 125 // be deleted in the main() program ! 111 126 112 delete verbosity; << 127 #ifdef G4VIS_USE 113 delete visManager; 128 delete visManager; >> 129 #endif 114 delete runManager; 130 delete runManager; 115 131 116 return 0; 132 return 0; 117 } 133 } 118 134 119 //....oooOO0OOooo........oooOO0OOooo........oo 135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 120 136