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

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

#include "MCApplication.h"
#include "TInterpreter.h"
#include "TROOT.h"
#include "TThread.h"
#include <iostream>
#include <string>
Include dependency graph for testGflash.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 Gflash test application.

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

Usage:
testGflash
  [-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_Gflash.C("",kFALSE)'
Date
28/10/2015
Author
I. Hrivnacova; IPN, Orsay

Definition in file testGflash.cxx.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Application main program.

Definition at line 137 of file testGflash.cxx.

138{
139 // Initialize Root threading.
140 // (Multi-threading is triggered automatically if Geant4 was built
141 // in MT mode.)
142#ifdef G4MULTITHREADED
143 ROOT::EnableThreadSafety();
144#endif
145
146 // Process arguments
147 // This code is generic with the exception of the start values and
148 // the program name
149#ifdef USE_GEANT4
150 std::string g4Geometry = "geomRootToGeant4";
151 std::string g4PhysicsList = "FTFP_BERT";
152 std::string g4SpecialPhysics = "stepLimiter+gflash";
153 std::string g4Macro = "g4config.in";
154 std::string g4VisMacro = "g4vis.in";
155 std::string g4Session = "";
156#endif
157#ifdef USE_GEANT3
158 std::string g3Geometry = "TGeant3TGeo";
159#endif
160 std::string rootMacro = "";
161 std::string verbose = "yes";
162
163 for (Int_t i = 1; i < argc; i = i + 2) {
164 std::cout << "processing " << argv[i] << " with " << argv[i + 1]
165 << std::endl;
166#ifdef USE_GEANT4
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];
185#endif
186#ifdef USE_GEANT3
187 if (std::string(argv[i]) == "--g3-geometry" ||
188 std::string(argv[i]) == "-g3g")
189 g3Geometry = argv[i + 1];
190#endif
191 else if (std::string(argv[i]) == "--root-macro" ||
192 std::string(argv[i]) == "-rm")
193 rootMacro = argv[i + 1];
194 else if (std::string(argv[i]) == "--verbose" ||
195 std::string(argv[i]) == "-v")
196 verbose = argv[i + 1];
197 else {
198 PrintUsage("testGflash");
199 return 1;
200 }
201 }
202
203 if (verbose == "yes") {
204#ifdef USE_GEANT4
205 PrintG4Configuration("testGflash", g4Geometry, g4PhysicsList,
206 g4SpecialPhysics, g4Macro, g4VisMacro, g4Session, rootMacro);
207#endif
208#ifdef USE_GEANT3
209 PrintG3Configuration("testGflash", g3Geometry, rootMacro);
210#endif
211 }
212 //
213 // end of code to process arguments
214
215 // Create MC application (thread local)
217 "ExampleGflash", "The exampleGflash MC application");
218
219#ifdef USE_GEANT4
220 // RunConfiguration for Geant4
221 TG4RunConfiguration* runConfiguration = new TG4RunConfiguration(
222 g4Geometry, g4PhysicsList, g4SpecialPhysics, false, false);
223
224 // TGeant4
225 TGeant4* geant4 = new TGeant4(
226 "TGeant4", "The Geant4 Monte Carlo", runConfiguration, argc, argv);
227
228 // Customise Geant4 setting
229 // (verbose level, global range cut, ..)
230 if (g4Macro.size()) {
231 geant4->ProcessGeantMacro(g4Macro.data());
232 }
233#endif
234
235#ifdef USE_GEANT3
236 if (g3Geometry == "TGeant3") {
237 new TGeant3("C++ Interface to Geant3");
238 }
239 else if (g3Geometry == "TGeant3TGeo") {
240 new TGeant3TGeo("C++ Interface to Geant3");
241 }
242 else {
243 PrintUsage("testGflash");
244 return 1;
245 }
246#endif
247
248 // Run example
249 if (!rootMacro.size()) {
250 appl->InitMC("");
251#ifdef USE_GEANT4
252 // Setting Geant4 visualization
253 if (g4VisMacro.size()) {
254 geant4->ProcessGeantMacro(g4VisMacro.data());
255 }
256#endif
257 appl->RunMC(10);
258 }
259 else {
260 // Run from Root macro
261 gROOT->Macro(rootMacro.data());
262 }
263
264 delete appl;
265}
Implementation of the TVirtualMCApplication.
void InitMC(const char *setup)
void RunMC(Int_t nofEvents)
std::string verbose
Definition testE03c.cxx:75
std::string rootMacro
Definition testE03c.cxx:74