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

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

#include "Ex06MCApplication.h"
#include "Ex06PrimaryGenerator.h"
#include "TInterpreter.h"
#include "TROOT.h"
#include "TThread.h"
#include <iostream>
#include <string>
Include dependency graph for testE06.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 E06 test application.

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

Usage:

testE06
  [-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
  [-g4m2, --g4-macro2]:          Geant4 macro run after initialization
  [-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_E06.C("",kFALSE)'

Date
26/02/2014
Author
I. Hrivnacova; IPN, Orsay

Definition in file testE06.cxx.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Application main program.

Definition at line 141 of file testE06.cxx.

142{
143 // Initialize Root threading.
144 // (Multi-threading is triggered automatically if Geant4 was built
145 // in MT mode.)
146#ifdef G4MULTITHREADED
147 ROOT::EnableThreadSafety();
148#endif
149
150 // Process arguments
151 // This code is generic with the exception of the start values,
152 // the program name and g4Macro2 option (present only in this example)
153#ifdef USE_GEANT4
154 std::string g4Geometry = "geomRootToGeant4";
155 std::string g4PhysicsList = "emStandard+optical";
156 std::string g4SpecialPhysics = "stepLimiter";
157 std::string g4Macro = "g4config.in";
158 std::string g4Macro2 = "g4config2.in";
159 std::string g4VisMacro = "g4vis.in";
160 std::string g4Session = "";
161#endif
162#ifdef USE_GEANT3
163 std::string g3Geometry = "TGeant3TGeo";
164#endif
165 std::string rootMacro = "";
166 std::string verbose = "yes";
167
168 for (Int_t i = 1; i < argc; i = i + 2) {
169 std::cout << "processing " << argv[i] << " with " << argv[i + 1]
170 << std::endl;
171#ifdef USE_GEANT4
172 if (std::string(argv[i]) == "--g4-geometry" ||
173 std::string(argv[i]) == "-g4g")
174 g4Geometry = argv[i + 1];
175 else if (std::string(argv[i]) == "--g4-physics-list" ||
176 std::string(argv[i]) == "-g4pl")
177 g4PhysicsList = argv[i + 1];
178 else if (std::string(argv[i]) == "--g4-special-physics" ||
179 std::string(argv[i]) == "-g4sp")
180 g4SpecialPhysics = argv[i + 1];
181 else if (std::string(argv[i]) == "--g4-macro" ||
182 std::string(argv[i]) == "-g4m")
183 g4Macro = argv[i + 1];
184 else if (std::string(argv[i]) == "--g4-macro2" ||
185 std::string(argv[i]) == "-g4m2")
186 g4Macro2 = argv[i + 1];
187 else if (std::string(argv[i]) == "--g4-vis-macro" ||
188 std::string(argv[i]) == "-g4vm")
189 g4VisMacro = argv[i + 1];
190 else if (std::string(argv[i]) == "--g4-session" ||
191 std::string(argv[i]) == "-g4s")
192 g4Session = argv[i + 1];
193#endif
194#ifdef USE_GEANT3
195 if (std::string(argv[i]) == "--g3-geometry" ||
196 std::string(argv[i]) == "-g3g")
197 g3Geometry = argv[i + 1];
198#endif
199 else if (std::string(argv[i]) == "--root-macro" ||
200 std::string(argv[i]) == "-rm")
201 rootMacro = argv[i + 1];
202 else if (std::string(argv[i]) == "--verbose" ||
203 std::string(argv[i]) == "-v")
204 verbose = argv[i + 1];
205 else {
206 PrintUsage("testE06");
207 return 1;
208 }
209 }
210
211 if (verbose == "yes") {
212#ifdef USE_GEANT4
213 PrintG4Configuration("testE06", g4Geometry, g4PhysicsList, g4SpecialPhysics,
214 g4Macro, g4Macro2, g4VisMacro, g4Session, rootMacro);
215#endif
216#ifdef USE_GEANT3
217 PrintG3Configuration("testE06", g3Geometry, rootMacro);
218#endif
219 }
220 //
221 // end of code to process arguments
222
223 // Create MC application (thread local)
224 Ex06MCApplication* appl =
225 new Ex06MCApplication("ExampleE06", "The exampleE06 MC application");
227 // appl->SetVerboseLevel(3);
228
229#ifdef USE_GEANT4
230 if (g4Geometry.find("VMC") != std::string::npos) {
231 appl->SetOldGeometry(true);
232 }
233#endif
234#ifdef USE_GEANT3
235 if (g3Geometry == "TGeant3") {
236 appl->SetOldGeometry(true);
237 }
238#endif
239
240#ifdef USE_GEANT4
241 // RunConfiguration for Geant4
242 TG4RunConfiguration* runConfiguration =
243 new TG4RunConfiguration(g4Geometry, g4PhysicsList, g4SpecialPhysics);
244
245 // TGeant4
246 // TO DO: pass g4session here
247 TGeant4* geant4 = new TGeant4(
248 "TGeant4", "The Geant4 Monte Carlo", runConfiguration, argc, argv);
249
250 // Customise Geant4 setting
251 // (verbose level, global range cut, ..)
252 if (g4Macro.size()) {
253 geant4->ProcessGeantMacro(g4Macro.data());
254 }
255#endif
256
257#ifdef USE_GEANT3
258 TGeant3* geant3 = 0;
259 if (g3Geometry == "TGeant3") {
260 geant3 = new TGeant3("C++ Interface to Geant3");
261 }
262 else if (g3Geometry == "TGeant3TGeo") {
263 geant3 = new TGeant3TGeo("C++ Interface to Geant3");
264 }
265 else {
266 PrintUsage("testE06");
267 return 1;
268 }
269 gMC->SetProcess("CKOV", 1);
270 gMC->SetCut("CUTELE", 10e-06);
271 gMC->SetCut("CUTGAM", 10e-06);
272 geant3->SetSWIT(4, 1000);
273 // reduce printing from GTREVE_ROOT (sets one printing per 1000 tracks)
274#endif
275
276 // Run example
277 if (!rootMacro.size()) {
278 // Initialize MC
279 appl->InitMC("");
280
281 // Activate storing tracks
282 // gMC->SetCollectTracks(kTRUE);
283
284#ifdef USE_GEANT4
285 // Customise Geant4 setting after initialization:
286 // Physics list
287 if (g4Macro.size()) {
288 geant4->ProcessGeantMacro(g4Macro2.data());
289 }
290 // Setting Geant4 visualization
291 if (g4VisMacro.size()) {
292 geant4->ProcessGeantMacro(g4VisMacro.data());
293 }
294#endif
295
296 // Run MC
297 appl->RunMC(5);
298 }
299 else {
300 // Run from Root macro
301 gROOT->Macro(rootMacro.data());
302 }
303
304 delete appl;
305}
Implementation of the TVirtualMCApplication.
void RunMC(Int_t nofEvents)
void InitMC(const char *setup)
void SetOldGeometry(Bool_t oldGeometry=kTRUE)
Ex06PrimaryGenerator * GetPrimaryGenerator() const
void SetNofPrimaries(Int_t nofPrimaries)
std::string verbose
Definition testE03c.cxx:75
std::string rootMacro
Definition testE03c.cxx:74