File indexing completed on 2025-02-23 09:21:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #include "ActionInitialization.hh"
0034 #include "DetectorConstruction.hh"
0035
0036 #include "G4MonopolePhysics.hh"
0037 #include "G4PhysListFactory.hh"
0038 #include "G4RunManagerFactory.hh"
0039 #include "G4Types.hh"
0040 #include "G4UIExecutive.hh"
0041 #include "G4UImanager.hh"
0042 #include "G4VModularPhysicsList.hh"
0043 #include "G4VisExecutive.hh"
0044 #include "Randomize.hh"
0045 #include "globals.hh"
0046
0047
0048
0049 namespace
0050 {
0051 void PrintUsage()
0052 {
0053 G4cerr << " Usage: " << G4endl << " monopole [-m macro ] [-s setupMonopole] [-t nThreads]"
0054 << G4endl << " Note: " << G4endl
0055 << " -s should be followed by a composed string, eg. \'1 0 100 GeV\'" << G4endl
0056 << " -t option is for multi-threaded mode." << G4endl << G4endl;
0057 }
0058 }
0059
0060
0061
0062 int main(int argc, char** argv)
0063 {
0064
0065
0066 if (argc > 7) {
0067 PrintUsage();
0068 return 1;
0069 }
0070
0071 G4String macro;
0072 G4String setupMonopole;
0073 G4int nThreads = 1;
0074 for (G4int i = 1; i < argc; i = i + 2) {
0075 if (G4String(argv[i]) == "-m")
0076 macro = argv[i + 1];
0077 else if (G4String(argv[i]) == "-s")
0078 setupMonopole = argv[i + 1];
0079 else if (G4String(argv[i]) == "-t") {
0080 nThreads = G4UIcommand::ConvertToInt(argv[i + 1]);
0081 }
0082 else {
0083 PrintUsage();
0084 return 1;
0085 }
0086 }
0087
0088
0089 auto* runManager = G4RunManagerFactory::CreateRunManager();
0090 if (nThreads > 0) {
0091 runManager->SetNumberOfThreads(nThreads);
0092 }
0093 G4cout << "===== Example is started with " << runManager->GetNumberOfThreads()
0094 << " threads =====" << G4endl;
0095
0096
0097 G4UIExecutive* ui = nullptr;
0098 if (macro.empty()) {
0099 ui = new G4UIExecutive(argc, argv);
0100 }
0101
0102
0103 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0104
0105
0106
0107 G4PhysListFactory factory;
0108 G4VModularPhysicsList* phys = factory.GetReferencePhysList("FTFP_BERT");
0109
0110
0111 G4MonopolePhysics* theMonopole = new G4MonopolePhysics();
0112
0113
0114 if (setupMonopole.size()) {
0115 UImanager->ApplyCommand("/control/verbose 1");
0116 UImanager->ApplyCommand("/monopole/setup " + setupMonopole);
0117 }
0118
0119
0120 phys->RegisterPhysics(theMonopole);
0121
0122 runManager->SetUserInitialization(phys);
0123
0124
0125 G4VisManager* visManager = nullptr;
0126
0127
0128 DetectorConstruction* det = new DetectorConstruction();
0129 runManager->SetUserInitialization(det);
0130
0131
0132 runManager->SetUserInitialization(new ActionInitialization(det));
0133
0134
0135
0136 if (macro.size()) {
0137
0138 G4String command = "/control/execute ";
0139 UImanager->ApplyCommand(command + macro);
0140 }
0141 else {
0142
0143 visManager = new G4VisExecutive();
0144 visManager->Initialize();
0145 UImanager->ApplyCommand("/control/execute init_vis.mac");
0146 ui->SessionStart();
0147 delete ui;
0148 }
0149
0150 delete visManager;
0151
0152
0153 delete runManager;
0154
0155 return 0;
0156 }
0157
0158