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 // This example is provided by the Geant4-DNA 27 // Any report or published results obtained us 28 // shall cite the following Geant4-DNA collabo 29 // Med. Phys. 37 (2010) 4692-4708 30 // The Geant4-DNA web site is available at htt 31 // 32 /// \file wholeNuclearDNA.cc 33 /// \brief Implementation of the microdosimetr 34 // 35 //....oooOO0OOooo........oooOO0OOooo........oo 36 #include "G4RunManagerFactory.hh" 37 #include "G4Types.hh" 38 #include "G4UIExecutive.hh" 39 #include "G4UImanager.hh" 40 #include "G4UItcsh.hh" 41 #include "G4UIterminal.hh" 42 #include "G4VisExecutive.hh" 43 #ifdef G4UI_USE_QT 44 # include "G4UIQt.hh" 45 #endif 46 47 #include "ActionInitialization.hh" 48 #include "CommandLineParser.hh" 49 #include "DetectorConstruction.hh" 50 #include "PhysicsList.hh" 51 52 //....oooOO0OOooo........oooOO0OOooo........oo 53 54 using namespace G4DNAPARSER; 55 CommandLineParser* parser(0); 56 57 void Parse(int& argc, char** argv); 58 59 int main(int argc, char** argv) 60 { 61 ////////// 62 // Parse options given in commandLine 63 // 64 Parse(argc, argv); 65 66 ////////// 67 // Construct the run manager according to wh 68 // 69 Command* commandLine(0); 70 71 auto* runManager = G4RunManagerFactory::Crea 72 if ((commandLine = parser->GetCommandIfActiv 73 int nThreads = 2; 74 if (commandLine->GetOption() == "NMAX") { 75 nThreads = G4Threading::G4GetNumberOfCor 76 } 77 else { 78 nThreads = G4UIcommand::ConvertToInt(com 79 } 80 81 runManager->SetNumberOfThreads(nThreads); 82 83 G4cout << "===== WholeNuclearDNA is starte 84 << " threads =====" << G4endl; 85 } 86 87 // Set mandatory user initialization classes 88 DetectorConstruction* detector = new Detecto 89 runManager->SetUserInitialization(detector); 90 runManager->SetUserInitialization(new Physic 91 runManager->SetUserInitialization(new Action 92 93 // Initialize G4 kernel 94 runManager->Initialize(); 95 96 // Initialize visualization 97 G4VisManager* visManager = new G4VisExecutiv 98 // G4VisExecutive can take a verbosity argum 99 // G4VisManager* visManager = new G4VisExecu 100 visManager->Initialize(); 101 102 // Get the pointer to the User Interface man 103 G4UImanager* UImanager = G4UImanager::GetUIp 104 G4UIExecutive* ui(0); 105 106 // interactive mode : define UI session 107 if ((commandLine = parser->GetCommandIfActiv 108 ui = new G4UIExecutive(argc, argv, command 109 110 if (ui->IsGUI()) UImanager->ApplyCommand(" 111 112 if (parser->GetCommandIfActive("-novis") = 113 // visualization is used by default 114 { 115 if ((commandLine = parser->GetCommandIfA 116 // select a visualization driver if need 117 { 118 UImanager->ApplyCommand(G4String("/vis 119 } 120 else 121 // by default OGL is used 122 { 123 UImanager->ApplyCommand("/vis/open OGL 124 } 125 UImanager->ApplyCommand("/control/execut 126 } 127 } 128 else 129 // to be use visualization file (= store the 130 // an external file: 131 // ASCIITree ; DAWNFILE ; HepRepFile ; VRML 132 { 133 if ((commandLine = parser->GetCommandIfAct 134 UImanager->ApplyCommand(G4String("/vis/o 135 UImanager->ApplyCommand("/control/execut 136 } 137 } 138 139 if ((commandLine = parser->GetCommandIfActiv 140 G4String command = "/control/execute "; 141 UImanager->ApplyCommand(command + commandL 142 } 143 else { 144 UImanager->ApplyCommand("/control/execute 145 } 146 147 if ((commandLine = parser->GetCommandIfActiv 148 #ifdef G4UI_USE_QT 149 G4UIQt* UIQt = static_cast<G4UIQt*>(UImana 150 if (UIQt) { 151 UIQt->AddViewerTabFromFile("README", "RE 152 } 153 #endif 154 ui->SessionStart(); 155 delete ui; 156 } 157 158 delete visManager; 159 delete runManager; 160 161 return 0; 162 } 163 164 //....oooOO0OOooo........oooOO0OOooo........oo 165 166 void GetNameAndPathOfExecutable(char** argv, G 167 { 168 // Get the last position of '/' 169 std::string aux(argv[0]); 170 171 // get '/' or '\\' depending on unix/mac or 172 #if defined(_WIN32) || defined(WIN32) 173 int pos = aux.rfind('\\'); 174 #else 175 int pos = aux.rfind('/'); 176 #endif 177 178 // Get the path and the name 179 path = aux.substr(0, pos + 1); 180 executable = aux.substr(pos + 1); 181 } 182 183 //....oooOO0OOooo........oooOO0OOooo........oo 184 185 void Parse(int& argc, char** argv) 186 { 187 ////////// 188 // Parse options given in commandLine 189 // 190 parser = CommandLineParser::GetParser(); 191 192 parser->AddCommand("-gui", Command::OptionNo 193 "Select geant4 UI or just 194 195 parser->AddCommand("-mac", Command::WithOpti 196 197 // You cann your own command, as for instanc 198 // parser->AddCommand("-seed", 199 // Command::WithOption, 200 // "Give a seed value in 201 // it is then up to you to manage this optio 202 203 parser->AddCommand("-mt", Command::WithOptio 204 "2"); 205 206 parser->AddCommand("-vis", Command::WithOpti 207 "OGL 600x600-0+0"); 208 209 parser->AddCommand("-novis", Command::Withou 210 211 G4String exec; 212 G4String path; 213 GetNameAndPathOfExecutable(argv, exec, path) 214 215 parser->AddCommand("-out", Command::OptionNo 216 exec); 217 218 ////////// 219 // If -h or --help is given in option : prin 220 // 221 if (parser->Parse(argc, argv) != 0) // help 222 { 223 // if you are using ROOT, create a TApplic 224 // to print the help from ROOT as well 225 CommandLineParser::DeleteInstance(); 226 std::exit(0); 227 } 228 229 /////////// 230 // Kill application if wrong argument in com 231 // 232 if (parser->CheckIfNotHandledOptionsExists(a 233 // if you are using ROOT, you should initi 234 // before this condition 235 abort(); 236 } 237 } 238