Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 /// \file field/field04/field04.cc 28 /// \brief Main program of the field/field04 e 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 33 #ifndef WIN32 34 # include <unistd.h> 35 #endif 36 37 #include "G4Types.hh" 38 39 #include "G4RunManagerFactory.hh" 40 #include "F04SteppingVerbose.hh" 41 42 #include "F04ActionInitialization.hh" 43 #include "F04DetectorConstruction.hh" 44 #include "F04PhysicsList.hh" 45 46 #include "G4UIExecutive.hh" 47 #include "G4UImanager.hh" 48 #include "G4VisExecutive.hh" 49 #include "Randomize.hh" 50 51 //....oooOO0OOooo........oooOO0OOooo........oo 52 53 namespace 54 { 55 void PrintUsage() 56 { 57 G4cerr << " Usage: " << G4endl; 58 G4cerr << " field04 [-m macro ] [-p physicsL 59 } 60 } // namespace 61 62 //....oooOO0OOooo........oooOO0OOooo........oo 63 64 int main(int argc, char** argv) 65 { 66 // Evaluate arguments 67 // argc holds the number of arguments (inclu 68 // -> it is ONE when only the name is given 69 // argv[0] is always the name of the program 70 // argv[1] points to the first argument, and 71 // 72 if (argc > 7) { 73 PrintUsage(); 74 return 1; 75 } 76 77 G4String macro; 78 G4String physicsList = "QGSP_BERT"; 79 G4int randomSeed = 1234; 80 G4String startPhase = "idle"; 81 for (G4int i = 1; i < argc; i = i + 2) { 82 if (G4String(argv[i]) == "-m") 83 macro = argv[i + 1]; 84 else if (G4String(argv[i]) == "-r") 85 randomSeed = atoi(argv[i + 1]); 86 else if (G4String(argv[i]) == "-p") 87 physicsList = argv[i + 1]; 88 else if (G4String(argv[i]) == "-s") 89 startPhase = argv[i + 1]; 90 else { 91 PrintUsage(); 92 return 1; 93 } 94 } 95 96 // Instantiate G4UIExecutive if there are no 97 // 98 G4UIExecutive* ui = nullptr; 99 if (!macro.size()) { 100 ui = new G4UIExecutive(argc, argv); 101 } 102 103 // Setting the application-specific Stepping 104 // 105 auto verbosity = new F04SteppingVerbose; 106 107 // Construct the default run manager 108 // 109 auto runManager = G4RunManagerFactory::Creat 110 111 G4Random::setTheSeed(randomSeed); 112 113 // Set mandatory initialization classes 114 // 115 // Detector construction 116 auto detector = new F04DetectorConstruction( 117 runManager->SetUserInitialization(detector); 118 // Physics list 119 runManager->SetUserInitialization(new F04Phy 120 // User action initialization 121 runManager->SetUserInitialization(new F04Act 122 123 // Initialize G4 kernel 124 // 125 // runManager->Initialize(); 126 127 // Initialize visualization 128 // 129 G4VisManager* visManager = new G4VisExecutiv 130 // G4VisExecutive can take a verbosity argum 131 // G4VisManager* visManager = new G4VisExecu 132 visManager->Initialize(); 133 134 // Get the pointer to the User Interface man 135 // 136 G4UImanager* UImanager = G4UImanager::GetUIp 137 138 // Process macro or start UI session 139 // 140 if (macro.size()) { 141 // batch mode 142 G4String command = "/control/execute "; 143 UImanager->ApplyCommand(command + macro); 144 } 145 else { 146 // interactive mode : define UI session 147 if (startPhase == "preinit") { 148 // start in PreInit> phase if requested 149 G4cout << "At the prompt, issue commands 150 G4cout << "/run/initialize" << G4endl; 151 G4cout << "Then if you want a viewer:" < 152 G4cout << "/control/execute vis.mac" << 153 G4cout << "Then: " << G4endl; 154 G4cout << "/run/beamOn … etc." << G4en 155 } 156 else { 157 // perform initialization and draw geome 158 UImanager->ApplyCommand("/control/execut 159 } 160 if (ui->IsGUI()) { 161 UImanager->ApplyCommand("/control/execut 162 } 163 ui->SessionStart(); 164 delete ui; 165 } 166 167 // Job termination 168 // Free the store: user actions, physics_lis 169 // owned and deleted by the 170 // be deleted in the main() 171 172 delete verbosity; 173 delete visManager; 174 delete runManager; 175 176 return 0; 177 } 178 179 //....oooOO0OOooo........oooOO0OOooo........oo 180