39#include "MCApplication.h"
40#include "PrimaryGenerator.h"
43#include "TG4RunConfiguration.h"
48#include "TGeant3TGeo.h"
51#include "TInterpreter.h"
62void PrintUsage(std::string programName)
64 std::cerr <<
" Usage: " << std::endl;
65 std::cerr <<
" " << programName << std::endl;
67 std::cerr <<
" [-g4g, --g4-geometry]: Geant4 VMC geometry option"
69 std::cerr <<
" [-g4pl, --g4-physics-list]: Geant4 physics list selection"
72 <<
" [-g4sp, --g4-special-physics]: Geant4 special physics selection"
74 std::cerr <<
" [-g4m, --g4-macro]: Geant4 macro" << std::endl;
75 std::cerr <<
" [-g4m2, --g4-macro2]: Geant4 post-init macro "
77 std::cerr <<
" [-g4vm, --g4-vis-macro]: Geant4 visualization macro"
81 std::cerr <<
" [-g3g, --g3-geometry]: Geant3 geometry option "
82 "(TGeant3,TGeant3TGeo)"
85 std::cerr <<
" [-rm, --root-macro]: Root macro" << std::endl;
86 std::cerr <<
" [-v, --verbose]: verbose option (yes,no)"
92void PrintG4Configuration(
const std::string& programName,
93 const std::string& g4Geometry,
const std::string& g4PhysicsList,
94 const std::string& g4SpecialPhysics,
const std::string& g4Macro,
95 const std::string& g4Macro2,
const std::string& g4VisMacro,
96 const std::string& g4Session,
const std::string&
rootMacro)
98 std::cout <<
" Running " << programName <<
" with options:" << std::endl;
99 std::cout <<
" --g4-geometry: " << g4Geometry << std::endl;
100 std::cout <<
" --g4-physics-list: " << g4PhysicsList << std::endl;
101 if (g4SpecialPhysics.size()) {
102 std::cout <<
" --g4-special-physics: " << g4SpecialPhysics << std::endl;
104 if (g4Macro.size()) {
105 std::cout <<
" --g4-macro: " << g4Macro << std::endl;
107 if (g4Macro2.size()) {
108 std::cout <<
" --g4-macro2: " << g4Macro2 << std::endl;
110 if (g4VisMacro.size()) {
111 std::cout <<
" --g4-vis-macro: " << g4VisMacro << std::endl;
113 if (g4Session.size()) {
114 std::cout <<
" --g4-session: " << g4Session << std::endl;
117 std::cout <<
" --root-macro: " <<
rootMacro << std::endl;
124void PrintG3Configuration(
const std::string& programName,
125 const std::string& g3Geometry,
const std::string&
rootMacro)
127 std::cout <<
" Running: " << std::endl;
128 std::cout <<
" " << programName << std::endl;
129 std::cout <<
" --g3-geometry: " << g3Geometry << std::endl;
131 std::cout <<
" --root-macro]: " <<
rootMacro << std::endl;
144#ifdef G4MULTITHREADED
145 ROOT::EnableThreadSafety();
152 std::string g4Geometry =
"geomRootToGeant4";
153 std::string g4PhysicsList =
"emStandard";
154 std::string g4SpecialPhysics =
"stepLimiter";
155 std::string g4Macro =
"g4config.in";
156 std::string g4Macro2 =
"g4config2.in";
158 std::string g4VisMacro =
"";
159 std::string g4Session =
"";
162 std::string g3Geometry =
"TGeant3TGeo";
167 for (Int_t i = 1; i < argc; i = i + 2) {
168 std::cout <<
"processing " << argv[i] <<
" with " << argv[i + 1]
171 if (std::string(argv[i]) ==
"--g4-geometry" ||
172 std::string(argv[i]) ==
"-g4g")
173 g4Geometry = argv[i + 1];
174 else if (std::string(argv[i]) ==
"--g4-physics-list" ||
175 std::string(argv[i]) ==
"-g4pl")
176 g4PhysicsList = argv[i + 1];
177 else if (std::string(argv[i]) ==
"--g4-special-physics" ||
178 std::string(argv[i]) ==
"-g4sp")
179 g4SpecialPhysics = argv[i + 1];
180 else if (std::string(argv[i]) ==
"--g4-macro" ||
181 std::string(argv[i]) ==
"-g4m")
182 g4Macro = argv[i + 1];
183 else if (std::string(argv[i]) ==
"--g4-vis-macro" ||
184 std::string(argv[i]) ==
"-g4vm")
185 g4VisMacro = argv[i + 1];
186 else if (std::string(argv[i]) ==
"--g4-session" ||
187 std::string(argv[i]) ==
"-g4s")
188 g4Session = argv[i + 1];
191 if (std::string(argv[i]) ==
"--g3-geometry" ||
192 std::string(argv[i]) ==
"-g3g")
193 g3Geometry = argv[i + 1];
195 else if (std::string(argv[i]) ==
"--root-macro" ||
196 std::string(argv[i]) ==
"-rm")
198 else if (std::string(argv[i]) ==
"--verbose" ||
199 std::string(argv[i]) ==
"-v")
202 PrintUsage(
"testTR");
209 PrintG4Configuration(
"testTR", g4Geometry, g4PhysicsList, g4SpecialPhysics,
210 g4Macro, g4Macro2, g4VisMacro, g4Session,
rootMacro);
213 PrintG3Configuration(
"testTR", g3Geometry,
rootMacro);
228 g4Geometry, g4PhysicsList, g4SpecialPhysics,
false,
false);
231 TGeant4* geant4 =
new TGeant4(
232 "TGeant4",
"The Geant4 Monte Carlo", runConfiguration, argc, argv);
236 if (g4Macro.size()) {
237 geant4->ProcessGeantMacro(g4Macro.data());
242 if (g3Geometry ==
"TGeant3") {
243 new TGeant3(
"C++ Interface to Geant3");
245 else if (g3Geometry ==
"TGeant3TGeo") {
246 new TGeant3TGeo(
"C++ Interface to Geant3");
249 PrintUsage(
"testTR");
252 gMC->SetProcess(
"DRAY", 1);
253 gMC->SetProcess(
"LOSS", 1);
254 gMC->SetProcess(
"HADR", 0);
261 if (g4Macro2.size()) {
263 geant4->ProcessGeantMacro(
"g4config2.in");
267 if (g4VisMacro.size()) {
268 geant4->ProcessGeantMacro(g4VisMacro.data());
Implementation of the TVirtualMCApplication.
PrimaryGenerator * GetPrimaryGenerator() const
void SetPrintModulo(Int_t value)
void RunMC(Int_t nofEvents)
void InitMC(const char *setup)
void SetNofPrimaries(Int_t nofPrimaries)
int main(int argc, char **argv)
Application main program.