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