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 #include "Randomize.hh" >> 51 48 #include "DetectorConstruction.hh" 52 #include "DetectorConstruction.hh" 49 #include "EventAction.hh" << 50 #include "PhysicsList.hh" 53 #include "PhysicsList.hh" >> 54 #include "G4PhysListFactory.hh" >> 55 #include "G4VModularPhysicsList.hh" 51 #include "PrimaryGeneratorAction.hh" 56 #include "PrimaryGeneratorAction.hh" >> 57 #include "PhysicsListMessenger.hh" >> 58 52 #include "RunAction.hh" 59 #include "RunAction.hh" >> 60 #include "EventAction.hh" 53 #include "StackingAction.hh" 61 #include "StackingAction.hh" 54 62 55 #include "G4HadronicParameters.hh" << 56 #include "G4PhysListFactory.hh" << 57 #include "G4RunManagerFactory.hh" << 58 #include "G4UIExecutive.hh" 63 #include "G4UIExecutive.hh" 59 #include "G4UImanager.hh" << 60 #include "G4VModularPhysicsList.hh" << 61 #include "G4VisExecutive.hh" 64 #include "G4VisExecutive.hh" 62 65 63 //....oooOO0OOooo........oooOO0OOooo........oo 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 67 65 int main(int argc, char** argv) << 68 int main(int argc,char** argv) { 66 { << 69 67 // detect interactive mode (if no arguments) << 70 //detect interactive mode (if no arguments) and define UI session 68 G4UIExecutive* ui = nullptr; 71 G4UIExecutive* ui = nullptr; 69 if (argc == 1) { << 72 if (argc == 1) { ui = new G4UIExecutive(argc,argv); } 70 ui = new G4UIExecutive(argc, argv); << 71 } << 72 73 73 // Construct a serial run manager << 74 //Construct a serial run manager 74 auto* runManager = G4RunManagerFactory::Crea 75 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly); 75 76 76 // set mandatory initialization classes << 77 //set mandatory initialization classes 77 runManager->SetUserInitialization(new Detect 78 runManager->SetUserInitialization(new DetectorConstruction()); 78 79 79 G4PhysListFactory factory; 80 G4PhysListFactory factory; 80 G4VModularPhysicsList* phys = nullptr; 81 G4VModularPhysicsList* phys = nullptr; >> 82 PhysicsListMessenger* mess = nullptr; 81 G4String physName = ""; 83 G4String physName = ""; 82 84 83 // Physics List name defined via 3nd argumen << 85 //Physics List name defined via 3nd argument 84 if (argc >= 3) { << 86 if (argc==3) { physName = argv[2]; } 85 physName = argv[2]; << 86 } << 87 87 88 // Physics List name defined via environment 88 // Physics List name defined via environment variable 89 if ("" == physName) { << 89 if("" == physName) { 90 char* path = std::getenv("PHYSLIST"); 90 char* path = std::getenv("PHYSLIST"); 91 if (nullptr != path) { << 91 if (path) { physName = G4String(path); } 92 physName = G4String(path); << 93 } << 94 } 92 } 95 93 96 G4cout << "PhysicsList: " << physName << G4e << 94 //reference PhysicsList via its name 97 << 98 // 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 } << 102 97 103 // local Physics List << 98 // instantiated messenger 104 if (nullptr == phys) { << 99 mess = new PhysicsListMessenger(); 105 phys = new PhysicsList(); << 106 } 100 } 107 101 108 // optional change of overlap cascade/string << 102 //local Physics List 109 if (argc >= 5) { << 103 if(!phys) { phys = new PhysicsList(); } 110 auto param = G4HadronicParameters::Instanc << 111 G4double e1 = CLHEP::GeV * std::strtod(arg << 112 G4double e2 = CLHEP::GeV * std::strtod(arg << 113 G4cout << "### Bertini/FTFP limits: e1(GeV << 114 << " e2(GeV)=" << e2 / CLHEP::GeV << 115 param->SetMinEnergyTransitionFTF_Cascade(e << 116 param->SetMaxEnergyTransitionFTF_Cascade(e << 117 } << 118 << 119 if (argc >= 6) { << 120 auto param = G4HadronicParameters::Instanc << 121 param->SetEnableNUDEX(true); << 122 } << 123 104 124 // define physics 105 // define physics 125 runManager->SetUserInitialization(phys); 106 runManager->SetUserInitialization(phys); 126 runManager->SetUserAction(new PrimaryGenerat 107 runManager->SetUserAction(new PrimaryGeneratorAction()); 127 108 128 // set user action classes << 109 //set user action classes 129 runManager->SetUserAction(new RunAction()); 110 runManager->SetUserAction(new RunAction()); 130 runManager->SetUserAction(new EventAction()) 111 runManager->SetUserAction(new EventAction()); 131 runManager->SetUserAction(new StackingAction 112 runManager->SetUserAction(new StackingAction()); 132 113 133 // initialize visualization << 114 //initialize visualization 134 G4VisManager* visManager = nullptr; 115 G4VisManager* visManager = nullptr; 135 116 136 // get the pointer to the User Interface man << 117 //get the pointer to the User Interface manager 137 G4UImanager* UImanager = G4UImanager::GetUIp 118 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 138 119 139 if (ui) { << 120 if (ui) { 140 // interactive mode << 121 //interactive mode 141 visManager = new G4VisExecutive; 122 visManager = new G4VisExecutive; 142 visManager->Initialize(); 123 visManager->Initialize(); 143 ui->SessionStart(); 124 ui->SessionStart(); 144 delete ui; 125 delete ui; 145 } << 126 } else { 146 else { << 127 //batch mode 147 // batch mode << 148 G4String command = "/control/execute "; 128 G4String command = "/control/execute "; 149 G4String fileName = argv[1]; 129 G4String fileName = argv[1]; 150 UImanager->ApplyCommand(command + fileName << 130 UImanager->ApplyCommand(command+fileName); 151 } 131 } 152 132 153 // job termination << 133 //job termination >> 134 delete mess; 154 delete visManager; 135 delete visManager; 155 delete runManager; 136 delete runManager; 156 } 137 } 157 138 158 //....oooOO0OOooo........oooOO0OOooo........oo 139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 159 140