39#include "MCApplication.h"
47#include "TGeant3TGeo.h"
50#include "TInterpreter.h"
61void PrintUsage(std::string programName)
63 std::cerr <<
" Usage: " << std::endl;
64 std::cerr <<
" " << programName << std::endl;
66 std::cerr <<
" [-g4g, --g4-geometry]: Geant4 VMC geometry option"
68 std::cerr <<
" [-g4pl, --g4-physics-list]: Geant4 physics list selection"
71 <<
" [-g4sp, --g4-special-physics]: Geant4 special physics selection"
73 std::cerr <<
" [-g4m, --g4-macro]: Geant4 macro" << std::endl;
74 std::cerr <<
" [-g4vm, --g4-vis-macro]: Geant4 visualization macro"
76 std::cerr <<
" [-g4uc, --g4-user-class]: Geant4 user class "
77 <<
" (geometry, regions, "
78 "physics-list, field)"
82 std::cerr <<
" [-g3g, --g3-geometry]: Geant3 geometry option "
83 "(TGeant3,TGeant3TGeo)"
86 std::cerr <<
" [-rm, --root-macro]: Root macro" << std::endl;
87 std::cerr <<
" [-v, --verbose]: verbose option (yes,no)"
93void PrintG4Configuration(
const std::string& programName,
94 const std::string& g4Geometry,
const std::string& g4PhysicsList,
95 const std::string& g4SpecialPhysics,
const std::string& g4Macro,
96 const std::string& g4VisMacro,
const std::string& g4Session,
99 std::cout <<
" Running " << programName <<
" with options:" << std::endl;
100 std::cout <<
" --g4-geometry: " << g4Geometry << std::endl;
101 std::cout <<
" --g4-physics-list: " << g4PhysicsList << std::endl;
102 if (g4SpecialPhysics.size()) {
103 std::cout <<
" --g4-special-physics: " << g4SpecialPhysics << std::endl;
105 if (g4Macro.size()) {
106 std::cout <<
" --g4-macro: " << g4Macro << std::endl;
108 if (g4VisMacro.size()) {
109 std::cout <<
" --g4-vis-macro: " << g4VisMacro << std::endl;
111 if (g4Session.size()) {
112 std::cout <<
" --g4-session: " << g4Session << std::endl;
115 std::cout <<
" --root-macro: " <<
rootMacro << std::endl;
122void PrintG3Configuration(
const std::string& programName,
123 const std::string& g3Geometry,
const std::string&
rootMacro)
125 std::cout <<
" Running: " << std::endl;
126 std::cout <<
" " << programName << std::endl;
127 std::cout <<
" --g3-geometry: " << g3Geometry << std::endl;
129 std::cout <<
" --root-macro]: " <<
rootMacro << std::endl;
142#ifdef G4MULTITHREADED
143 ROOT::EnableThreadSafety();
150 std::string g4Geometry =
"geomRootToGeant4";
151 std::string g4PhysicsList =
"FTFP_BERT";
152 std::string g4SpecialPhysics =
"stepLimiter";
153 std::string g4Macro =
"g4config.in";
154 std::string g4VisMacro =
"g4vis.in";
155 std::string g4Session =
"";
158 std::string g3Geometry =
"TGeant3TGeo";
163 for (Int_t i = 1; i < argc; i = i + 2) {
164 std::cout <<
"processing " << argv[i] <<
" with " << argv[i + 1]
167 if (std::string(argv[i]) ==
"--g4-geometry" ||
168 std::string(argv[i]) ==
"-g4g")
169 g4Geometry = argv[i + 1];
170 else if (std::string(argv[i]) ==
"--g4-physics-list" ||
171 std::string(argv[i]) ==
"-g4pl")
172 g4PhysicsList = argv[i + 1];
173 else if (std::string(argv[i]) ==
"--g4-special-physics" ||
174 std::string(argv[i]) ==
"-g4sp")
175 g4SpecialPhysics = argv[i + 1];
176 else if (std::string(argv[i]) ==
"--g4-macro" ||
177 std::string(argv[i]) ==
"-g4m")
178 g4Macro = argv[i + 1];
179 else if (std::string(argv[i]) ==
"--g4-vis-macro" ||
180 std::string(argv[i]) ==
"-g4vm")
181 g4VisMacro = argv[i + 1];
182 else if (std::string(argv[i]) ==
"--g4-session" ||
183 std::string(argv[i]) ==
"-g4s")
184 g4Session = argv[i + 1];
187 if (std::string(argv[i]) ==
"--g3-geometry" ||
188 std::string(argv[i]) ==
"-g3g")
189 g3Geometry = argv[i + 1];
191 else if (std::string(argv[i]) ==
"--root-macro" ||
192 std::string(argv[i]) ==
"-rm")
194 else if (std::string(argv[i]) ==
"--verbose" ||
195 std::string(argv[i]) ==
"-v")
198 PrintUsage(
"testExGarfield");
205 PrintG4Configuration(
"testExGarfield", g4Geometry, g4PhysicsList,
206 g4SpecialPhysics, g4Macro, g4VisMacro, g4Session,
rootMacro);
209 PrintG3Configuration(
"testExGarfield", g3Geometry,
rootMacro);
217 "ExampleExGarfield",
"The example ExGarfield MC application");
223 g4Geometry, g4PhysicsList, g4SpecialPhysics);
226 TGeant4* geant4 =
new TGeant4(
227 "TGeant4",
"The Geant4 Monte Carlo", runConfiguration, argc, argv);
231 if (g4Macro.size()) {
232 geant4->ProcessGeantMacro(g4Macro.data());
237 if (g3Geometry ==
"TGeant3") {
238 new TGeant3(
"C++ Interface to Geant3");
240 else if (g3Geometry ==
"TGeant3TGeo") {
241 new TGeant3TGeo(
"C++ Interface to Geant3");
244 PrintUsage(
"testGarfield");
255 geant4->ProcessGeantMacro(
"g4config2.in");
257 if (g4VisMacro.size()) {
258 geant4->ProcessGeantMacro(g4VisMacro.data());
Definition of the ExGarfield::RunConfiguration class.
Implementation of the TVirtualMCApplication.
void InitMC(const char *setup)
void RunMC(Int_t nofEvents)
User Geant4 VMC run configuration.
int main(int argc, char **argv)
Application main program.