|
|
|||
File indexing completed on 2026-04-30 07:32:58
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 examplePar01.cc 0027 /// \brief Main program of the parameterisations/Par01 example 0028 0029 // -------------------------------------------------------------- 0030 // Geant4 - examplePar01 0031 // -------------------------------------------------------------- 0032 // Comments 0033 // 0034 // Example of a main program making use of parameterisation 0035 // i.e. "Fast Simulation" 0036 //------------------------------------------------------------------- 0037 0038 #include "G4Types.hh" 0039 0040 //--------------- 0041 // -- Geometries: 0042 //--------------- 0043 #include "Par01DetectorConstruction.hh" 0044 #include "Par01ParallelWorldForPion.hh" 0045 0046 //--------------------------------------------------------------------- 0047 // -- Physics list, and tool to modify it and activate fast simulation: 0048 //--------------------------------------------------------------------- 0049 #include "FTFP_BERT.hh" 0050 0051 #include "G4FastSimulationPhysics.hh" 0052 #include "G4RunManagerFactory.hh" 0053 #include "G4UImanager.hh" 0054 0055 // ---------------------------------------------------------------- 0056 // -- Action initialization (includes the primary generator action: 0057 // ---------------------------------------------------------------- 0058 #include "Par01ActionInitialization.hh" 0059 0060 #include "G4UIExecutive.hh" 0061 #include "G4VisExecutive.hh" 0062 0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0064 0065 int main(int argc, char** argv) 0066 { 0067 // Instantiate G4UIExecutive if interactive mode 0068 G4UIExecutive* ui = nullptr; 0069 if (argc == 1) { 0070 ui = new G4UIExecutive(argc, argv); 0071 } 0072 0073 //------------------------------- 0074 // Initialization of Run manager 0075 //------------------------------- 0076 auto* runManager = G4RunManagerFactory::CreateRunManager(); 0077 runManager->SetNumberOfThreads(4); 0078 0079 // ----------------------------------------------------- 0080 // -- Detector/mass geometry and parallel geometry(ies): 0081 // ----------------------------------------------------- 0082 // -- Mass geometry (ie : standard geometry): 0083 auto detector = new Par01DetectorConstruction(); 0084 // -- Parallel geometry for pion parameterisation 0085 detector->RegisterParallelWorld(new Par01ParallelWorldForPion("pionGhostWorld")); 0086 // -- Passed to the run manager: 0087 runManager->SetUserInitialization(detector); 0088 0089 // ---------------------------------------------- 0090 // -- PhysicsList and fast simulation activation: 0091 // ---------------------------------------------- 0092 // -- Create a physics list (note : FTFP_BERT is a G4VModularPhysicsList 0093 // -- which allows to use the subsequent G4FastSimulationPhysics tool to 0094 // -- activate the fast simulation): 0095 auto physicsList = new FTFP_BERT; 0096 // -- Create helper tool, used to activate the fast simulation: 0097 auto fastSimulationPhysics = new G4FastSimulationPhysics(); 0098 fastSimulationPhysics->BeVerbose(); 0099 // -- activation of fast simulation for particles having fast simulation models 0100 // -- attached in the mass geometry: 0101 fastSimulationPhysics->ActivateFastSimulation("e-"); 0102 fastSimulationPhysics->ActivateFastSimulation("e+"); 0103 fastSimulationPhysics->ActivateFastSimulation("gamma"); 0104 // -- activation of fast simulation for particles having fast simulation models 0105 // -- attached in the parallel geometry: 0106 fastSimulationPhysics->ActivateFastSimulation("pi+", "pionGhostWorld"); 0107 fastSimulationPhysics->ActivateFastSimulation("pi-", "pionGhostWorld"); 0108 // -- Attach the fast simulation physics constructor to the physics list: 0109 physicsList->RegisterPhysics(fastSimulationPhysics); 0110 // -- Finally passes the physics list to the run manager: 0111 runManager->SetUserInitialization(physicsList); 0112 0113 //------------------------------- 0114 // UserAction classes 0115 //------------------------------- 0116 runManager->SetUserInitialization(new Par01ActionInitialization); 0117 0118 // Initialize Run manager 0119 runManager->Initialize(); 0120 0121 //---------------- 0122 // Visualization: 0123 //---------------- 0124 G4cout << "Instantiating Visualization Manager......." << G4endl; 0125 G4VisManager* visManager = new G4VisExecutive; 0126 visManager->Initialize(); 0127 0128 if (ui) { 0129 //-------------------------- 0130 // Define (G)UI 0131 //-------------------------- 0132 ui->SessionStart(); 0133 delete ui; 0134 } 0135 else { 0136 G4String command = "/control/execute "; 0137 G4String fileName = argv[1]; 0138 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 0139 UImanager->ApplyCommand(command + fileName); 0140 } 0141 0142 // Free the store: user actions, physics_list and detector_description are 0143 // owned and deleted by the run manager, so they should not 0144 // be deleted in the main() program ! 0145 0146 delete visManager; 0147 delete runManager; 0148 0149 return 0; 0150 }
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|