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 // (adapted from exampleB1) 26 // (adapted from exampleB1) 27 // Author: A.Knaian (ara@nklabs.com), N.MacFad 27 // Author: A.Knaian (ara@nklabs.com), N.MacFadden (natemacfadden@gmail.com) 28 28 29 29 30 #include "G4MTRunManager.hh" 30 #include "G4MTRunManager.hh" 31 #include "G4RunManagerFactory.hh" 31 #include "G4RunManagerFactory.hh" 32 32 33 #include "G4UImanager.hh" 33 #include "G4UImanager.hh" 34 #include "G4ScoringManager.hh" 34 #include "G4ScoringManager.hh" 35 35 36 #include "G4VisExecutive.hh" 36 #include "G4VisExecutive.hh" 37 #include "G4UIExecutive.hh" 37 #include "G4UIExecutive.hh" 38 38 39 #include "Randomize.hh" 39 #include "Randomize.hh" 40 40 41 #include "QGSP_BIC.hh" 41 #include "QGSP_BIC.hh" 42 #include "G4StepLimiterPhysics.hh" 42 #include "G4StepLimiterPhysics.hh" 43 43 44 #include "FADetectorConstruction.hh" 44 #include "FADetectorConstruction.hh" 45 #include "FAActionInitialization.hh" 45 #include "FAActionInitialization.hh" 46 46 47 int main(int argc,char** argv) 47 int main(int argc,char** argv) 48 { 48 { 49 // Construct the default run manager 49 // Construct the default run manager 50 auto* runManager = G4RunManagerFactory::Crea 50 auto* runManager = G4RunManagerFactory::CreateRunManager(); 51 G4int nThreads = 4; 51 G4int nThreads = 4; 52 runManager->SetNumberOfThreads(nThreads); 52 runManager->SetNumberOfThreads(nThreads); 53 53 54 // Set mandatory initialization classes << 54 // Detect interactive mode (if no arguments) and define UI session 55 // << 55 // 56 //G4ScoringManager* scoringManager = << 56 G4UIExecutive* ui = 0; 57 G4ScoringManager::GetScoringManager(); << 57 if ( argc == 1 ) { 58 << 58 ui = new G4UIExecutive(argc, argv); 59 // Detector construction initialization << 59 } 60 runManager->SetUserInitialization(new Detector << 60 61 << 61 // Choose the random engine 62 // Physics list << 62 // 63 G4VModularPhysicsList* physicsList = new QGSP_ << 63 CLHEP::RanecuEngine* randomEngine = new CLHEP::RanecuEngine; 64 physicsList->SetVerboseLevel(1); << 64 G4Random::setTheEngine(randomEngine); 65 << 65 66 // Physics list - step limiter << 66 // Set mandatory initialization classes 67 auto* stepLimiter = new G4StepLimiterPhysics; << 67 // 68 stepLimiter->SetApplyToAll(true); // apply ste << 68 //G4ScoringManager* scoringManager = >> 69 G4ScoringManager::GetScoringManager(); >> 70 >> 71 // Detector construction initialization >> 72 runManager->SetUserInitialization(new DetectorConstruction()); >> 73 >> 74 // Physics list >> 75 G4VModularPhysicsList* physicsList = new QGSP_BIC; >> 76 physicsList->SetVerboseLevel(1); >> 77 >> 78 // Physics list - step limiter >> 79 G4StepLimiterPhysics* stepLimiter = new G4StepLimiterPhysics; >> 80 stepLimiter->SetApplyToAll(true); // apply step limit to all particles. Default we set limit to DBL_MAX >> 81 physicsList->RegisterPhysics(stepLimiter); 69 82 70 physicsList->RegisterPhysics(stepLimiter); << 83 // Physics list initialization 71 << 84 runManager->SetUserInitialization(physicsList); 72 // Physics list initialization << 73 runManager->SetUserInitialization(physicsList) << 74 85 75 // User action initialization << 86 // User action initialization 76 runManager->SetUserInitialization(new ActionIn << 87 runManager->SetUserInitialization(new ActionInitialization()); 77 88 78 // Initialize visualization << 89 // Initialize visualization 79 // << 90 // 80 auto* visManager = new G4VisExecutive; << 91 G4VisManager* visManager = new G4VisExecutive; 81 visManager->Initialize(); << 92 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance. 82 << 93 // G4VisManager* visManager = new G4VisExecutive("Quiet"); 83 // Get the pointer to the User Interface manag << 94 visManager->Initialize(); 84 auto* UImanager = G4UImanager::GetUIpointer(); << 95 85 // Detect interactive mode (if no arguments) a << 96 // Get the pointer to the User Interface manager 86 // << 97 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 87 G4UIExecutive* ui = nullptr; << 98 88 if ( argc == 1 ) ui = new G4UIExecutive(argc, << 99 // Process macro or start UI session 89 // Process macro or start UI session << 100 // 90 // << 101 if ( ! ui ) { 91 if ( ! ui ) << 102 // batch mode 92 { << 103 G4String command = "/control/execute "; 93 // batch mode << 104 G4String fileName = argv[1]; 94 G4String command = "/control/execute "; << 105 UImanager->ApplyCommand(command+fileName); 95 G4String fileName = argv[1]; << 106 } 96 UImanager->ApplyCommand(command+fileName); << 107 else { 97 } << 108 // interactive mode 98 else << 109 UImanager->ApplyCommand("/control/execute init_vis.mac"); 99 { << 110 ui->SessionStart(); 100 // interactive mode << 111 delete ui; 101 UImanager->ApplyCommand("/control/execute in << 112 } 102 ui->SessionStart(); << 113 103 delete ui; << 114 // Job termination 104 } << 115 // Free the store: user actions, physics_list and detector_description are 105 << 116 // owned and deleted by the run manager, so they should not be deleted 106 // Job termination << 117 // in the main() program ! 107 // Free the store: user actions, physics_list << 108 // owned and deleted by the run manager, so th << 109 // in the main() program ! << 110 118 111 delete visManager; << 119 delete randomEngine; 112 delete runManager; << 120 delete visManager; 113 return 0; << 121 delete runManager; >> 122 //delete scoringManager; 114 } 123 } 115 124 116 125