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