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

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

#include "Ex01MCApplication.h"
#include "TROOT.h"
#include <iostream>
#include <string>
Include dependency graph for testE01.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 E01 test application.

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

Usage:

testE01
  [-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_E01.C("",kFALSE)'

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

Definition in file testE01.cxx.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Application main program.

Definition at line 131 of file testE01.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 = "emStandard";
146 std::string g4SpecialPhysics = "stepLimiter";
147 std::string g4Macro = "";
148 std::string g4VisMacro = "";
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("testE01");
193 return 1;
194 }
195 }
196
197 if (verbose == "yes") {
198#ifdef USE_GEANT4
199 PrintG4Configuration("testE01", g4Geometry, g4PhysicsList, g4SpecialPhysics,
200 g4Macro, g4VisMacro, g4Session, rootMacro);
201#endif
202#ifdef USE_GEANT3
203 PrintG3Configuration("testE01", g3Geometry, rootMacro);
204#endif
205 }
206 //
207 // end of code to process arguments
208
209 // Create MC application (thread local)
210 Ex01MCApplication* appl =
211 new Ex01MCApplication("ExampleE01", "The exampleE01 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 // Geant4 configuration tuning (can be run from a macro
240 geant4->ProcessGeantCommand("/mcVerbose/all 1");
241#endif
242
243#ifdef USE_GEANT3
244 TGeant3* geant3 = 0;
245 if (g3Geometry == "TGeant3") {
246 geant3 = new TGeant3("C++ Interface to Geant3");
247 }
248 else if (g3Geometry == "TGeant3TGeo") {
249 geant3 = new TGeant3TGeo("C++ Interface to Geant3");
250 }
251 else {
252 PrintUsage("testE01");
253 return 1;
254 }
255 geant3->SetHADR(0);
256#endif
257
258 // Run example
259 if (!rootMacro.size()) {
260 // Run from this main
261 appl->InitMC("");
262 appl->RunMC(1);
263 }
264 else {
265 // Run from Root macro
266 gROOT->Macro(rootMacro.data());
267 }
268
269 delete appl;
270}
Implementation of the TVirtualMCApplication.
void InitMC(const char *setup)
void RunMC(Int_t nofEvents)
void SetOldGeometry(Bool_t oldGeometry=kTRUE)
std::string verbose
Definition testE03c.cxx:75
std::string rootMacro
Definition testE03c.cxx:74