81{
82
83
84 if(argc > 9)
85 {
87 return 1;
88 }
92#ifdef G4MULTITHREADED
93 G4int nThreads = 0;
94#endif
95
96 G4long myseed = 345354;
97 for(G4int i = 1; i < argc; i = i + 2)
98 {
100 gdmlfile = argv[i + 1];
102 macro = argv[i + 1];
104 session = argv[i + 1];
106 myseed = atoi(argv[i + 1]);
107#ifdef G4MULTITHREADED
109 {
110 nThreads = G4UIcommand::ConvertToInt(argv[i + 1]);
111 }
112#endif
113 else
114 {
116 return 1;
117 }
118 }
119
120
122 if(macro.size() == 0)
123 {
125 }
126
127
128 auto runManager = G4RunManagerFactory::CreateRunManager();
129#ifdef G4MULTITHREADED
130 if(nThreads > 0)
131 runManager->SetNumberOfThreads(nThreads);
132#endif
133
134
135 G4Random::setTheSeed(myseed);
136
137
138
139
140 if(gdmlfile != "")
141 {
142#ifdef GEANT4_USE_GDML
143 runManager->SetUserInitialization(
145#else
146 G4cout << "Error! Input gdml file specified, but Geant4 wasn't" << G4endl
147 << "built with gdml support." << G4endl;
148 return 1;
149#endif
150 }
151 else
152 {
154 }
155
159 physicsList->RegisterPhysics(opticalPhysics);
160 runManager->SetUserInitialization(physicsList);
161
163
165 visManager->Initialize();
166
167 G4UImanager* UImanager = G4UImanager::GetUIpointer();
168
169 if(macro.size())
170 {
171 G4String command =
"/control/execute ";
172 UImanager->ApplyCommand(command + macro);
173 }
174 else
175 {
176 UImanager->ApplyCommand("/control/execute vis.mac");
177 if(ui->IsGUI())
178 UImanager->ApplyCommand("/control/execute gui.mac");
179 ui->SessionStart();
180 delete ui;
181 }
182
183 delete visManager;
184 delete runManager;
185
186 return 0;
187}