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 // 26 // 27 // 27 // 28 //....oooOO0OOooo........oooOO0OOooo........oo 28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 29 29 30 #include "SAXSActionInitialization.hh" << 30 #include "G4RunManagerFactory.hh" >> 31 >> 32 #include "G4UImanager.hh" >> 33 31 #include "SAXSDetectorConstruction.hh" 34 #include "SAXSDetectorConstruction.hh" 32 #include "SAXSEventAction.hh" << 33 #include "SAXSPhysicsList.hh" 35 #include "SAXSPhysicsList.hh" >> 36 #include "SAXSActionInitialization.hh" 34 #include "SAXSRunAction.hh" 37 #include "SAXSRunAction.hh" >> 38 #include "SAXSEventAction.hh" 35 #include "SAXSSteppingAction.hh" 39 #include "SAXSSteppingAction.hh" 36 40 37 #include "G4RunManagerFactory.hh" << 38 #include "G4Timer.hh" << 39 #include "G4UIExecutive.hh" << 40 #include "G4UImanager.hh" << 41 #include "G4VisExecutive.hh" 41 #include "G4VisExecutive.hh" 42 #include "Randomize.hh" << 42 #include "G4UIExecutive.hh" >> 43 #include "G4Timer.hh" 43 44 >> 45 #include "Randomize.hh" 44 #include <time.h> 46 #include <time.h> 45 47 46 //....oooOO0OOooo........oooOO0OOooo........oo 48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 49 48 int main(int argc, char** argv) << 50 int main(int argc,char** argv) 49 { 51 { >> 52 50 G4Timer* theTimer = new G4Timer(); 53 G4Timer* theTimer = new G4Timer(); 51 theTimer->Start(); 54 theTimer->Start(); 52 55 53 // Choose the Random engine and reset the se << 56 //Choose the Random engine and reset the seed (before the RunManager) 54 /* 57 /* 55 G4int seed = time(0); 58 G4int seed = time(0); 56 G4cout << "Random seed: " << seed << G4end 59 G4cout << "Random seed: " << seed << G4endl; 57 CLHEP::HepRandom::setTheSeed(seed); 60 CLHEP::HepRandom::setTheSeed(seed); 58 */ 61 */ 59 // Construct the run manager << 62 //Construct the run manager 60 auto* runManager = G4RunManagerFactory::Crea 63 auto* runManager = G4RunManagerFactory::CreateRunManager(); 61 int vNumberOfThreads = 2; 64 int vNumberOfThreads = 2; 62 if (argc > 2) { << 65 if (argc>2) { 63 vNumberOfThreads = atoi(argv[2]); 66 vNumberOfThreads = atoi(argv[2]); 64 } 67 } 65 if (vNumberOfThreads > 0) { 68 if (vNumberOfThreads > 0) { 66 runManager->SetNumberOfThreads(vNumberOfTh 69 runManager->SetNumberOfThreads(vNumberOfThreads); 67 } 70 } 68 71 69 // Set mandatory initialization classes << 72 //Set mandatory initialization classes 70 runManager->SetUserInitialization(new SAXSDe 73 runManager->SetUserInitialization(new SAXSDetectorConstruction); 71 runManager->SetUserInitialization(new SAXSPh 74 runManager->SetUserInitialization(new SAXSPhysicsList()); 72 75 73 // Set user action classes << 76 //Set user action classes 74 runManager->SetUserInitialization(new SAXSAc 77 runManager->SetUserInitialization(new SAXSActionInitialization()); 75 << 78 76 // Get the pointer to the User Interface man << 79 //Get the pointer to the User Interface manager 77 G4UImanager* UImanager = G4UImanager::GetUIp 80 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 78 81 79 // No arguments: set the batch mode << 82 //No arguments: set the batch mode 80 if (argc != 1) { << 83 if (argc!=1) { 81 // Batch mode << 84 //Batch mode 82 G4String command = "/control/execute "; 85 G4String command = "/control/execute "; 83 G4String fileName = argv[1]; 86 G4String fileName = argv[1]; 84 UImanager->ApplyCommand(command + fileName << 87 UImanager->ApplyCommand(command+fileName); 85 } << 88 } else { 86 else { << 89 //Visualization manager 87 // Visualization manager << 88 G4VisManager* visManager = new G4VisExecut 90 G4VisManager* visManager = new G4VisExecutive; 89 visManager->Initialize(); 91 visManager->Initialize(); 90 92 91 // Define UI session for interactive mode << 93 //Define UI session for interactive mode 92 G4UIExecutive* ui = new G4UIExecutive(argc << 94 G4UIExecutive* ui = new G4UIExecutive(argc,argv); 93 UImanager->ApplyCommand("/control/execute 95 UImanager->ApplyCommand("/control/execute init_vis.mac"); 94 if (ui->IsGUI()) UImanager->ApplyCommand(" << 96 if (ui->IsGUI()) >> 97 UImanager->ApplyCommand("/control/execute gui.mac"); 95 ui->SessionStart(); 98 ui->SessionStart(); 96 99 97 delete ui; 100 delete ui; 98 delete visManager; 101 delete visManager; 99 } 102 } 100 103 101 // Job termination << 104 //Job termination 102 delete runManager; 105 delete runManager; 103 106 104 theTimer->Stop(); 107 theTimer->Stop(); 105 G4cout << "Execution completed" << G4endl; 108 G4cout << "Execution completed" << G4endl; 106 G4cout << (*theTimer) << G4endl; 109 G4cout << (*theTimer) << G4endl; 107 delete theTimer; 110 delete theTimer; 108 111 109 return 0; 112 return 0; 110 } 113 } 111 114 112 //....oooOO0OOooo........oooOO0OOooo........oo 115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 116 113 117