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 RE06/exampleRE06.cc 26 /// \file RE06/exampleRE06.cc 27 /// \brief Main program of the RE06 example 27 /// \brief Main program of the RE06 example 28 // 28 // 29 // 29 // 30 // ------------------------------------------- 30 // -------------------------------------------------------------- 31 // GEANT 4 - example RE06 31 // GEANT 4 - example RE06 32 // ------------------------------------------- 32 // -------------------------------------------------------------- 33 33 >> 34 #include "G4Types.hh" >> 35 >> 36 #include "G4RunManagerFactory.hh" >> 37 >> 38 #include "G4VisExecutive.hh" >> 39 #include "G4UIExecutive.hh" >> 40 >> 41 #include "G4UImanager.hh" 34 #include "FTFP_BERT.hh" 42 #include "FTFP_BERT.hh" 35 #include "RE06ActionInitialization.hh" << 43 #include "G4ParallelWorldPhysics.hh" >> 44 36 #include "RE06DetectorConstruction.hh" 45 #include "RE06DetectorConstruction.hh" 37 #include "RE06ParallelWorld.hh" 46 #include "RE06ParallelWorld.hh" 38 #include "RE06PrimaryGeneratorAction.hh" 47 #include "RE06PrimaryGeneratorAction.hh" 39 #include "RE06RunAction.hh" 48 #include "RE06RunAction.hh" 40 #include "RE06SteppingVerbose.hh" 49 #include "RE06SteppingVerbose.hh" >> 50 #include "RE06ActionInitialization.hh" 41 51 42 #include "G4ParallelWorldPhysics.hh" << 52 int main(int argc,char** argv) 43 #include "G4RunManagerFactory.hh" << 44 #include "G4Types.hh" << 45 #include "G4UIExecutive.hh" << 46 #include "G4UImanager.hh" << 47 #include "G4VisExecutive.hh" << 48 << 49 int main(int argc, char** argv) << 50 { 53 { 51 // Instantiate G4UIExecutive if there are no << 54 // Instantiate G4UIExecutive if there are no arguments (interactive mode) 52 G4UIExecutive* ui = nullptr; << 55 G4UIExecutive* ui = nullptr; 53 if (argc == 1) { << 56 if ( argc == 1 ) { 54 ui = new G4UIExecutive(argc, argv); << 57 ui = new G4UIExecutive(argc, argv); 55 } << 58 } 56 << 59 57 // Construct the stepping verbose class << 60 // Construct the stepping verbose class 58 // << 61 // 59 auto verbosity = new RE06SteppingVerbose; << 62 auto verbosity = new RE06SteppingVerbose; 60 << 63 61 // Construct the run manager << 64 // Construct the run manager 62 // << 65 // 63 auto runManager = G4RunManagerFactory::Creat << 66 auto runManager = G4RunManagerFactory::CreateRunManager(); 64 << 67 65 // Set mandatory initialization classes << 68 // Set mandatory initialization classes 66 // << 69 // 67 G4String parallelWorldName = "ParallelScorin << 70 G4String parallelWorldName = "ParallelScoringWorld"; 68 auto detector = new RE06DetectorConstruction << 71 auto detector = new RE06DetectorConstruction; 69 detector->RegisterParallelWorld(new RE06Para << 72 detector->RegisterParallelWorld(new RE06ParallelWorld(parallelWorldName)); 70 runManager->SetUserInitialization(detector); << 73 runManager->SetUserInitialization(detector); 71 // << 74 // 72 auto physics = new FTFP_BERT; << 75 auto physics = new FTFP_BERT; 73 physics->RegisterPhysics(new G4ParallelWorld << 76 physics->RegisterPhysics(new G4ParallelWorldPhysics(parallelWorldName)); 74 runManager->SetUserInitialization(physics); << 77 runManager->SetUserInitialization(physics); 75 << 78 76 // Set user action classes << 79 // Set user action classes 77 // << 80 // 78 runManager->SetUserInitialization(new RE06Ac << 81 runManager->SetUserInitialization(new RE06ActionInitialization); 79 << 82 80 // Visualization manager << 83 // Visualization manager 81 // << 84 // 82 auto visManager = new G4VisExecutive; << 85 auto visManager = new G4VisExecutive; 83 visManager->Initialize(); << 86 visManager->Initialize(); 84 << 87 85 // Initialize G4 kernel << 88 // Initialize G4 kernel 86 // << 89 // 87 runManager->Initialize(); << 90 runManager->Initialize(); 88 << 91 89 // Get the pointer to the User Interface man << 92 // Get the pointer to the User Interface manager 90 // << 93 // 91 auto UImanager = G4UImanager::GetUIpointer() << 94 auto UImanager = G4UImanager::GetUIpointer(); 92 << 95 93 if (ui) // Define UI session for interactiv << 96 if (ui) // Define UI session for interactive mode 94 { << 97 { 95 UImanager->ApplyCommand("/control/execute << 98 UImanager->ApplyCommand("/control/execute vis.mac"); 96 ui->SessionStart(); << 99 ui->SessionStart(); 97 delete ui; << 100 delete ui; 98 } << 101 } 99 else // Batch mode << 102 else // Batch mode 100 { << 103 { 101 G4String command = "/control/execute "; << 104 G4String command = "/control/execute "; 102 G4String fileName = argv[1]; << 105 G4String fileName = argv[1]; 103 UImanager->ApplyCommand(command + fileName << 106 UImanager->ApplyCommand(command+fileName); 104 } << 107 } 105 << 108 106 // Job termination << 109 // Job termination 107 // Free the store: << 110 // Free the store: 108 // user actions, physics_list and detector_d << 111 // user actions, physics_list and detector_description are 109 // owned and deleted by the run manager, so << 112 // owned and deleted by the run manager, so they should not 110 // be deleted in the main() program ! << 113 // be deleted in the main() program ! 111 << 114 112 delete verbosity; << 115 delete verbosity; 113 delete visManager; << 116 delete visManager; 114 delete runManager; << 117 delete runManager; 115 118 116 return 0; << 119 return 0; 117 } 120 } 118 121