Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 // 28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 29 30 #include "SAXSActionInitialization.hh" 31 #include "SAXSDetectorConstruction.hh" 32 #include "SAXSEventAction.hh" 33 #include "SAXSPhysicsList.hh" 34 #include "SAXSRunAction.hh" 35 #include "SAXSSteppingAction.hh" 36 37 #include "G4RunManagerFactory.hh" 38 #include "G4Timer.hh" 39 #include "G4UIExecutive.hh" 40 #include "G4UImanager.hh" 41 #include "G4VisExecutive.hh" 42 #include "Randomize.hh" 43 44 #include <time.h> 45 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 48 int main(int argc, char** argv) 49 { 50 G4Timer* theTimer = new G4Timer(); 51 theTimer->Start(); 52 53 // Choose the Random engine and reset the seed (before the RunManager) 54 /* 55 G4int seed = time(0); 56 G4cout << "Random seed: " << seed << G4endl; 57 CLHEP::HepRandom::setTheSeed(seed); 58 */ 59 // Construct the run manager 60 auto* runManager = G4RunManagerFactory::CreateRunManager(); 61 int vNumberOfThreads = 2; 62 if (argc > 2) { 63 vNumberOfThreads = atoi(argv[2]); 64 } 65 if (vNumberOfThreads > 0) { 66 runManager->SetNumberOfThreads(vNumberOfThreads); 67 } 68 69 // Set mandatory initialization classes 70 runManager->SetUserInitialization(new SAXSDetectorConstruction); 71 runManager->SetUserInitialization(new SAXSPhysicsList()); 72 73 // Set user action classes 74 runManager->SetUserInitialization(new SAXSActionInitialization()); 75 76 // Get the pointer to the User Interface manager 77 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 78 79 // No arguments: set the batch mode 80 if (argc != 1) { 81 // Batch mode 82 G4String command = "/control/execute "; 83 G4String fileName = argv[1]; 84 UImanager->ApplyCommand(command + fileName); 85 } 86 else { 87 // Visualization manager 88 G4VisManager* visManager = new G4VisExecutive; 89 visManager->Initialize(); 90 91 // Define UI session for interactive mode 92 G4UIExecutive* ui = new G4UIExecutive(argc, argv); 93 UImanager->ApplyCommand("/control/execute init_vis.mac"); 94 if (ui->IsGUI()) UImanager->ApplyCommand("/control/execute gui.mac"); 95 ui->SessionStart(); 96 97 delete ui; 98 delete visManager; 99 } 100 101 // Job termination 102 delete runManager; 103 104 theTimer->Stop(); 105 G4cout << "Execution completed" << G4endl; 106 G4cout << (*theTimer) << G4endl; 107 delete theTimer; 108 109 return 0; 110 } 111 112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 113