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