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 persistency/P02/exampleP02.cc 26 /// \file persistency/P02/exampleP02.cc 27 /// \brief Main program of the persistency/P02 27 /// \brief Main program of the persistency/P02 example 28 // 28 // 29 // 29 // >> 30 // $Id: exampleP02.cc 82291 2014-06-13 15:20:32Z 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 "ExP02DetConstrReader.hh" << 36 #include "ExP02DetectorConstruction.hh" 36 #include "ExP02DetectorConstruction.hh" >> 37 #include "ExP02DetConstrReader.hh" 37 #include "ExP02PrimaryGeneratorAction.hh" 38 #include "ExP02PrimaryGeneratorAction.hh" >> 39 38 #include "FTFP_BERT.hh" 40 #include "FTFP_BERT.hh" 39 41 40 #include "G4RunManagerFactory.hh" << 42 41 #include "G4Types.hh" << 43 #include "G4RunManager.hh" 42 #include "G4UIExecutive.hh" << 43 #include "G4UImanager.hh" 44 #include "G4UImanager.hh" >> 45 >> 46 #ifdef G4VIS_USE 44 #include "G4VisExecutive.hh" 47 #include "G4VisExecutive.hh" >> 48 #endif >> 49 >> 50 #ifdef G4UI_USE >> 51 #include "G4UIExecutive.hh" >> 52 #endif 45 53 46 //....oooOO0OOooo........oooOO0OOooo........oo 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 55 48 int main(int argc, char** argv) 56 int main(int argc, char** argv) 49 { << 57 { 50 if (argc == 1) { << 58 >> 59 if(argc==1) >> 60 { 51 G4cout << "Please give 'write' or 'read' a 61 G4cout << "Please give 'write' or 'read' as argument " << G4endl; 52 return 0; 62 return 0; 53 } 63 } 54 64 55 G4VUserDetectorConstruction* det; 65 G4VUserDetectorConstruction* det; 56 66 57 if (std::string(argv[1]) == "read") { << 67 if(std::string(argv[1]) == "read") 58 det = new ExP02DetConstrReader; << 68 { 59 } << 69 det = new ExP02DetConstrReader; 60 else if (std::string(argv[1]) == "write") { << 70 } >> 71 else if(std::string(argv[1]) == "write") >> 72 { 61 det = new ExP02DetectorConstruction; 73 det = new ExP02DetectorConstruction; 62 } 74 } 63 else { << 75 else >> 76 { 64 G4cout << "Wrong argument!" << G4endl; 77 G4cout << "Wrong argument!" << G4endl; 65 return 0; 78 return 0; 66 } 79 } 67 80 68 // User interface << 69 G4UIExecutive* ui = new G4UIExecutive(argc, << 70 << 71 // Run manager 81 // Run manager 72 auto* runManager = G4RunManagerFactory::Crea << 82 G4RunManager * runManager = new G4RunManager; 73 83 74 // UserInitialization classes (mandatory) 84 // UserInitialization classes (mandatory) 75 runManager->SetUserInitialization(det); 85 runManager->SetUserInitialization(det); 76 86 77 G4VModularPhysicsList* physicsList = new FTF 87 G4VModularPhysicsList* physicsList = new FTFP_BERT; 78 runManager->SetUserInitialization(physicsLis 88 runManager->SetUserInitialization(physicsList); 79 << 89 80 // Visualization << 90 #ifdef G4VIS_USE >> 91 // Visualization, if you choose to have it! 81 G4VisManager* visManager = new G4VisExecutiv 92 G4VisManager* visManager = new G4VisExecutive; 82 visManager->Initialize(); 93 visManager->Initialize(); 83 << 94 #endif >> 95 84 // UserAction classes 96 // UserAction classes 85 runManager->SetUserAction(new ExP02PrimaryGe 97 runManager->SetUserAction(new ExP02PrimaryGeneratorAction()); 86 98 87 // Initialize G4 kernel << 99 //Initialize G4 kernel 88 runManager->Initialize(); 100 runManager->Initialize(); >> 101 >> 102 //get the pointer to the User Interface manager >> 103 G4UImanager * UImanager = G4UImanager::GetUIpointer(); >> 104 >> 105 #ifdef G4UI_USE >> 106 G4UIExecutive* ui = new G4UIExecutive(argc, argv); >> 107 #ifdef G4VIS_USE >> 108 UImanager->ApplyCommand("/control/execute vis.mac"); >> 109 #endif >> 110 ui->SessionStart(); >> 111 delete ui; >> 112 #endif 89 113 90 // get the pointer to the User Interface man << 114 #ifdef G4VIS_USE 91 G4UImanager* UImanager = G4UImanager::GetUIp << 92 << 93 UImanager->ApplyCommand("/control/execute vi << 94 ui->SessionStart(); << 95 delete ui; << 96 << 97 delete visManager; 115 delete visManager; >> 116 #endif 98 delete runManager; 117 delete runManager; 99 118 100 return 0; 119 return 0; 101 } 120 } 102 121 103 //....oooOO0OOooo........oooOO0OOooo........oo 122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 123 104 124