68{
69
70 std::string rm_type =
GetName(_type);
74 {
75
76 fail_if_unavail = true;
77 }
78 else {
79
80
81
82
83
85 "Overriding G4RunManager type...");
86 auto force_rm =
88
89 if (force_rm.length() > 0) {
90 rm_type = std::move(force_rm);
91 fail_if_unavail = true;
92 }
93 else if (rm_type.empty()) {
95 }
96 }
97
98
99
100
102 if (opts.find(rm_type) == opts.end()) {
103 if (fail_if_unavail) {
104 fail("Run manager type is not available", rm_type, opts, 1);
105 }
106 else {
108 }
109 }
110
111
113 G4RunManager* rm = nullptr;
114
115 switch (_type) {
117 rm = new G4RunManager();
118 break;
120#if defined(G4MULTITHREADED)
121 rm = new G4MTRunManager();
122#endif
123 break;
125#if defined(G4MULTITHREADED)
126 rm = new G4TaskRunManager(_queue, false);
127#endif
128 break;
130#if defined(G4MULTITHREADED) && defined(GEANT4_USE_TBB)
131 rm = new G4TaskRunManager(_queue, true);
132#endif
133 break;
135#if defined(G4MULTITHREADED)
136#if defined(GEANT4_USE_TBB)
137 rm = new G4SubEvtRunManager(_queue, true);
138#else
139 rm = new G4SubEvtRunManager(_queue, false);
140#endif
141#endif
142 break;
143
145 break;
147 break;
149 break;
151 break;
153 break;
155 break;
156 }
157
158 if (rm ==
nullptr) fail(
"Failure creating run manager",
GetName(_type),
GetOptions(), 2);
159
160 auto mtrm = dynamic_cast<G4MTRunManager*>(rm);
161 if (nthreads > 0 && (mtrm != nullptr)) mtrm->SetNumberOfThreads(nthreads);
162
163 master_run_manager = rm;
164 mt_master_run_manager = mtrm;
165 master_run_manager_kernel = rm->
kernel;
166
168 return rm;
169}
_Tp G4GetEnv(const std::string &env_id, _Tp _default=_Tp())
static std::set< std::string > GetOptions()
static std::string GetName(G4RunManagerType)
static std::string GetDefault()
static G4RunManagerType GetType(const std::string &)
G4RunManagerKernel * kernel
void G4ConsumeParameters(_Args &&...)