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 // >> 27 // $Id$ >> 28 // >> 29 // 26 30 27 #include "eRositaActionInitialization.hh" << 28 #include "eRositaDetectorConstruction.hh" 31 #include "eRositaDetectorConstruction.hh" 29 #include "eRositaEventAction.hh" << 30 #include "eRositaPhysicsList.hh" 32 #include "eRositaPhysicsList.hh" 31 #include "eRositaPrimaryGeneratorAction.hh" 33 #include "eRositaPrimaryGeneratorAction.hh" 32 #include "eRositaRunAction.hh" 34 #include "eRositaRunAction.hh" >> 35 #include "eRositaEventAction.hh" 33 #include "eRositaSteppingAction.hh" 36 #include "eRositaSteppingAction.hh" 34 #include "eRositaSteppingVerbose.hh" 37 #include "eRositaSteppingVerbose.hh" 35 38 36 #include "G4RunManagerFactory.hh" << 39 #include "G4RunManager.hh" 37 #include "G4UIExecutive.hh" << 38 #include "G4UImanager.hh" 40 #include "G4UImanager.hh" >> 41 >> 42 #ifdef G4VIS_USE 39 #include "G4VisExecutive.hh" 43 #include "G4VisExecutive.hh" >> 44 #endif >> 45 >> 46 #ifdef G4UI_USE >> 47 #include "G4UIExecutive.hh" >> 48 #endif >> 49 40 50 41 auto main(int argumentCount, char** argumentVe << 51 int main(int argc,char** argv) 42 { 52 { 43 // User verbose output class << 53 // User Verbose output class 44 // << 54 // 45 auto *verbosity = new eRositaSteppingVerbo << 55 G4VSteppingVerbose* verbosity = new eRositaSteppingVerbose; 46 G4VSteppingVerbose::SetInstance(verbosity) << 56 G4VSteppingVerbose::SetInstance(verbosity); 47 << 57 48 // Run manager << 58 // Run manager 49 // << 59 // 50 auto *runManager = G4RunManagerFactory::Cr << 60 G4RunManager* runManager = new G4RunManager; 51 << 61 52 constexpr auto NUMBER_OF_THREADS{4}; << 62 // User Initialization classes (mandatory) 53 runManager->SetNumberOfThreads(NUMBER_OF_T << 63 // 54 << 64 eRositaDetectorConstruction* detector = new eRositaDetectorConstruction; 55 G4cout << "***********************" << G4e << 65 runManager->SetUserInitialization(detector); 56 G4cout << "** Seed: " << G4Random::getTheS << 66 // 57 G4cout << "***********************" << G4e << 67 G4VUserPhysicsList* physics = new eRositaPhysicsList; 58 << 68 runManager->SetUserInitialization(physics); 59 runManager->SetUserInitialization(new eRos << 69 60 runManager->SetUserInitialization(new eRos << 70 // User Action classes 61 runManager->SetUserInitialization(new eRos << 71 // 62 << 72 G4VUserPrimaryGeneratorAction* genAction = new eRositaPrimaryGeneratorAction(detector); 63 // Initialize GEANT4 kernel << 73 runManager->SetUserAction(genAction); 64 // << 74 // 65 runManager->Initialize(); << 75 G4UserRunAction* runAction = new eRositaRunAction; 66 << 76 runManager->SetUserAction(runAction); 67 // Get the pointer to the User Interface ( << 77 // 68 // << 78 G4UserEventAction* eventAction = new eRositaEventAction; 69 auto *userInterfaceManager = G4UImanager:: << 79 runManager->SetUserAction(eventAction); 70 << 80 // 71 if (argumentCount != 1) { // batch mode << 81 G4UserSteppingAction* steppingAction = new eRositaSteppingAction; 72 G4String command = "/control/execute " << 82 runManager->SetUserAction(steppingAction); 73 G4String fileName = argumentVector[1]; << 83 74 userInterfaceManager->ApplyCommand(com << 84 // Initialize G4 kernel 75 } else { // interactive mode : define visu << 85 // 76 auto *visualizationManager = new G4Vis << 86 runManager->Initialize(); 77 visualizationManager->Initialize(); << 87 78 << 88 // Get the pointer to the User Interface manager 79 auto *userInterface = new G4UIExecutiv << 89 // 80 userInterfaceManager->ApplyCommand("/c << 90 G4UImanager * UImanager = G4UImanager::GetUIpointer(); 81 userInterface->SessionStart(); << 91 82 << 92 if (argc!=1) // batch mode 83 delete userInterface; << 93 { 84 delete visualizationManager; << 94 G4String command = "/control/execute "; >> 95 G4String fileName = argv[1]; >> 96 UImanager->ApplyCommand(command+fileName); >> 97 } >> 98 >> 99 else // interactive mode : define visualization and UI terminal >> 100 { >> 101 #ifdef G4VIS_USE >> 102 G4VisManager* visManager = new G4VisExecutive; >> 103 visManager->Initialize(); >> 104 #endif >> 105 >> 106 #ifdef G4UI_USE >> 107 G4UIExecutive* ui = new G4UIExecutive(argc, argv); >> 108 UImanager->ApplyCommand("/control/execute vis.mac"); >> 109 ui->SessionStart(); >> 110 delete ui; >> 111 #endif >> 112 >> 113 #ifdef G4VIS_USE >> 114 delete visManager; >> 115 #endif 85 } 116 } 86 117 87 // Free the store: << 118 // Free the store: user actions, physics_list and detector_description are 88 // user actions, physics list and detector << 119 // owned and deleted by the run manager, so they should not 89 // owned and deleted by the run manager, << 120 // be deleted in the main() program ! 90 // so they should not be deleted in the ma << 91 121 92 delete verbosity; << 122 delete runManager; 93 delete runManager; << 123 delete verbosity; 94 124 95 return 0; << 125 return 0; 96 } 126 } >> 127 >> 128 97 129