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