|
|
|||
File indexing completed on 2026-09-23 08:29:16
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 Hadr00.cc 0027 /// \brief Main program of the hadronic/Hadr00 example 0028 0029 // ------------------------------------------------------------- 0030 // GEANT4 Hadr00 0031 // 0032 // Application demonstrating Geant4 hadronic cross sections 0033 // 0034 // Author: V.Ivanchenko 20 June 2008 0035 // 0036 // Modified: 0037 // 0038 // ------------------------------------------------------------- 0039 // 0040 // 0041 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0043 0044 #include "ActionInitialization.hh" 0045 #include "DetectorConstruction.hh" 0046 #include "PrimaryGeneratorAction.hh" 0047 0048 #include "G4PhysListFactory.hh" 0049 #include "G4RunManagerFactory.hh" 0050 #include "G4UIExecutive.hh" 0051 #include "G4UImanager.hh" 0052 #include "G4VModularPhysicsList.hh" 0053 #include "G4VisExecutive.hh" 0054 #include "Randomize.hh" 0055 0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0057 0058 int main(int argc, char** argv) 0059 { 0060 // detect interactive mode (if no arguments) and define UI session 0061 G4UIExecutive* ui = nullptr; 0062 if (argc == 1) { 0063 ui = new G4UIExecutive(argc, argv); 0064 } 0065 0066 auto* runManager = G4RunManagerFactory::CreateRunManager(); 0067 0068 // Number of threads can be defined via 3rd argument 0069 if (argc == 4) { 0070 G4int nThreads = G4UIcommand::ConvertToInt(argv[3]); 0071 runManager->SetNumberOfThreads(nThreads); 0072 } 0073 G4cout << "##### Hadr00 started for " << runManager->GetNumberOfThreads() << " threads" 0074 << " #####" << G4endl; 0075 0076 // set mandatory initialization classes 0077 DetectorConstruction* det = new DetectorConstruction(); 0078 runManager->SetUserInitialization(det); 0079 0080 G4PhysListFactory factory; 0081 G4VModularPhysicsList* phys = nullptr; 0082 G4String physName = ""; 0083 0084 // Physics List name defined via 3nd argument 0085 if (argc >= 3) { 0086 physName = argv[2]; 0087 } 0088 0089 // Physics List is defined via environment variable PHYSLIST 0090 if ("" == physName) { 0091 char* path = std::getenv("PHYSLIST"); 0092 if (path) { 0093 physName = G4String(path); 0094 } 0095 } 0096 0097 // if name is not known to the factory use FTFP_BERT 0098 if ("" == physName || !factory.IsReferencePhysList(physName)) { 0099 physName = "FTFP_BERT"; 0100 } 0101 0102 // reference PhysicsList via its name 0103 phys = factory.GetReferencePhysList(physName); 0104 0105 runManager->SetUserInitialization(phys); 0106 det->SetPhysicsList(phys); 0107 0108 // set user action classes 0109 runManager->SetUserInitialization(new ActionInitialization(det)); 0110 0111 // initialize visualization 0112 G4VisManager* visManager = nullptr; 0113 0114 // get the pointer to the User Interface manager 0115 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 0116 0117 if (ui) { 0118 // interactive mode 0119 visManager = new G4VisExecutive; 0120 visManager->Initialize(); 0121 ui->SessionStart(); 0122 delete ui; 0123 } 0124 else { 0125 // batch mode 0126 G4String command = "/control/execute "; 0127 G4String fileName = argv[1]; 0128 UImanager->ApplyCommand(command + fileName); 0129 } 0130 0131 // job termination 0132 delete visManager; 0133 delete runManager; 0134 } 0135 0136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|