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 /// \file rdecay02.cc 26 /// \file rdecay02.cc 27 /// \brief Main program of the radioactivedeca 27 /// \brief Main program of the radioactivedecay/rdecay02 example 28 // 28 // 29 // 29 // 30 // 30 // 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 33 34 #include "ActionInitialization.hh" << 34 #include "G4Types.hh" >> 35 >> 36 #ifdef G4MULTITHREADED >> 37 #include "G4MTRunManager.hh" >> 38 #else >> 39 #include "G4RunManager.hh" >> 40 #endif >> 41 >> 42 #include "G4UImanager.hh" >> 43 #include "Randomize.hh" >> 44 35 #include "DetectorConstruction.hh" 45 #include "DetectorConstruction.hh" 36 #include "PhysicsList.hh" 46 #include "PhysicsList.hh" >> 47 #include "ActionInitialization.hh" >> 48 #include "SteppingVerbose.hh" 37 49 38 #include "G4RunManagerFactory.hh" << 39 #include "G4SteppingVerbose.hh" << 40 #include "G4Types.hh" << 41 #include "G4UIExecutive.hh" 50 #include "G4UIExecutive.hh" 42 #include "G4UImanager.hh" << 43 #include "G4VisExecutive.hh" 51 #include "G4VisExecutive.hh" 44 #include "Randomize.hh" << 45 52 46 //....oooOO0OOooo........oooOO0OOooo........oo 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 54 48 int main(int argc, char** argv) << 55 int main(int argc,char** argv) { 49 { << 56 50 // detect interactive mode (if no arguments) << 57 //detect interactive mode (if no arguments) and define UI session 51 G4UIExecutive* ui = 0; 58 G4UIExecutive* ui = 0; 52 if (argc == 1) ui = new G4UIExecutive(argc, << 59 if (argc == 1) ui = new G4UIExecutive(argc,argv); 53 60 54 // choose the Random engine << 61 //choose the Random engine 55 G4Random::setTheEngine(new CLHEP::RanecuEngi 62 G4Random::setTheEngine(new CLHEP::RanecuEngine); 56 63 57 // use G4SteppingVerboseWithUnits << 64 // Construct the default run manager 58 G4int precision = 4; << 65 #ifdef G4MULTITHREADED 59 G4SteppingVerbose::UseBestUnit(precision); << 66 G4MTRunManager* runManager = new G4MTRunManager; 60 << 67 G4int nThreads = G4Threading::G4GetNumberOfCores(); 61 // construct the run manager << 68 if (argc==3) nThreads = G4UIcommand::ConvertToInt(argv[2]); 62 auto runManager = G4RunManagerFactory::Creat << 69 runManager->SetNumberOfThreads(nThreads); 63 if (argc == 3) { << 70 #else 64 G4int nThreads = G4UIcommand::ConvertToInt << 71 //my Verbose output class 65 runManager->SetNumberOfThreads(nThreads); << 72 G4VSteppingVerbose::SetInstance(new SteppingVerbose); 66 } << 73 G4RunManager* runManager = new G4RunManager; 67 // set mandatory initialization classes << 74 #endif 68 DetectorConstruction* det = new DetectorCons << 75 >> 76 //set mandatory initialization classes >> 77 DetectorConstruction* det= new DetectorConstruction; 69 runManager->SetUserInitialization(det); 78 runManager->SetUserInitialization(det); 70 79 71 PhysicsList* phys = new PhysicsList; 80 PhysicsList* phys = new PhysicsList; 72 runManager->SetUserInitialization(phys); 81 runManager->SetUserInitialization(phys); 73 82 74 runManager->SetUserInitialization(new Action 83 runManager->SetUserInitialization(new ActionInitialization(det)); 75 84 76 // initialize visualization << 85 //initialize visualization 77 G4VisManager* visManager = nullptr; 86 G4VisManager* visManager = nullptr; 78 87 79 // get the pointer to the User Interface man 88 // get the pointer to the User Interface manager 80 G4UImanager* UImanager = G4UImanager::GetUIp 89 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 81 90 82 if (ui) { << 91 if (ui) { 83 // interactive mode << 92 //interactive mode 84 visManager = new G4VisExecutive; << 93 visManager = new G4VisExecutive; 85 visManager->Initialize(); << 94 visManager->Initialize(); 86 ui->SessionStart(); << 95 ui->SessionStart(); 87 delete ui; << 96 delete ui; 88 } 97 } 89 else { << 98 else { 90 // batch mode << 99 //batch mode 91 G4String command = "/control/execute "; << 100 G4String command = "/control/execute "; 92 G4String fileName = argv[1]; << 101 G4String fileName = argv[1]; 93 UImanager->ApplyCommand(command + fileName << 102 UImanager->ApplyCommand(command+fileName); 94 } 103 } 95 104 96 // job termination << 105 //job termination 97 delete visManager; 106 delete visManager; 98 delete runManager; 107 delete runManager; 99 } 108 } 100 109 101 //....oooOO0OOooo........oooOO0OOooo........oo 110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 102 111