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 persistency/P03/textGeom.cc 27 /// \file persistency/P03/textGeom.cc 28 /// \brief Main program of the persistency/P03 28 /// \brief Main program of the persistency/P03 example 29 // 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 31 32 #include "ExTGActionInitialization.hh" << 32 #include "G4Types.hh" >> 33 33 #include "ExTGDetectorConstruction.hh" 34 #include "ExTGDetectorConstruction.hh" >> 35 #include "ExTGDetectorConstructionWithSD.hh" 34 #include "ExTGDetectorConstructionWithCpp.hh" 36 #include "ExTGDetectorConstructionWithCpp.hh" 35 #include "ExTGDetectorConstructionWithCuts.hh" 37 #include "ExTGDetectorConstructionWithCuts.hh" 36 #include "ExTGDetectorConstructionWithSD.hh" << 38 #include "G4GenericPhysicsList.hh" 37 #include "ExTGPrimaryGeneratorAction.hh" 39 #include "ExTGPrimaryGeneratorAction.hh" >> 40 #include "ExTGActionInitialization.hh" >> 41 >> 42 #ifdef G4MULTITHREADED >> 43 #include "G4MTRunManager.hh" >> 44 #else >> 45 #include "G4RunManager.hh" >> 46 #endif 38 47 39 #include "G4GenericPhysicsList.hh" << 40 #include "G4RunManagerFactory.hh" << 41 #include "G4Types.hh" << 42 #include "G4UIExecutive.hh" << 43 #include "G4UImanager.hh" 48 #include "G4UImanager.hh" >> 49 44 #include "G4VisExecutive.hh" 50 #include "G4VisExecutive.hh" >> 51 #include "G4UIExecutive.hh" 45 52 46 //....oooOO0OOooo........oooOO0OOooo........oo 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 54 48 int main(int argc, char** argv) << 55 int main(int argc,char** argv) 49 { 56 { 50 // Instantiate G4UIExecutive if interactive 57 // Instantiate G4UIExecutive if interactive mode 51 G4UIExecutive* ui = nullptr; 58 G4UIExecutive* ui = nullptr; 52 if (argc == 1) { << 59 if ( argc == 1 ) { 53 ui = new G4UIExecutive(argc, argv); 60 ui = new G4UIExecutive(argc, argv); 54 } 61 } 55 62 56 // Run manager 63 // Run manager 57 // 64 // 58 auto* runManager = G4RunManagerFactory::Crea << 65 #ifdef G4MULTITHREADED >> 66 G4MTRunManager* runManager = new G4MTRunManager; 59 runManager->SetNumberOfThreads(1); 67 runManager->SetNumberOfThreads(1); >> 68 #else >> 69 G4RunManager* runManager = new G4RunManager; >> 70 #endif 60 71 61 // User Initialization classes (mandatory) 72 // User Initialization classes (mandatory) 62 // 73 // 63 runManager->SetUserInitialization(new ExTGDe 74 runManager->SetUserInitialization(new ExTGDetectorConstruction); 64 75 65 // 76 // 66 std::vector<G4String>* MyConstr = new std::v 77 std::vector<G4String>* MyConstr = new std::vector<G4String>; 67 MyConstr->push_back("G4EmStandardPhysics"); 78 MyConstr->push_back("G4EmStandardPhysics"); 68 G4VModularPhysicsList* phys = new G4GenericP 79 G4VModularPhysicsList* phys = new G4GenericPhysicsList(MyConstr); 69 runManager->SetUserInitialization(phys); 80 runManager->SetUserInitialization(phys); 70 81 71 // User Action classes 82 // User Action classes 72 // 83 // 73 // MT runManager->SetUserAction(new ExTGPri << 84 //MT runManager->SetUserAction(new ExTGPrimaryGeneratorAction); 74 85 75 runManager->SetUserInitialization(new ExTGAc 86 runManager->SetUserInitialization(new ExTGActionInitialization); 76 << 87 77 // Run action that dumps GEANT4 in-memory ge 88 // Run action that dumps GEANT4 in-memory geometry to text file 78 // MT runManager->SetUserAction(new ExTGRun << 89 //MT runManager->SetUserAction(new ExTGRunAction); 79 90 80 // Initialize G4 kernel 91 // Initialize G4 kernel 81 // 92 // 82 // runManager->Initialize(); 93 // runManager->Initialize(); 83 << 94 84 // Get the pointer to the User Interface man 95 // Get the pointer to the User Interface manager 85 // 96 // 86 G4UImanager* UImanager = G4UImanager::GetUIp << 97 G4UImanager * UImanager = G4UImanager::GetUIpointer(); 87 98 88 if (!ui) // batch mode << 99 G4VisManager* visManager = new G4VisExecutive; 89 { << 100 visManager->Initialize(); 90 G4String command = "/control/execute "; << 101 91 G4String fileName = argv[1]; << 102 if (!ui) // batch mode 92 UImanager->ApplyCommand(command + fileName << 103 { 93 } << 104 G4String command = "/control/execute "; 94 else // interactive mode : define visualiza << 105 G4String fileName = argv[1]; 95 { << 106 UImanager->ApplyCommand(command+fileName); 96 G4VisManager* visManager = new G4VisExecut << 107 } 97 visManager->Initialize(); << 108 else // interactive mode : define visualization and UI terminal 98 << 109 { 99 UImanager->ApplyCommand("/control/execute << 110 UImanager->ApplyCommand("/control/execute run.mac"); 100 ui->SessionStart(); << 111 ui->SessionStart(); 101 delete ui; << 112 delete ui; 102 delete visManager; << 113 } 103 } << 104 114 105 // Free the store: user actions, physics_lis 115 // Free the store: user actions, physics_list and detector_description are 106 // owned and deleted by the 116 // owned and deleted by the run manager, so they should not 107 // be deleted in the main() 117 // be deleted in the main() program ! 108 118 >> 119 delete visManager; 109 delete runManager; 120 delete runManager; 110 121 111 return 0; 122 return 0; 112 } 123 } 113 124 114 //....oooOO0OOooo........oooOO0OOooo........oo 125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 126 115 127