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 analysis/AnaEx02/AnaEx02.cc 26 /// \file analysis/AnaEx02/AnaEx02.cc 27 /// \brief Main program of the analysis/AnaEx0 27 /// \brief Main program of the analysis/AnaEx02 example 28 // 28 // 29 // 29 // >> 30 // $Id: AnaEx02.cc 68015 2013-03-13 13:27:27Z gcosmo $ 30 // 31 // 31 // 32 // 32 //....oooOO0OOooo........oooOO0OOooo........oo 33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 //....oooOO0OOooo........oooOO0OOooo........oo 34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 34 35 35 #include "ActionInitialization.hh" << 36 #include "G4RunManager.hh" >> 37 #include "G4UImanager.hh" >> 38 36 #include "DetectorConstruction.hh" 39 #include "DetectorConstruction.hh" 37 #include "EventAction.hh" << 40 #include "PhysicsList.hh" 38 #include "FTFP_BERT.hh" << 39 #include "HistoManager.hh" << 40 #include "PrimaryGeneratorAction.hh" 41 #include "PrimaryGeneratorAction.hh" 41 #include "RunAction.hh" 42 #include "RunAction.hh" >> 43 #include "EventAction.hh" 42 #include "SteppingAction.hh" 44 #include "SteppingAction.hh" >> 45 #include "HistoManager.hh" 43 46 44 #include "G4RunManagerFactory.hh" << 47 #ifdef G4VIS_USE 45 #include "G4UIExecutive.hh" << 46 #include "G4UImanager.hh" << 47 #include "G4VisExecutive.hh" 48 #include "G4VisExecutive.hh" >> 49 #endif 48 50 49 //....oooOO0OOooo........oooOO0OOooo........oo << 51 #ifdef G4UI_USE >> 52 #include "G4UIExecutive.hh" >> 53 #endif 50 54 51 int main(int argc, char** argv) << 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 52 { << 53 // Detect interactive mode (if no arguments) << 54 // << 55 G4UIExecutive* ui = nullptr; << 56 if (argc == 1) { << 57 ui = new G4UIExecutive(argc, argv); << 58 } << 59 56 60 // Construct a serial run manager << 57 int main(int argc,char** argv) >> 58 { >> 59 // Construct the default run manager 61 // 60 // 62 auto* runManager = G4RunManagerFactory::Crea << 61 G4RunManager * runManager = new G4RunManager; 63 62 64 // Set mandatory initialization classes 63 // Set mandatory initialization classes 65 // 64 // 66 auto detector = new DetectorConstruction; << 65 DetectorConstruction* detector = new DetectorConstruction; 67 runManager->SetUserInitialization(detector); 66 runManager->SetUserInitialization(detector); 68 runManager->SetUserInitialization(new FTFP_B << 69 runManager->SetUserInitialization(new Action << 70 << 71 // Initialize G4 kernel << 72 // 67 // 73 // runManager->Initialize(); << 68 PhysicsList* physics = new PhysicsList; 74 << 69 runManager->SetUserInitialization(physics); 75 // Initialize visualization << 70 >> 71 // set an HistoManager >> 72 // >> 73 HistoManager* histo = new HistoManager(); >> 74 >> 75 // Set user action classes >> 76 // >> 77 PrimaryGeneratorAction* gen_action = >> 78 new PrimaryGeneratorAction(detector); >> 79 runManager->SetUserAction(gen_action); >> 80 // >> 81 RunAction* run_action = new RunAction(histo); >> 82 runManager->SetUserAction(run_action); >> 83 // >> 84 EventAction* event_action = new EventAction(run_action,histo); >> 85 runManager->SetUserAction(event_action); >> 86 // >> 87 SteppingAction* stepping_action = >> 88 new SteppingAction(detector, event_action); >> 89 runManager->SetUserAction(stepping_action); >> 90 >> 91 // Initialize G4 kernel 76 // 92 // 77 G4VisManager* visManager = new G4VisExecutiv << 93 runManager->Initialize(); 78 visManager->Initialize(); << 79 94 80 // Get the pointer to the User Interface man 95 // Get the pointer to the User Interface manager 81 // 96 // 82 G4UImanager* UImanager = G4UImanager::GetUIp 97 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 83 << 98 84 if (ui == nullptr) { << 99 if (argc!=1) // batch mode 85 // batch mode << 100 { 86 G4String command = "/control/execute "; << 101 G4String command = "/control/execute "; 87 G4String fileName = argv[1]; << 102 G4String fileName = argv[1]; 88 UImanager->ApplyCommand(command + fileName << 103 UImanager->ApplyCommand(command+fileName); 89 } << 104 } 90 else { << 105 else 91 // interactive mode << 106 { // interactive mode : define visualization and UI terminal 92 UImanager->ApplyCommand("/control/execute << 107 #ifdef G4VIS_USE 93 ui->SessionStart(); << 108 G4VisManager* visManager = new G4VisExecutive; 94 delete ui; << 109 visManager->Initialize(); 95 } << 110 #ifdef G4UI_USE 96 << 111 G4UIExecutive* ui = new G4UIExecutive(argc, argv); >> 112 #endif >> 113 UImanager->ApplyCommand("/control/execute vis.mac"); >> 114 #endif >> 115 >> 116 #ifdef G4UI_USE >> 117 ui->SessionStart(); >> 118 delete ui; >> 119 #endif >> 120 >> 121 #ifdef G4VIS_USE >> 122 delete visManager; >> 123 #endif >> 124 } >> 125 97 // Job termination 126 // Job termination 98 delete visManager; << 127 delete histo; 99 delete runManager; 128 delete runManager; 100 129 101 return 0; 130 return 0; 102 } 131 } 103 132 104 //....oooOO0OOooo........oooOO0OOooo........oo 133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 105 134