42#include "TG4RunConfiguration.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)" << std::endl;
78 std::cerr <<
" [-g4lf, --g4-local-field]: Geant4 local field option "
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,
97 const std::string& g4UserClass,
const std::string& g4LocalField,
100 std::cout <<
" Running " << programName <<
" with options:" << std::endl;
101 std::cout <<
" --g4-geometry: " << g4Geometry << std::endl;
102 std::cout <<
" --g4-physics-list: " << g4PhysicsList << std::endl;
103 if (g4SpecialPhysics.size()) {
104 std::cout <<
" --g4-special-physics: " << g4SpecialPhysics << std::endl;
106 if (g4Macro.size()) {
107 std::cout <<
" --g4-macro: " << g4Macro << std::endl;
109 if (g4VisMacro.size()) {
110 std::cout <<
" --g4-vis-macro: " << g4VisMacro << std::endl;
112 if (g4Session.size()) {
113 std::cout <<
" --g4-session: " << g4Session << std::endl;
115 if (g4UserClass.size()) {
116 std::cout <<
" --g4-user-class: " << g4UserClass << std::endl;
118 if (g4LocalField.size()) {
119 std::cout <<
" --g4-local-field: " << g4LocalField << std::endl;
122 std::cout <<
" --root-macro: " <<
rootMacro << std::endl;
129void PrintG3Configuration(
const std::string& programName,
130 const std::string& g3Geometry,
const std::string&
rootMacro)
132 std::cout <<
" Running: " << std::endl;
133 std::cout <<
" " << programName << std::endl;
134 std::cout <<
" --g3-geometry: " << g3Geometry << std::endl;
136 std::cout <<
" --root-macro]: " <<
rootMacro << std::endl;
149#ifdef G4MULTITHREADED
150 ROOT::EnableThreadSafety();
157 std::string g4Geometry =
"geomRootToGeant4";
158 std::string g4PhysicsList =
"FTFP_BERT";
159 std::string g4SpecialPhysics =
"stepLimiter";
160 std::string g4Macro =
"g4config.in";
161 std::string g4VisMacro =
"g4vis.in";
162 std::string g4Session =
"";
163 std::string g4UserClass =
"";
164 std::string g4LocalField =
"";
167 std::string g3Geometry =
"TGeant3TGeo";
172 for (Int_t i = 1; i < argc; i = i + 2) {
173 std::cout <<
"processing " << argv[i] <<
" with " << argv[i + 1]
176 if (std::string(argv[i]) ==
"--g4-geometry" ||
177 std::string(argv[i]) ==
"-g4g")
178 g4Geometry = argv[i + 1];
179 else if (std::string(argv[i]) ==
"--g4-physics-list" ||
180 std::string(argv[i]) ==
"-g4pl")
181 g4PhysicsList = argv[i + 1];
182 else if (std::string(argv[i]) ==
"--g4-special-physics" ||
183 std::string(argv[i]) ==
"-g4sp")
184 g4SpecialPhysics = argv[i + 1];
185 else if (std::string(argv[i]) ==
"--g4-macro" ||
186 std::string(argv[i]) ==
"-g4m")
187 g4Macro = argv[i + 1];
188 else if (std::string(argv[i]) ==
"--g4-vis-macro" ||
189 std::string(argv[i]) ==
"-g4vm")
190 g4VisMacro = argv[i + 1];
191 else if (std::string(argv[i]) ==
"--g4-session" ||
192 std::string(argv[i]) ==
"-g4s")
193 g4Session = argv[i + 1];
195 else if (std::string(argv[i]) ==
"--g4-user-class" ||
196 std::string(argv[i]) ==
"-g4uc")
197 g4UserClass = argv[i + 1];
198 else if (std::string(argv[i]) ==
"--g4-local-field" ||
199 std::string(argv[i]) ==
"-g4lf")
200 g4LocalField = argv[i + 1];
203 if (std::string(argv[i]) ==
"--g3-geometry" ||
204 std::string(argv[i]) ==
"-g3g")
205 g3Geometry = argv[i + 1];
207 else if (std::string(argv[i]) ==
"--root-macro" ||
208 std::string(argv[i]) ==
"-rm")
210 else if (std::string(argv[i]) ==
"--verbose" ||
211 std::string(argv[i]) ==
"-v")
214 PrintUsage(
"testA01");
221 PrintG4Configuration(
"testA01", g4Geometry, g4PhysicsList, g4SpecialPhysics,
222 g4Macro, g4VisMacro, g4Session, g4UserClass, g4LocalField,
rootMacro);
225 PrintG3Configuration(
"testA01", g3Geometry,
rootMacro);
236 if (g4LocalField.size()) {
237 G4cout <<
"setting local field to true" << G4endl;
243 if (!g4UserClass.size()) {
247 else if (g4UserClass ==
"geometry") {
250 if (g4LocalField.size()) {
252 ->SetUseLocalMagField(
true);
256 PrintUsage(
"testA01");
262 TGeant4* geant4 =
new TGeant4(
263 "TGeant4",
"The Geant4 Monte Carlo", runConfiguration, argc, argv);
267 if (g4Macro.size()) {
268 geant4->ProcessGeantMacro(g4Macro.data());
273 if (g3Geometry ==
"TGeant3") {
274 new TGeant3(
"C++ Interface to Geant3");
276 else if (g3Geometry ==
"TGeant3TGeo") {
277 new TGeant3TGeo(
"C++ Interface to Geant3");
280 PrintUsage(
"testA01");
283 gMC->SetProcess(
"DRAY", 1);
284 gMC->SetProcess(
"LOSS", 1);
285 gMC->SetProcess(
"HADR", 1);
297 if (g4VisMacro.size()) {
298 geant4->ProcessGeantMacro(g4VisMacro.data());
Definition of the A01MCApplication class.
Definition of the A01PrimaryGenerator class.
Definition of the A01RunConfiguration class.
Implementation of the TVirtualMCApplication.
void SetWriteHits(Bool_t writeHits)
void RunMC(Int_t nofEvents)
void SetWriteStack(Bool_t writeStack)
A01PrimaryGenerator * GetPrimaryGenerator() const
void InitMC(const char *setup)
void SetUseLocalMagField(Bool_t localMagField)
void SetRandomize(Bool_t val)
User Geant4 VMC run configuration.
int main(int argc, char **argv)
Application main program.