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

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

#include "Ex02MCApplication.h"
#include "TROOT.h"
#include <iostream>
#include <string>
Include dependency graph for testE02.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 E02 test application.

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

Usage:

testE02
  [-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_E02.C("",kFALSE)'
Date
26/02/2014
Author
I. Hrivnacova; IPN, Orsay

Definition in file testE02.cxx.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Application main program.

Definition at line 131 of file testE02.cxx.

132{
133 // Initialize Root threading.
134 // (Multi-threading is triggered automatically if Geant4 was built
135 // in MT mode.)
136#ifdef G4MULTITHREADED
137 ROOT::EnableThreadSafety();
138#endif
139
140 // Process arguments
141 // This code is generic with the exception of the start values and
142 // the program name
143#ifdef USE_GEANT4
144 std::string g4Geometry = "geomRootToGeant4";
145 std::string g4PhysicsList = "FTFP_BERT";
146 std::string g4SpecialPhysics = "stepLimiter";
147 std::string g4Macro = "g4config.in";
148 std::string g4VisMacro = "g4vis.in";
149 std::string g4Session = "";
150#endif
151#ifdef USE_GEANT3
152 std::string g3Geometry = "TGeant3TGeo";
153#endif
154 std::string rootMacro = "";
155 std::string verbose = "yes";
156
157 for (Int_t i = 1; i < argc; i = i + 2) {
158 std::cout << "processing " << argv[i] << " with " << argv[i + 1]
159 << std::endl;
160#ifdef USE_GEANT4
161 if (std::string(argv[i]) == "--g4-geometry" ||
162 std::string(argv[i]) == "-g4g")
163 g4Geometry = argv[i + 1];
164 else if (std::string(argv[i]) == "--g4-physics-list" ||
165 std::string(argv[i]) == "-g4pl")
166 g4PhysicsList = argv[i + 1];
167 else if (std::string(argv[i]) == "--g4-special-physics" ||
168 std::string(argv[i]) == "-g4sp")
169 g4SpecialPhysics = argv[i + 1];
170 else if (std::string(argv[i]) == "--g4-macro" ||
171 std::string(argv[i]) == "-g4m")
172 g4Macro = argv[i + 1];
173 else if (std::string(argv[i]) == "--g4-vis-macro" ||
174 std::string(argv[i]) == "-g4vm")
175 g4VisMacro = argv[i + 1];
176 else if (std::string(argv[i]) == "--g4-session" ||
177 std::string(argv[i]) == "-g4s")
178 g4Session = argv[i + 1];
179#endif
180#ifdef USE_GEANT3
181 if (std::string(argv[i]) == "--g3-geometry" ||
182 std::string(argv[i]) == "-g3g")
183 g3Geometry = argv[i + 1];
184#endif
185 else if (std::string(argv[i]) == "--root-macro" ||
186 std::string(argv[i]) == "-rm")
187 rootMacro = argv[i + 1];
188 else if (std::string(argv[i]) == "--verbose" ||
189 std::string(argv[i]) == "-v")
190 verbose = argv[i + 1];
191 else {
192 PrintUsage("testE02");
193 return 1;
194 }
195 }
196
197 if (verbose == "yes") {
198#ifdef USE_GEANT4
199 PrintG4Configuration("testE02", g4Geometry, g4PhysicsList, g4SpecialPhysics,
200 g4Macro, g4VisMacro, g4Session, rootMacro);
201#endif
202#ifdef USE_GEANT3
203 PrintG3Configuration("testE02", g3Geometry, rootMacro);
204#endif
205 }
206 //
207 // end of code to process arguments
208
209 // Create MC application (thread local)
210 Ex02MCApplication* appl =
211 new Ex02MCApplication("ExampleE02", "The exampleE02 MC application");
212
213#ifdef USE_GEANT4
214 if (g4Geometry.find("VMC") != std::string::npos) {
215 appl->SetOldGeometry(true);
216 }
217#endif
218#ifdef USE_GEANT3
219 if (g3Geometry == "TGeant3") {
220 appl->SetOldGeometry(true);
221 }
222#endif
223
224#ifdef USE_GEANT4
225 // RunConfiguration for Geant4
226 TG4RunConfiguration* runConfiguration =
227 new TG4RunConfiguration(g4Geometry, g4PhysicsList, g4SpecialPhysics);
228
229 // TGeant4
230 // TO DO: pass g4session here
231 TGeant4* geant4 = new TGeant4(
232 "TGeant4", "The Geant4 Monte Carlo", runConfiguration, argc, argv);
233
234 // Customise Geant4 setting
235 // (verbose level, global range cut, ..)
236 if (g4Macro.size()) {
237 geant4->ProcessGeantMacro(g4Macro.data());
238 }
239#endif
240
241#ifdef USE_GEANT3
242 TGeant3* geant3 = 0;
243 if (g3Geometry == "TGeant3") {
244 geant3 = new TGeant3("C++ Interface to Geant3");
245 }
246 else if (g3Geometry == "TGeant3TGeo") {
247 geant3 = new TGeant3TGeo("C++ Interface to Geant3");
248 }
249 else {
250 PrintUsage("exampleE01");
251 return 1;
252 }
253 geant3->SetHADR(0);
254#endif
255
256 // Run example
257 if (!rootMacro.size()) {
258 // Run from this main
259 appl->InitMC("");
260#ifdef USE_GEANT4
261 // Setting Geant4 visualization
262 if (g4VisMacro.size()) {
263 geant4->ProcessGeantMacro(g4VisMacro.data());
264 }
265#endif
266 appl->RunMC(5);
267 }
268 else {
269 // Run from Root macro
270 gROOT->Macro(rootMacro.data());
271 }
272
273 delete appl;
274}
Implementation of the TVirtualMCApplication.
void SetOldGeometry(Bool_t oldGeometry=kTRUE)
void RunMC(Int_t nofEvents)
void InitMC(const char *setup)
std::string verbose
Definition testE03c.cxx:75
std::string rootMacro
Definition testE03c.cxx:74