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