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 /// \file OpNovice/OpNovice.cc 27 /// \brief Main program of the OpNovice exampl 28 // 29 // 30 // 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oo 33 // 34 // Description: Test of Continuous Process G4C 35 // and RestDiscrete Process G4Sci 36 // -- Generation Cerenkov Photons 37 // -- Generation Scintillation Ph 38 // -- Transport of optical Photon 39 // Version: 5.0 40 // Created: 1996-04-30 41 // Author: Juliet Armstrong 42 // 43 //....oooOO0OOooo........oooOO0OOooo........oo 44 45 #include "OpNoviceDetectorConstruction.hh" 46 #ifdef GEANT4_USE_GDML 47 # include "OpNoviceGDMLDetectorConstruction.h 48 #endif 49 #include "FTFP_BERT.hh" 50 #include "OpNoviceActionInitialization.hh" 51 52 #include "G4EmStandardPhysics_option4.hh" 53 #include "G4OpticalPhysics.hh" 54 #include "G4RunManagerFactory.hh" 55 #include "G4Types.hh" 56 #include "G4UIExecutive.hh" 57 #include "G4UImanager.hh" 58 #include "G4VisExecutive.hh" 59 60 //....oooOO0OOooo........oooOO0OOooo........oo 61 namespace 62 { 63 void PrintUsage() 64 { 65 G4cerr << " Usage: " << G4endl; 66 #ifdef GEANT4_USE_GDML 67 G4cerr << " OpNovice [-g gdmlfile] [-m macro 68 "nThreads] [-r seed] " 69 << G4endl; 70 #else 71 G4cerr << " OpNovice [-m macro ] [-u UIsess 72 #endif 73 G4cerr << " note: -t option is available o 74 } 75 } // namespace 76 77 //....oooOO0OOooo........oooOO0OOooo........oo 78 79 int main(int argc, char** argv) 80 { 81 // Evaluate arguments 82 // 83 if (argc > 9) { 84 PrintUsage(); 85 return 1; 86 } 87 G4String gdmlfile; 88 G4String macro; 89 G4String session; 90 #ifdef G4MULTITHREADED 91 G4int nThreads = 0; 92 #endif 93 94 G4long myseed = 345354; 95 for (G4int i = 1; i < argc; i = i + 2) { 96 if (G4String(argv[i]) == "-g") 97 gdmlfile = argv[i + 1]; 98 else if (G4String(argv[i]) == "-m") 99 macro = argv[i + 1]; 100 else if (G4String(argv[i]) == "-u") 101 session = argv[i + 1]; 102 else if (G4String(argv[i]) == "-r") 103 myseed = atoi(argv[i + 1]); 104 #ifdef G4MULTITHREADED 105 else if (G4String(argv[i]) == "-t") { 106 nThreads = G4UIcommand::ConvertToInt(arg 107 } 108 #endif 109 else { 110 PrintUsage(); 111 return 1; 112 } 113 } 114 115 // Instantiate G4UIExecutive if interactive 116 G4UIExecutive* ui = nullptr; 117 if (macro.size() == 0) { 118 ui = new G4UIExecutive(argc, argv); 119 } 120 121 // Construct the default run manager 122 auto runManager = G4RunManagerFactory::Creat 123 #ifdef G4MULTITHREADED 124 if (nThreads > 0) runManager->SetNumberOfThr 125 #endif 126 127 // Seed the random number generator manually 128 G4Random::setTheSeed(myseed); 129 130 // Set mandatory initialization classes 131 // 132 // Detector construction 133 if (gdmlfile != "") { 134 #ifdef GEANT4_USE_GDML 135 runManager->SetUserInitialization(new OpNo 136 #else 137 G4cout << "Error! Input gdml file specifie 138 << "built with gdml support." << G4 139 return 1; 140 #endif 141 } 142 else { 143 runManager->SetUserInitialization(new OpNo 144 } 145 // Physics list 146 G4VModularPhysicsList* physicsList = new FTF 147 physicsList->ReplacePhysics(new G4EmStandard 148 auto opticalPhysics = new G4OpticalPhysics() 149 physicsList->RegisterPhysics(opticalPhysics) 150 runManager->SetUserInitialization(physicsLis 151 152 runManager->SetUserInitialization(new OpNovi 153 154 G4VisManager* visManager = new G4VisExecutiv 155 visManager->Initialize(); 156 157 G4UImanager* UImanager = G4UImanager::GetUIp 158 159 if (macro.size()) { 160 G4String command = "/control/execute "; 161 UImanager->ApplyCommand(command + macro); 162 } 163 else // Define UI session for interactive m 164 { 165 UImanager->ApplyCommand("/control/execute 166 if (ui->IsGUI()) UImanager->ApplyCommand(" 167 ui->SessionStart(); 168 delete ui; 169 } 170 171 delete visManager; 172 delete runManager; 173 174 return 0; 175 } 176 177 //....oooOO0OOooo........oooOO0OOooo........oo 178