53 #include "ActionInitialization.hh" 56 #ifdef G4MULTITHREADED 57 #include "G4MTRunManager.hh" 59 #include "G4RunManager.hh" 68 #include "G4PhysListFactoryAlt.hh" 77 #include "G4PhysListRegistry.hh" 80 #include "G4PhysicsConstructorFactory.hh" 85 #include "G4PhysListStamper.hh" 86 #include "MySpecialPhysList.hh" 91 #include "G4VModularPhysicsList.hh" 92 #include "G4UImanager.hh" 93 #include "Randomize.hh" 94 #include "G4VisExecutive.hh" 95 #include "G4UIExecutive.hh" 101 void PrintAvailable(G4int verbosity) {
103 G4cout <<
"extensibleFactory: here are the available physics lists:" 105 g4alt::G4PhysListFactory factory;
106 factory.PrintAvailablePhysLists();
109 if ( verbosity > 1 ) {
111 G4cout <<
"extensibleFactory: " 112 <<
"here are the available physics ctors that can be added:" 114 G4PhysicsConstructorRegistry* g4pctorFactory =
115 G4PhysicsConstructorRegistry::Instance();
116 g4pctorFactory->PrintAvailablePhysicsConstructors();
121 G4cerr <<
" Usage: " << G4endl;
122 G4cerr <<
" extensibleFactory [-m macro ] [-p physList ]" 123 <<
" [-u UIsession] [-t nThreads]" << G4endl
124 <<
" [-v | --verbose] [-h | --help]" << G4endl;
125 G4cerr <<
" note: -t option is available only for multi-threaded mode." 127 G4cerr <<
" note: -v can be repeated to increase verbosity." << G4endl;
130 if (verbosity>0) PrintAvailable(verbosity);
149 char* physListNameEnv = 0;
151 #ifdef G4MULTITHREADED 152 G4int nofThreads = 0;
156 for ( G4int i=1; i<argc; i=i+2 ) {
158 if ( g4argv ==
"-m" ) macro = argv[i+1];
159 else if ( g4argv ==
"-u" ) session = argv[i+1];
160 else if ( g4argv ==
"-p" ) physListName = argv[i+1];
161 #ifdef G4MULTITHREADED 162 else if ( g4argv ==
"-t" ) {
163 nofThreads = G4UIcommand::ConvertToInt(argv[i+1]);
166 else if ( g4argv ==
"-v" || g4argv ==
"--verbose" ) {
170 else if ( g4argv ==
"-h" || g4argv ==
"--help" ) {
182 G4UIExecutive* ui = 0;
183 if ( ! macro.size() ) {
184 ui =
new G4UIExecutive(argc, argv, session);
188 G4Random::setTheEngine(
new CLHEP::RanecuEngine());
191 #ifdef G4MULTITHREADED 192 G4MTRunManager * runManager =
new G4MTRunManager();
193 if ( nofThreads > 0 ) {
194 runManager->SetNumberOfThreads(nofThreads);
197 G4RunManager * runManager =
new G4RunManager();
205 g4alt::G4PhysListFactory factory;
206 G4VModularPhysicsList* physList =
nullptr;
212 G4String defaultPhysListName =
"FTFP_BERT";
213 if ( verbosity > 0 ) {
214 G4cout <<
"extensibleFactory: SetDefaultReferencePhysList to '" 215 << defaultPhysListName <<
"' ('' = system default)" 218 factory.SetDefaultReferencePhysList(defaultPhysListName);
221 G4PhysListRegistry* plreg = G4PhysListRegistry::Instance();
222 plreg->AddPhysicsExtension(
"RADIO",
"G4RadioactiveDecayPhysics");
223 plreg->AddPhysicsExtension(
"MYPHYSICS",
"MyG4PhysicsPhysics");
224 if ( verbosity > 0 ) {
225 G4cout <<
"extensibleFactory: adding extensions" << G4endl
226 <<
" RADIO ===> G4RadioactiveDecayPhysics" << G4endl
227 <<
" MYPHYSICS ===> MyG4PhysicsPhysics" << G4endl
233 if ( physListName.size() ) {
234 if ( verbosity > 0 ) {
235 G4cout <<
"extensibleFactory: explicitly using '" 236 << physListName <<
"'" << G4endl;
238 physList = factory.GetReferencePhysList(physListName);
240 if ( verbosity > 0 ) {
241 G4cout <<
"extensibleFactory: no -p flag;" 242 <<
" using ReferencePhysList() ($PHYSLIST or default)" << G4endl;
244 physList = factory.ReferencePhysList();
248 physListNameEnv = std::getenv(
"PHYSLIST");
249 if ( physListNameEnv ) {
250 G4cout <<
"extensibleFactory: $PHYSLIST=" 251 << physListNameEnv << G4endl;
260 G4cerr <<
"extensibleFactory: PhysicsList '" 261 << ( physListNameEnv ? physListNameEnv : physListName )
262 <<
"' was not available in g4alt::PhysListFactory." << G4endl;
263 PrintAvailable(verbosity);
267 G4ExceptionDescription ED;
268 ED <<
"The factory for the physicslist [" 269 << ( physListNameEnv ? physListNameEnv : physListName )
270 <<
"] does not exist!" 272 G4Exception(
"extensibleFactory",
273 "extensibleFactory001", FatalException, ED);
279 runManager->SetUserInitialization(physList);
282 ActionInitialization* actinit =
283 new ActionInitialization(
"extensibleFactory");
284 runManager->SetUserInitialization(actinit);
287 G4VisManager* visManager =
new G4VisExecutive;
290 visManager->Initialize();
293 G4UImanager* UImanager = G4UImanager::GetUIpointer();
295 if ( macro.size() ) {
297 G4String command =
"/control/execute ";
298 UImanager->ApplyCommand(command+macro);
302 UImanager->ApplyCommand(
"/control/execute init_vis.mac");
static G4UIterminal * session
int main(int argc, char **argv)
G4_DECLARE_PHYSLIST_FACTORY(MySpecialPhysList)