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 hadronic/Hadr01/Hadr01.cc 26 /// \file hadronic/Hadr01/Hadr01.cc 27 /// \brief Main program of the hadronic/Hadr01 27 /// \brief Main program of the hadronic/Hadr01 example 28 // 28 // 29 // 29 // 30 // 30 // 31 // ------------------------------------------- 31 // ------------------------------------------------------------- 32 // GEANT4 Hadr01 32 // GEANT4 Hadr01 33 // 33 // 34 // Application demonstrating Geant4 hadronic 34 // Application demonstrating Geant4 hadronic physics: 35 // beam interaction with a target 35 // beam interaction with a target 36 // 36 // 37 // Authors: A.Bagulya, I.Gudowska, V.Ivanchen 37 // Authors: A.Bagulya, I.Gudowska, V.Ivanchenko, N.Starkov 38 // 38 // 39 // Modified: 39 // Modified: 40 // 29.12.2009 V.Ivanchenko introduced access 40 // 29.12.2009 V.Ivanchenko introduced access to reference PhysLists 41 // 41 // 42 // ------------------------------------------- 42 // ------------------------------------------------------------- 43 // 43 // 44 // 44 // 45 //....oooOO0OOooo........oooOO0OOooo........oo 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 //....oooOO0OOooo........oooOO0OOooo........oo 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 47 >> 48 #include "G4RunManagerFactory.hh" >> 49 #include "G4UImanager.hh" >> 50 48 #include "DetectorConstruction.hh" 51 #include "DetectorConstruction.hh" 49 #include "EventAction.hh" << 50 #include "PhysicsList.hh" 52 #include "PhysicsList.hh" >> 53 #include "G4PhysListFactory.hh" >> 54 #include "G4VModularPhysicsList.hh" 51 #include "PrimaryGeneratorAction.hh" 55 #include "PrimaryGeneratorAction.hh" >> 56 #include "G4HadronicParameters.hh" >> 57 52 #include "RunAction.hh" 58 #include "RunAction.hh" >> 59 #include "EventAction.hh" 53 #include "StackingAction.hh" 60 #include "StackingAction.hh" 54 61 55 #include "G4HadronicParameters.hh" << 56 #include "G4PhysListFactory.hh" << 57 #include "G4RunManagerFactory.hh" << 58 #include "G4UIExecutive.hh" 62 #include "G4UIExecutive.hh" 59 #include "G4UImanager.hh" << 60 #include "G4VModularPhysicsList.hh" << 61 #include "G4VisExecutive.hh" 63 #include "G4VisExecutive.hh" 62 64 63 //....oooOO0OOooo........oooOO0OOooo........oo 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 66 65 int main(int argc, char** argv) << 67 int main(int argc,char** argv) { 66 { << 68 67 // detect interactive mode (if no arguments) << 69 //detect interactive mode (if no arguments) and define UI session 68 G4UIExecutive* ui = nullptr; 70 G4UIExecutive* ui = nullptr; 69 if (argc == 1) { << 71 if (argc == 1) { ui = new G4UIExecutive(argc,argv); } 70 ui = new G4UIExecutive(argc, argv); << 71 } << 72 72 73 // Construct a serial run manager << 73 //Construct a serial run manager 74 auto* runManager = G4RunManagerFactory::Crea 74 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly); 75 75 76 // set mandatory initialization classes << 76 //set mandatory initialization classes 77 runManager->SetUserInitialization(new Detect 77 runManager->SetUserInitialization(new DetectorConstruction()); 78 78 79 G4PhysListFactory factory; 79 G4PhysListFactory factory; 80 G4VModularPhysicsList* phys = nullptr; 80 G4VModularPhysicsList* phys = nullptr; 81 G4String physName = ""; 81 G4String physName = ""; 82 82 83 // Physics List name defined via 3nd argumen << 83 //Physics List name defined via 3nd argument 84 if (argc >= 3) { << 84 if (argc >= 3) { physName = argv[2]; } 85 physName = argv[2]; << 86 } << 87 85 88 // Physics List name defined via environment 86 // Physics List name defined via environment variable 89 if ("" == physName) { << 87 if("" == physName) { 90 char* path = std::getenv("PHYSLIST"); 88 char* path = std::getenv("PHYSLIST"); 91 if (nullptr != path) { << 89 if (nullptr != path) { physName = G4String(path); } 92 physName = G4String(path); << 93 } << 94 } 90 } 95 91 96 G4cout << "PhysicsList: " << physName << G4e 92 G4cout << "PhysicsList: " << physName << G4endl; 97 93 98 // reference PhysicsList via its name 94 // reference PhysicsList via its name 99 if ("" != physName && factory.IsReferencePhy 95 if ("" != physName && factory.IsReferencePhysList(physName)) { 100 phys = factory.GetReferencePhysList(physNa 96 phys = factory.GetReferencePhysList(physName); 101 } 97 } 102 98 103 // local Physics List 99 // local Physics List 104 if (nullptr == phys) { << 100 if (nullptr == phys) { phys = new PhysicsList(); } 105 phys = new PhysicsList(); << 106 } << 107 101 108 // optional change of overlap cascade/string 102 // optional change of overlap cascade/string 109 if (argc >= 5) { 103 if (argc >= 5) { 110 auto param = G4HadronicParameters::Instanc 104 auto param = G4HadronicParameters::Instance(); 111 G4double e1 = CLHEP::GeV * std::strtod(arg << 105 G4double e1 = CLHEP::GeV*std::strtod(argv[3], 0); 112 G4double e2 = CLHEP::GeV * std::strtod(arg << 106 G4double e2 = CLHEP::GeV*std::strtod(argv[4], 0); 113 G4cout << "### Bertini/FTFP limits: e1(GeV << 107 G4cout << "### Bertini/FTFP limits: e1(GeV)=" << e1/CLHEP::GeV 114 << " e2(GeV)=" << e2 / CLHEP::GeV << 108 << " e2(GeV)=" << e2/CLHEP::GeV << G4endl; 115 param->SetMinEnergyTransitionFTF_Cascade(e 109 param->SetMinEnergyTransitionFTF_Cascade(e1); 116 param->SetMaxEnergyTransitionFTF_Cascade(e 110 param->SetMaxEnergyTransitionFTF_Cascade(e2); 117 } 111 } 118 112 119 if (argc >= 6) { << 120 auto param = G4HadronicParameters::Instanc << 121 param->SetEnableNUDEX(true); << 122 } << 123 << 124 // define physics 113 // define physics 125 runManager->SetUserInitialization(phys); 114 runManager->SetUserInitialization(phys); 126 runManager->SetUserAction(new PrimaryGenerat 115 runManager->SetUserAction(new PrimaryGeneratorAction()); 127 116 128 // set user action classes << 117 //set user action classes 129 runManager->SetUserAction(new RunAction()); 118 runManager->SetUserAction(new RunAction()); 130 runManager->SetUserAction(new EventAction()) 119 runManager->SetUserAction(new EventAction()); 131 runManager->SetUserAction(new StackingAction 120 runManager->SetUserAction(new StackingAction()); 132 121 133 // initialize visualization << 122 //initialize visualization 134 G4VisManager* visManager = nullptr; 123 G4VisManager* visManager = nullptr; 135 124 136 // get the pointer to the User Interface man << 125 //get the pointer to the User Interface manager 137 G4UImanager* UImanager = G4UImanager::GetUIp 126 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 138 127 139 if (ui) { << 128 if (ui) { 140 // interactive mode << 129 //interactive mode 141 visManager = new G4VisExecutive; 130 visManager = new G4VisExecutive; 142 visManager->Initialize(); 131 visManager->Initialize(); 143 ui->SessionStart(); 132 ui->SessionStart(); 144 delete ui; 133 delete ui; 145 } << 134 } else { 146 else { << 135 //batch mode 147 // batch mode << 148 G4String command = "/control/execute "; 136 G4String command = "/control/execute "; 149 G4String fileName = argv[1]; 137 G4String fileName = argv[1]; 150 UImanager->ApplyCommand(command + fileName << 138 UImanager->ApplyCommand(command+fileName); 151 } 139 } 152 140 153 // job termination << 141 //job termination 154 delete visManager; 142 delete visManager; 155 delete runManager; 143 delete runManager; 156 } 144 } 157 145 158 //....oooOO0OOooo........oooOO0OOooo........oo 146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 159 147