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 exoticphysics/monopole/monopole.cc 27 /// \brief Main program of the exoticphysics/m 28 // 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 33 #include "ActionInitialization.hh" 34 #include "DetectorConstruction.hh" 35 36 #include "G4MonopolePhysics.hh" 37 #include "G4PhysListFactory.hh" 38 #include "G4RunManagerFactory.hh" 39 #include "G4Types.hh" 40 #include "G4UIExecutive.hh" 41 #include "G4UImanager.hh" 42 #include "G4VModularPhysicsList.hh" 43 #include "G4VisExecutive.hh" 44 #include "Randomize.hh" 45 #include "globals.hh" 46 47 //....oooOO0OOooo........oooOO0OOooo........oo 48 49 namespace 50 { 51 void PrintUsage() 52 { 53 G4cerr << " Usage: " << G4endl << " monopole 54 << G4endl << " Note: " << G4endl 55 << " -s should be followed by a co 56 << " -t option is for multi-thread 57 } 58 } // namespace 59 60 //....oooOO0OOooo........oooOO0OOooo........oo 61 62 int main(int argc, char** argv) 63 { 64 // Evaluate arguments 65 // 66 if (argc > 7) { 67 PrintUsage(); 68 return 1; 69 } 70 71 G4String macro; 72 G4String setupMonopole; 73 G4int nThreads = 1; 74 for (G4int i = 1; i < argc; i = i + 2) { 75 if (G4String(argv[i]) == "-m") 76 macro = argv[i + 1]; 77 else if (G4String(argv[i]) == "-s") 78 setupMonopole = argv[i + 1]; 79 else if (G4String(argv[i]) == "-t") { 80 nThreads = G4UIcommand::ConvertToInt(arg 81 } 82 else { 83 PrintUsage(); 84 return 1; 85 } 86 } 87 88 // Construct the default run manager 89 auto* runManager = G4RunManagerFactory::Crea 90 if (nThreads > 0) { 91 runManager->SetNumberOfThreads(nThreads); 92 } 93 G4cout << "===== Example is started with " < 94 << " threads =====" << G4endl; 95 96 // Instantiate G4UIExecutive if interactive 97 G4UIExecutive* ui = nullptr; 98 if (macro.empty()) { 99 ui = new G4UIExecutive(argc, argv); 100 } 101 102 // get the pointer to the User Interface man 103 G4UImanager* UImanager = G4UImanager::GetUIp 104 105 // create physicsList 106 // Physics List is defined via environment 107 G4PhysListFactory factory; 108 G4VModularPhysicsList* phys = factory.GetRef 109 110 // monopole physics is added 111 G4MonopolePhysics* theMonopole = new G4Monop 112 113 // Setup monopole 114 if (setupMonopole.size()) { 115 UImanager->ApplyCommand("/control/verbose 116 UImanager->ApplyCommand("/monopole/setup " 117 } 118 119 // regsiter monopole physics 120 phys->RegisterPhysics(theMonopole); 121 122 runManager->SetUserInitialization(phys); 123 124 // visualization manager 125 G4VisManager* visManager = nullptr; 126 127 // set detector construction 128 DetectorConstruction* det = new DetectorCons 129 runManager->SetUserInitialization(det); 130 131 // set user action classes 132 runManager->SetUserInitialization(new Action 133 134 // Process macro or start UI session 135 // 136 if (macro.size()) { 137 // batch mode 138 G4String command = "/control/execute "; 139 UImanager->ApplyCommand(command + macro); 140 } 141 else { 142 // interactive mode : define UI session 143 visManager = new G4VisExecutive(); 144 visManager->Initialize(); 145 UImanager->ApplyCommand("/control/execute 146 ui->SessionStart(); 147 delete ui; 148 } 149 150 delete visManager; 151 152 // job termination 153 delete runManager; 154 155 return 0; 156 } 157 158 //....oooOO0OOooo........oooOO0OOooo........oo 159