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

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

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

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

Usage:
testTR
  [-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_TR_1.C("",kFALSE)'
Date
18/12/2015
Author
I. Hrivnacova; IPN, Orsay

Definition in file testTR.cxx.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Application main program.

Definition at line 139 of file testTR.cxx.

140{
141 // Initialize Root threading.
142 // (Multi-threading is triggered automatically if Geant4 was built
143 // in MT mode.)
144#ifdef G4MULTITHREADED
145 ROOT::EnableThreadSafety();
146#endif
147
148 // Process arguments
149 // This code is generic with the exception of the start values and
150 // the program name
151#ifdef USE_GEANT4
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";
157 // std::string g4VisMacro = "g4vis.in";
158 std::string g4VisMacro = "";
159 std::string g4Session = "";
160#endif
161#ifdef USE_GEANT3
162 std::string g3Geometry = "TGeant3TGeo";
163#endif
164 std::string rootMacro = "";
165 std::string verbose = "yes";
166
167 for (Int_t i = 1; i < argc; i = i + 2) {
168 std::cout << "processing " << argv[i] << " with " << argv[i + 1]
169 << std::endl;
170#ifdef USE_GEANT4
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];
189#endif
190#ifdef USE_GEANT3
191 if (std::string(argv[i]) == "--g3-geometry" ||
192 std::string(argv[i]) == "-g3g")
193 g3Geometry = argv[i + 1];
194#endif
195 else if (std::string(argv[i]) == "--root-macro" ||
196 std::string(argv[i]) == "-rm")
197 rootMacro = argv[i + 1];
198 else if (std::string(argv[i]) == "--verbose" ||
199 std::string(argv[i]) == "-v")
200 verbose = argv[i + 1];
201 else {
202 PrintUsage("testTR");
203 return 1;
204 }
205 }
206
207 if (verbose == "yes") {
208#ifdef USE_GEANT4
209 PrintG4Configuration("testTR", g4Geometry, g4PhysicsList, g4SpecialPhysics,
210 g4Macro, g4Macro2, g4VisMacro, g4Session, rootMacro);
211#endif
212#ifdef USE_GEANT3
213 PrintG3Configuration("testTR", g3Geometry, rootMacro);
214#endif
215 }
216 //
217 // end of code to process arguments
218
219 // Create MC application (thread local)
221 new VMC::TR::MCApplication("ExampleTR", "The exampleTR MC application");
223 appl->SetPrintModulo(10000);
224
225#ifdef USE_GEANT4
226 // RunConfiguration for Geant4
227 TG4RunConfiguration* runConfiguration = new TG4RunConfiguration(
228 g4Geometry, g4PhysicsList, g4SpecialPhysics, false, false);
229
230 // TGeant4
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 if (g3Geometry == "TGeant3") {
243 new TGeant3("C++ Interface to Geant3");
244 }
245 else if (g3Geometry == "TGeant3TGeo") {
246 new TGeant3TGeo("C++ Interface to Geant3");
247 }
248 else {
249 PrintUsage("testTR");
250 return 1;
251 }
252 gMC->SetProcess("DRAY", 1);
253 gMC->SetProcess("LOSS", 1);
254 gMC->SetProcess("HADR", 0);
255#endif
256
257 // Run example
258 if (!rootMacro.size()) {
259 appl->InitMC("");
260#ifdef USE_GEANT4
261 if (g4Macro2.size()) {
262 // Customise Geant4 setting after initialization:
263 geant4->ProcessGeantMacro("g4config2.in");
264 }
265
266 // Setting Geant4 visualization
267 if (g4VisMacro.size()) {
268 geant4->ProcessGeantMacro(g4VisMacro.data());
269 }
270#endif
271 appl->RunMC(5000);
272 }
273 else {
274 // Run from Root macro
275 gROOT->Macro(rootMacro.data());
276 }
277
278 delete appl;
279}
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)
std::string verbose
Definition testE03c.cxx:75
std::string rootMacro
Definition testE03c.cxx:74