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