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 // << 27 /// \file field/field03/field03.cc 26 /// \file field/field03/field03.cc 28 /// \brief Main program of the field/field03 e 27 /// \brief Main program of the field/field03 example 29 // 28 // 30 //....oooOO0OOooo........oooOO0OOooo........oo << 29 // $Id$ 31 //....oooOO0OOooo........oooOO0OOooo........oo << 30 // 32 << 33 #include "G4Types.hh" << 34 31 35 #include "G4RunManagerFactory.hh" << 32 #include "G4RunManager.hh" 36 #include "F03SteppingVerbose.hh" << 33 #include "G4UImanager.hh" >> 34 #include "Randomize.hh" 37 35 38 #include "F03ActionInitialization.hh" << 39 #include "F03DetectorConstruction.hh" 36 #include "F03DetectorConstruction.hh" 40 #include "FTFP_BERT.hh" << 37 #include "F03PhysicsList.hh" >> 38 #include "F03PrimaryGeneratorAction.hh" >> 39 #include "F03RunAction.hh" >> 40 #include "F03EventAction.hh" >> 41 #include "F03SteppingVerbose.hh" 41 42 42 #include "G4StepLimiterPhysics.hh" << 43 #include "G4RunManager.hh" 43 #include "G4UIExecutive.hh" << 44 #include "G4UImanager.hh" 44 #include "G4UImanager.hh" >> 45 #include "Randomize.hh" >> 46 >> 47 #ifdef G4VIS_USE 45 #include "G4VisExecutive.hh" 48 #include "G4VisExecutive.hh" >> 49 #endif 46 50 47 //....oooOO0OOooo........oooOO0OOooo........oo << 51 #ifdef G4UI_USE >> 52 #include "G4UIExecutive.hh" >> 53 #endif 48 54 49 int main(int argc, char** argv) << 55 int main(int argc,char** argv) 50 { 56 { 51 // Instantiate G4UIExecutive if there are no << 52 // << 53 G4UIExecutive* ui = nullptr; << 54 if (argc == 1) { << 55 ui = new G4UIExecutive(argc, argv); << 56 } << 57 << 58 // Setting the application-specific Stepping << 59 // << 60 auto verbosity = new F03SteppingVerbose; << 61 57 >> 58 //choose the Random engine >> 59 >> 60 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); >> 61 >> 62 //my Verbose output class >> 63 >> 64 G4VSteppingVerbose::SetInstance(new F03SteppingVerbose); >> 65 62 // Construct the default run manager 66 // Construct the default run manager 63 // << 67 64 auto runManager = G4RunManagerFactory::Creat << 68 G4RunManager * runManager = new G4RunManager; 65 69 66 // Set mandatory initialization classes 70 // Set mandatory initialization classes 67 // << 71 68 // Detector construction << 72 F03DetectorConstruction* detector; 69 auto detector = new F03DetectorConstruction( << 73 detector = new F03DetectorConstruction; 70 runManager->SetUserInitialization(detector); 74 runManager->SetUserInitialization(detector); 71 // Physics list << 75 runManager->SetUserInitialization(new F03PhysicsList(detector)); 72 G4VModularPhysicsList* physicsList = new FTF << 76 73 physicsList->RegisterPhysics(new G4StepLimit << 77 // Set user action classes 74 runManager->SetUserInitialization(physicsLis << 78 75 // User action initialization << 79 runManager->SetUserAction(new F03PrimaryGeneratorAction(detector)); 76 runManager->SetUserInitialization(new F03Act << 80 >> 81 F03RunAction* runAction = new F03RunAction; >> 82 >> 83 runManager->SetUserAction(runAction); >> 84 >> 85 F03EventAction* eventAction = new F03EventAction(runAction); >> 86 >> 87 runManager->SetUserAction(eventAction); >> 88 >> 89 // Initialize G4 kernel, physics tables ... 77 90 78 // Initialize G4 kernel << 79 // << 80 runManager->Initialize(); 91 runManager->Initialize(); >> 92 >> 93 #ifdef G4VIS_USE >> 94 >> 95 // visualization manager 81 96 82 // Initialize visualization << 83 // << 84 G4VisManager* visManager = new G4VisExecutiv 97 G4VisManager* visManager = new G4VisExecutive; 85 // G4VisExecutive can take a verbosity argum << 86 // G4VisManager* visManager = new G4VisExecu << 87 visManager->Initialize(); 98 visManager->Initialize(); 88 99 89 // Get the pointer to the User Interface man << 100 #endif 90 // << 101 91 G4UImanager* UImanager = G4UImanager::GetUIp << 102 // Get the pointer to the User Interface manager 92 << 103 93 if (!ui) // batch mode << 104 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 94 { << 105 95 G4String command = "/control/execute "; << 106 if (argc!=1) // batch mode 96 G4String fileName = argv[1]; << 107 { 97 UImanager->ApplyCommand(command + fileName << 108 G4String command = "/control/execute "; 98 } << 109 G4String fileName = argv[1]; 99 else { << 110 UImanager->ApplyCommand(command+fileName); 100 UImanager->ApplyCommand("/control/execute << 111 } 101 if (ui->IsGUI()) UImanager->ApplyCommand(" << 112 else 102 ui->SessionStart(); << 113 { // interactive mode : define UI session 103 delete ui; << 114 #ifdef G4UI_USE 104 } << 115 G4UIExecutive* ui = new G4UIExecutive(argc, argv); 105 << 116 ui->SessionStart(); 106 // Job termination << 117 delete ui; 107 // Free the store: user actions, physics_lis << 118 #endif 108 // owned and deleted by the << 119 } 109 // be deleted in the main() << 110 120 111 delete verbosity; << 121 // job termination >> 122 >> 123 #ifdef G4VIS_USE 112 delete visManager; 124 delete visManager; >> 125 #endif 113 delete runManager; 126 delete runManager; 114 127 115 return 0; 128 return 0; 116 } 129 } 117 << 118 //....oooOO0OOooo........oooOO0OOooo........oo << 119 130