![]() |
|
|||
File indexing completed on 2025-02-23 09:22:32
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 /// \file Par01/examplePar01.cc 0027 /// \brief Main program of the Par01 example 0028 // 0029 // 0030 // 0031 // 0032 // -------------------------------------------------------------- 0033 // Geant4 - examplePar01 0034 // -------------------------------------------------------------- 0035 // Comments 0036 // 0037 // Example of a main program making use of parameterisation 0038 // i.e. "Fast Simulation" 0039 //------------------------------------------------------------------- 0040 0041 #include "G4Types.hh" 0042 0043 //--------------- 0044 // -- Geometries: 0045 //--------------- 0046 #include "Par01DetectorConstruction.hh" 0047 #include "Par01ParallelWorldForPion.hh" 0048 0049 //--------------------------------------------------------------------- 0050 // -- Physics list, and tool to modify it and activate fast simulation: 0051 //--------------------------------------------------------------------- 0052 #include "FTFP_BERT.hh" 0053 0054 #include "G4FastSimulationPhysics.hh" 0055 #include "G4RunManagerFactory.hh" 0056 #include "G4UImanager.hh" 0057 0058 // ---------------------------------------------------------------- 0059 // -- Action initialization (includes the primary generator action: 0060 // ---------------------------------------------------------------- 0061 #include "Par01ActionInitialization.hh" 0062 0063 #include "G4UIExecutive.hh" 0064 #include "G4VisExecutive.hh" 0065 0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0067 0068 int main(int argc, char** argv) 0069 { 0070 // Instantiate G4UIExecutive if interactive mode 0071 G4UIExecutive* ui = nullptr; 0072 if (argc == 1) { 0073 ui = new G4UIExecutive(argc, argv); 0074 } 0075 0076 //------------------------------- 0077 // Initialization of Run manager 0078 //------------------------------- 0079 auto* runManager = G4RunManagerFactory::CreateRunManager(); 0080 runManager->SetNumberOfThreads(4); 0081 0082 // ----------------------------------------------------- 0083 // -- Detector/mass geometry and parallel geometry(ies): 0084 // ----------------------------------------------------- 0085 // -- Mass geometry (ie : standard geometry): 0086 auto detector = new Par01DetectorConstruction(); 0087 // -- Parallel geometry for pion parameterisation 0088 detector->RegisterParallelWorld(new Par01ParallelWorldForPion("pionGhostWorld")); 0089 // -- Passed to the run manager: 0090 runManager->SetUserInitialization(detector); 0091 0092 // ---------------------------------------------- 0093 // -- PhysicsList and fast simulation activation: 0094 // ---------------------------------------------- 0095 // -- Create a physics list (note : FTFP_BERT is a G4VModularPhysicsList 0096 // -- which allows to use the subsequent G4FastSimulationPhysics tool to 0097 // -- activate the fast simulation): 0098 auto physicsList = new FTFP_BERT; 0099 // -- Create helper tool, used to activate the fast simulation: 0100 auto fastSimulationPhysics = new G4FastSimulationPhysics(); 0101 fastSimulationPhysics->BeVerbose(); 0102 // -- activation of fast simulation for particles having fast simulation models 0103 // -- attached in the mass geometry: 0104 fastSimulationPhysics->ActivateFastSimulation("e-"); 0105 fastSimulationPhysics->ActivateFastSimulation("e+"); 0106 fastSimulationPhysics->ActivateFastSimulation("gamma"); 0107 // -- activation of fast simulation for particles having fast simulation models 0108 // -- attached in the parallel geometry: 0109 fastSimulationPhysics->ActivateFastSimulation("pi+", "pionGhostWorld"); 0110 fastSimulationPhysics->ActivateFastSimulation("pi-", "pionGhostWorld"); 0111 // -- Attach the fast simulation physics constructor to the physics list: 0112 physicsList->RegisterPhysics(fastSimulationPhysics); 0113 // -- Finally passes the physics list to the run manager: 0114 runManager->SetUserInitialization(physicsList); 0115 0116 //------------------------------- 0117 // UserAction classes 0118 //------------------------------- 0119 runManager->SetUserInitialization(new Par01ActionInitialization); 0120 0121 // Initialize Run manager 0122 runManager->Initialize(); 0123 0124 //---------------- 0125 // Visualization: 0126 //---------------- 0127 G4cout << "Instantiating Visualization Manager......." << G4endl; 0128 G4VisManager* visManager = new G4VisExecutive; 0129 visManager->Initialize(); 0130 0131 if (ui) { 0132 //-------------------------- 0133 // Define (G)UI 0134 //-------------------------- 0135 ui->SessionStart(); 0136 delete ui; 0137 } 0138 else { 0139 G4String command = "/control/execute "; 0140 G4String fileName = argv[1]; 0141 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 0142 UImanager->ApplyCommand(command + fileName); 0143 } 0144 0145 // Free the store: user actions, physics_list and detector_description are 0146 // owned and deleted by the run manager, so they should not 0147 // be deleted in the main() program ! 0148 0149 delete visManager; 0150 delete runManager; 0151 0152 return 0; 0153 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |