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 Par01/examplePar01.cc << 27 /// \brief Main program of the Par01 example << 28 // << 29 // << 30 // 26 // >> 27 // $Id: examplePar01.cc 77659 2013-11-27 08:57:46Z gcosmo $ 31 // 28 // >> 29 // 32 // ------------------------------------------- 30 // -------------------------------------------------------------- 33 // Geant4 - examplePar01 << 31 // GEANT 4 - examplePar01 34 // ------------------------------------------- 32 // -------------------------------------------------------------- 35 // Comments 33 // Comments 36 // 34 // 37 // Example of a main program making use of par 35 // Example of a main program making use of parameterisation 38 // i.e. "Fast Simulation" 36 // i.e. "Fast Simulation" 39 //-------------------------------------------- 37 //------------------------------------------------------------------- 40 38 41 #include "G4Types.hh" << 39 //------------------- 42 << 40 // Generator action: 43 //--------------- << 41 //------------------- 44 // -- Geometries: << 42 #include "Par01PrimaryGeneratorAction.hh" 45 //--------------- << 43 >> 44 //--------------------------- >> 45 // Parameterisation manager: >> 46 //--------------------------- >> 47 #include "G4GlobalFastSimulationManager.hh" >> 48 >> 49 //------------ >> 50 // Geometries: >> 51 //------------ 46 #include "Par01DetectorConstruction.hh" 52 #include "Par01DetectorConstruction.hh" 47 #include "Par01ParallelWorldForPion.hh" 53 #include "Par01ParallelWorldForPion.hh" 48 54 49 //-------------------------------------------- << 55 //----------------------------------- 50 // -- Physics list, and tool to modify it and << 56 // Par01PhysicsList (makes use of the 51 //-------------------------------------------- << 57 // G4ParameterisationManagerProcess): 52 #include "FTFP_BERT.hh" << 58 //----------------------------------- >> 59 #include "Par01PhysicsList.hh" 53 60 54 #include "G4FastSimulationPhysics.hh" << 55 #include "G4RunManagerFactory.hh" << 56 #include "G4UImanager.hh" 61 #include "G4UImanager.hh" 57 << 62 #ifdef G4MULTITHREADED 58 // ------------------------------------------- << 63 #include "G4MTRunManager.hh" 59 // -- Action initialization (includes the prim << 64 #else 60 // ------------------------------------------- << 65 #include "G4RunManager.hh" >> 66 #endif 61 #include "Par01ActionInitialization.hh" 67 #include "Par01ActionInitialization.hh" 62 68 63 #include "G4UIExecutive.hh" << 69 #ifdef G4VIS_USE 64 #include "G4VisExecutive.hh" 70 #include "G4VisExecutive.hh" >> 71 #endif 65 72 66 //....oooOO0OOooo........oooOO0OOooo........oo << 73 #ifdef G4UI_USE >> 74 #include "G4UIExecutive.hh" >> 75 #endif 67 76 68 int main(int argc, char** argv) 77 int main(int argc, char** argv) 69 { 78 { 70 // Instantiate G4UIExecutive if interactive << 71 G4UIExecutive* ui = nullptr; << 72 if (argc == 1) { << 73 ui = new G4UIExecutive(argc, argv); << 74 } << 75 << 76 //------------------------------- 79 //------------------------------- 77 // Initialization of Run manager 80 // Initialization of Run manager 78 //------------------------------- 81 //------------------------------- 79 auto* runManager = G4RunManagerFactory::Crea << 82 #ifdef G4MULTITHREADED >> 83 G4MTRunManager * runManager = new G4MTRunManager; 80 runManager->SetNumberOfThreads(4); 84 runManager->SetNumberOfThreads(4); >> 85 G4cout<<"+-------------------------------------------------------+"<<G4endl; >> 86 G4cout<<"| Constructing MT run manager |"<<G4endl; >> 87 G4cout<<"+-------------------------------------------------------+"<<G4endl; >> 88 #else >> 89 G4RunManager * runManager = new G4RunManager; >> 90 G4cout<<"+-------------------------------------------------------+"<<G4endl; >> 91 G4cout<<"| Constructing sequential run manager |"<<G4endl; >> 92 G4cout<<"+-------------------------------------------------------+"<<G4endl; >> 93 #endif 81 94 82 // ----------------------------------------- << 95 // Detector/mass geometry and parallel geometry(ies): 83 // -- Detector/mass geometry and parallel ge << 96 G4VUserDetectorConstruction* detector = new Par01DetectorConstruction(); 84 // ----------------------------------------- << 85 // -- Mass geometry (ie : standard geometry) << 86 auto detector = new Par01DetectorConstructio << 87 // -- Parallel geometry for pion parameteris 97 // -- Parallel geometry for pion parameterisation 88 detector->RegisterParallelWorld(new Par01Par 98 detector->RegisterParallelWorld(new Par01ParallelWorldForPion("pionGhostWorld")); 89 // -- Passed to the run manager: << 99 // -- The name passed must be the same passed to the >> 100 // -- G4FastSimulationManagerProcess attached to the pions 90 runManager->SetUserInitialization(detector); 101 runManager->SetUserInitialization(detector); 91 << 102 92 // ----------------------------------------- << 103 // PhysicsList (including G4FastSimulationManagerProcess) 93 // -- PhysicsList and fast simulation activa << 104 G4VUserPhysicsList* physicsList = new Par01PhysicsList; 94 // ----------------------------------------- << 95 // -- Create a physics list (note : FTFP_BER << 96 // -- which allows to use the subsequent G4F << 97 // -- activate the fast simulation): << 98 auto physicsList = new FTFP_BERT; << 99 // -- Create helper tool, used to activate t << 100 auto fastSimulationPhysics = new G4FastSimul << 101 fastSimulationPhysics->BeVerbose(); << 102 // -- activation of fast simulation for part << 103 // -- attached in the mass geometry: << 104 fastSimulationPhysics->ActivateFastSimulatio << 105 fastSimulationPhysics->ActivateFastSimulatio << 106 fastSimulationPhysics->ActivateFastSimulatio << 107 // -- activation of fast simulation for part << 108 // -- attached in the parallel geometry: << 109 fastSimulationPhysics->ActivateFastSimulatio << 110 fastSimulationPhysics->ActivateFastSimulatio << 111 // -- Attach the fast simulation physics con << 112 physicsList->RegisterPhysics(fastSimulationP << 113 // -- Finally passes the physics list to the << 114 runManager->SetUserInitialization(physicsLis 105 runManager->SetUserInitialization(physicsList); 115 106 116 //------------------------------- 107 //------------------------------- 117 // UserAction classes 108 // UserAction classes 118 //------------------------------- 109 //------------------------------- 119 runManager->SetUserInitialization(new Par01A << 110 runManager->SetUserInitialization( new Par01ActionInitialization ); 120 111 121 // Initialize Run manager 112 // Initialize Run manager 122 runManager->Initialize(); 113 runManager->Initialize(); 123 114 124 //---------------- 115 //---------------- 125 // Visualization: 116 // Visualization: 126 //---------------- 117 //---------------- >> 118 #ifdef G4VIS_USE 127 G4cout << "Instantiating Visualization Manag 119 G4cout << "Instantiating Visualization Manager......." << G4endl; 128 G4VisManager* visManager = new G4VisExecutiv 120 G4VisManager* visManager = new G4VisExecutive; 129 visManager->Initialize(); << 121 visManager -> Initialize (); >> 122 #endif 130 123 131 if (ui) { << 124 if(argc==1) >> 125 { 132 //-------------------------- 126 //-------------------------- 133 // Define (G)UI 127 // Define (G)UI 134 //-------------------------- 128 //-------------------------- >> 129 #ifdef G4UI_USE >> 130 G4UIExecutive * ui = new G4UIExecutive(argc, argv); 135 ui->SessionStart(); 131 ui->SessionStart(); 136 delete ui; 132 delete ui; >> 133 #endif 137 } 134 } 138 else { << 135 else >> 136 { 139 G4String command = "/control/execute "; 137 G4String command = "/control/execute "; 140 G4String fileName = argv[1]; 138 G4String fileName = argv[1]; 141 G4UImanager* UImanager = G4UImanager::GetU << 139 G4UImanager * UImanager = G4UImanager::GetUIpointer(); 142 UImanager->ApplyCommand(command + fileName << 140 UImanager->ApplyCommand(command+fileName); 143 } 141 } 144 142 145 // Free the store: user actions, physics_lis 143 // Free the store: user actions, physics_list and detector_description are 146 // owned and deleted by the 144 // owned and deleted by the run manager, so they should not 147 // be deleted in the main() 145 // be deleted in the main() program ! 148 146 >> 147 #ifdef G4VIS_USE 149 delete visManager; 148 delete visManager; >> 149 #endif 150 delete runManager; 150 delete runManager; 151 151 152 return 0; 152 return 0; 153 } 153 } 154 154