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

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

#include "Ex03PrimaryGenerator.h"
#include "Ex03cMCApplication.h"
#include "TROOT.h"
#include <iostream>
#include <string>
Include dependency graph for testE03c.cxx:

Go to the source code of this file.

Functions

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

Variables

std::string firstEngine = "g3"
 
std::string rootMacro = ""
 
std::string verbose = "yes"
 

Detailed Description

The Geant4 VMC example E03c test application.

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

Usage:
testE03c
  [-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)
  [-r4m,  --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_E03c_1.C("",kFALSE)'
Date
30/04/2019 Benedikt Volkel, CERN

Definition in file testE03c.cxx.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Application main program.

Definition at line 196 of file testE03c.cxx.

197{
198// Initialize Root threading.
199// (Multi-threading is triggered automatically if Geant4 was built
200// in MT mode.)
201#ifdef G4MULTITHREADED
202 ROOT::EnableThreadSafety();
203#endif
204
205 // Process arguments
206 for (Int_t i = 1; i < argc; i = i + 2) {
207 std::cout << "processing " << argv[i] << " with " << argv[i + 1]
208 << std::endl;
209 if (std::string(argv[i]) == "--root-macro" || std::string(argv[i]) == "-rm")
210 rootMacro = argv[i + 1];
211 else if (std::string(argv[i]) == "--verbose" ||
212 std::string(argv[i]) == "-v")
213 verbose = argv[i + 1];
214#ifdef USE_GEANT4
215 else if (std::string(argv[i]) == "--g4-geometry" ||
216 std::string(argv[i]) == "-g4g")
217 g4Geometry = argv[i + 1];
218 else if (std::string(argv[i]) == "--g4-physics-list" ||
219 std::string(argv[i]) == "-g4pl")
220 g4PhysicsList = argv[i + 1];
221 else if (std::string(argv[i]) == "--g4-special-physics" ||
222 std::string(argv[i]) == "-g4sp")
223 g4SpecialPhysics = argv[i + 1];
224 else if (std::string(argv[i]) == "--g4-macro" ||
225 std::string(argv[i]) == "-g4m")
226 g4Macro = argv[i + 1];
227 else if (std::string(argv[i]) == "--g4-vis-macro" ||
228 std::string(argv[i]) == "-g4vm")
229 g4VisMacro = argv[i + 1];
230 else if (std::string(argv[i]) == "--g4-session" ||
231 std::string(argv[i]) == "-g4s")
232 g4Session = argv[i + 1];
233 // the following option is specific to use of Geant4 dependent classes
234 else if (std::string(argv[i]) == "--g4-user-class" ||
235 std::string(argv[i]) == "-g4uc")
236 g4UserClass = argv[i + 1];
237#endif
238#ifdef USE_GEANT3
239 else if (std::string(argv[i]) == "--g3-geometry" ||
240 std::string(argv[i]) == "-g3g")
241 g3Geometry = argv[i + 1];
242#endif
243#ifdef USE_MULTI
244 else if (std::string(argv[i]) == "--first-engine" ||
245 std::string(argv[i]) == "-fe")
246 firstEngine = argv[i + 1];
247#endif
248 else {
249 PrintUsage("testE03c");
250 return 1;
251 }
252 }
253
254 if (verbose == "yes") {
255 PrintConfiguration("testE03c");
256 }
257 //
258 // end of code to process arguments
259
260 Bool_t isMulti = false;
261 Int_t debug = 0;
262#ifdef USE_MULTI
263 isMulti = true;
264 debug = 1;
265#endif
266
267 // Create MC application (thread local)
269 "ExampleE03", "The exampleE03 MC application", isMulti, isMulti);
270 appl->SetDebug(debug);
271
272 if (firstEngine == "g3") {
273 CreateGeant3();
274 CreateGeant4(argc, argv);
275 }
276 else {
277 CreateGeant4(argc, argv);
278 CreateGeant3();
279 }
280
281 if (!rootMacro.size()) {
282 // Run example without Root macro
283#ifdef USE_MULTI
284 appl->InitMC();
285#else
286 appl->InitMC("");
287#endif
288
289 // Setting Geant4 visualization
290 // #ifdef USE_GEANT4
291 // #ifndef USE_MULTI
292 // if (g4VisMacro.size()) {
293 // geant4->ProcessGeantMacro(g4VisMacro.data());
294 // }
295 // #endif
296 // #endif
297 appl->RunMC(5);
298 }
299 else {
300 // Run from Root macro
301 std::cout << "Go to call macro" << std::endl;
302 gROOT->Macro(rootMacro.data());
303 }
304
305 delete appl;
306}
Implementation of the TVirtualMCApplication.
void InitMC(const char *setup)
void RunMC(Int_t nofEvents)
void SetDebug(Int_t debug)
Set debug option for multiple run.
std::string firstEngine
Definition testE03c.cxx:73
std::string verbose
Definition testE03c.cxx:75
std::string rootMacro
Definition testE03c.cxx:74

Variable Documentation

◆ firstEngine

std::string firstEngine = "g3"

Definition at line 73 of file testE03c.cxx.

◆ rootMacro

std::string rootMacro = ""

Definition at line 74 of file testE03c.cxx.

◆ verbose

std::string verbose = "yes"

Definition at line 75 of file testE03c.cxx.