VMC Examples Version 6.6
Loading...
Searching...
No Matches
testE03b.cxx File Reference

The Geant4 VMC example E03 test application. More...

#include "Ex03bMCApplication.h"
#include "TROOT.h"
#include <iostream>
#include <string>
Include dependency graph for testE03b.cxx:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 Application main program.
 

Detailed Description

The Geant4 VMC example E03 test application.

The Geant4 VMC test application with explicitely instantiated TGeant3 or TGeant4 and linked with all libraries.

Usage:
testE03b
  [-g4g,  --g4-geometry]:        Geant4 VMC geometry option
  [-g4pl, --g4-physics-list]:    Geant4 physics list selection
  [-g4sp, --g4-special-physics]: Geant4 special physics selection
  [-g4m,  --g4-macro]:           Geant4 macro
  [-g4vm, --g4-vis-macro]:       Geant4 visualization macro
  [-g3g,  --g3-geometry]:        Geant3 geometry option
  (TGeant3,TGeant3TGeo)
  [-rm,   --root-macro]:         Root macro
  [-v,    --verbose]:            verbose option (yes,no)

Note that the g4* and g3* options are available only when built
with the corresponding VMC_WITH_Geant4 or VMC_WITH_Geant3 option.
Root macro with arguments should be passed within '', eg.
 --root-macro 'test_E03_1.C("",kFALSE)'
Date
26/02/2014
Author
I. Hrivnacova; IPN, Orsay

Definition in file testE03b.cxx.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Application main program.

Definition at line 142 of file testE03b.cxx.

143{
144 // Initialize Root threading.
145 // (Multi-threading is triggered automatically if Geant4 was built
146 // in MT mode.)
147#ifdef G4MULTITHREADED
148 ROOT::EnableThreadSafety();
149#endif
150
151 // Process arguments
152 // This code is generic with the exception of the start values and
153 // the program name
154#ifdef USE_GEANT4
155 std::string g4Geometry = "geomRootToGeant4";
156 std::string g4PhysicsList = "FTFP_BERT";
157 std::string g4SpecialPhysics = "stepLimiter";
158 std::string g4Macro = "g4config.in";
159 std::string g4VisMacro = "g4vis.in";
160 std::string g4Session = "";
161 std::string g4UserClass = "";
162#endif
163#ifdef USE_GEANT3
164 std::string g3Geometry = "TGeant3TGeo";
165#endif
166 std::string rootMacro = "";
167 std::string verbose = "yes";
168
169 for (Int_t i = 1; i < argc; i = i + 2) {
170 std::cout << "processing " << argv[i] << " with " << argv[i + 1]
171 << std::endl;
172#ifdef USE_GEANT4
173 if (std::string(argv[i]) == "--g4-geometry" ||
174 std::string(argv[i]) == "-g4g")
175 g4Geometry = argv[i + 1];
176 else if (std::string(argv[i]) == "--g4-physics-list" ||
177 std::string(argv[i]) == "-g4pl")
178 g4PhysicsList = argv[i + 1];
179 else if (std::string(argv[i]) == "--g4-special-physics" ||
180 std::string(argv[i]) == "-g4sp")
181 g4SpecialPhysics = argv[i + 1];
182 else if (std::string(argv[i]) == "--g4-macro" ||
183 std::string(argv[i]) == "-g4m")
184 g4Macro = argv[i + 1];
185 else if (std::string(argv[i]) == "--g4-vis-macro" ||
186 std::string(argv[i]) == "-g4vm")
187 g4VisMacro = argv[i + 1];
188 else if (std::string(argv[i]) == "--g4-session" ||
189 std::string(argv[i]) == "-g4s")
190 g4Session = argv[i + 1];
191 // the following option is specific to use of Geant4 dependent classes
192 else if (std::string(argv[i]) == "--g4-user-class" ||
193 std::string(argv[i]) == "-g4uc")
194 g4UserClass = argv[i + 1];
195#endif
196#ifdef USE_GEANT3
197 if (std::string(argv[i]) == "--g3-geometry" ||
198 std::string(argv[i]) == "-g3g")
199 g3Geometry = argv[i + 1];
200#endif
201 else if (std::string(argv[i]) == "--root-macro" ||
202 std::string(argv[i]) == "-rm")
203 rootMacro = argv[i + 1];
204 else if (std::string(argv[i]) == "--verbose" ||
205 std::string(argv[i]) == "-v")
206 verbose = argv[i + 1];
207 else {
208 PrintUsage("testE03");
209 return 1;
210 }
211 }
212
213 if (verbose == "yes") {
214#ifdef USE_GEANT4
215 PrintG4Configuration("testE03", g4Geometry, g4PhysicsList, g4SpecialPhysics,
216 g4Macro, g4VisMacro, g4Session, g4UserClass, rootMacro);
217#endif
218#ifdef USE_GEANT3
219 PrintG3Configuration("testE03", g3Geometry, rootMacro);
220#endif
221 }
222 //
223 // end of code to process arguments
224
225 // Create MC application (thread local)
226 Ex03bMCApplication* appl =
227 new Ex03bMCApplication("ExampleE03", "The exampleE03 MC application");
228
229#ifdef USE_GEANT4
230 if (g4Geometry.find("VMC") != std::string::npos) {
231 appl->SetOldGeometry(true);
232 }
233#endif
234#ifdef USE_GEANT3
235 if (g3Geometry == "TGeant3") {
236 appl->SetOldGeometry(true);
237 }
238#endif
239
240#ifdef USE_GEANT4
241 // RunConfiguration for Geant4
242 TG4RunConfiguration* runConfiguration = 0;
243 if (!g4UserClass.size()) {
244 runConfiguration =
245 new TG4RunConfiguration(g4Geometry, g4PhysicsList, g4SpecialPhysics);
246 }
247 else if (g4UserClass == "geometry") {
248 runConfiguration =
249 new Ex03RunConfiguration1(g4PhysicsList, g4SpecialPhysics);
250 }
251 else if (g4UserClass == "physics-list") {
252 runConfiguration = new Ex03RunConfiguration2(g4Geometry, g4SpecialPhysics);
253 }
254 else if (g4UserClass == "regions") {
255 runConfiguration =
256 new Ex03RunConfiguration3(g4Geometry, g4PhysicsList, g4SpecialPhysics);
257 }
258 else if (g4UserClass == "field") {
259 runConfiguration =
260 new Ex03RunConfiguration4(g4Geometry, g4PhysicsList, g4SpecialPhysics);
261 }
262 else {
263 PrintUsage("testE03");
264 return 1;
265 }
266
267 // TGeant4
268 TGeant4* geant4 = new TGeant4(
269 "TGeant4", "The Geant4 Monte Carlo", runConfiguration, argc, argv);
270
271 // Customise Geant4 setting
272 // (verbose level, global range cut, ..)
273 if (g4Macro.size()) {
274 geant4->ProcessGeantMacro(g4Macro.data());
275 }
276#endif
277
278#ifdef USE_GEANT3
279 if (g3Geometry == "TGeant3") {
280 new TGeant3("C++ Interface to Geant3");
281 }
282 else if (g3Geometry == "TGeant3TGeo") {
283 new TGeant3TGeo("C++ Interface to Geant3");
284 }
285 else {
286 PrintUsage("testE03");
287 return 1;
288 }
289 gMC->SetProcess("DRAY", 1);
290 gMC->SetProcess("LOSS", 1);
291 gMC->SetProcess("HADR", 0);
292#endif
293
294 // Run example
295 if (!rootMacro.size()) {
296 appl->InitMC("");
297#ifdef USE_GEANT4
298 // Setting Geant4 visualization
299 if (g4VisMacro.size()) {
300 geant4->ProcessGeantMacro(g4VisMacro.data());
301 }
302#endif
303 appl->RunMC(5);
304 }
305 else {
306 // Run from Root macro
307 gROOT->Macro(rootMacro.data());
308 }
309
310 delete appl;
311}
User Geant4 VMC run configuration.
User Geant4 VMC run configuration.
User Geant4 VMC run configuration.
User Geant4 VMC run configuration.
Implementation of the TVirtualMCApplication.
void InitMC(const char *setup)
void RunMC(Int_t nofEvents)
void SetOldGeometry(Bool_t oldGeometry=kTRUE)
std::string verbose
Definition testE03c.cxx:75
std::string rootMacro
Definition testE03c.cxx:74