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