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

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

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

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

Usage:
testMonopole
  [-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
  [-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_Monopole_1.C("",kFALSE)'
Date
06/03/2019
Author
I. Hrivnacova; IPN, Orsay

Definition in file testMonopole.cxx.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Application main program.

Definition at line 115 of file testMonopole.cxx.

116{
117 // Initialize Root threading.
118 // (Multi-threading is triggered automatically if Geant4 was built
119 // in MT mode.)
120#ifdef G4MULTITHREADED
121 ROOT::EnableThreadSafety();
122#endif
123
124 // Process arguments
125 // This code is generic with the exception of the start values and
126 // the program name
127#ifdef USE_GEANT4
128 std::string g4Geometry = "geomRootToGeant4";
129 std::string g4PhysicsList = "FTFP_BERT+monopole";
130 std::string g4SpecialPhysics = "stepLimiter";
131 std::string g4Macro = "g4config.in";
132 std::string g4Macro2 = "g4config2.in";
133 // std::string g4VisMacro = "g4vis.in";
134 std::string g4VisMacro = "";
135 std::string g4Session = "";
136#endif
137 std::string rootMacro = "";
138 std::string verbose = "yes";
139
140 for (Int_t i = 1; i < argc; i = i + 2) {
141 std::cout << "processing " << argv[i] << " with " << argv[i + 1]
142 << std::endl;
143#ifdef USE_GEANT4
144 if (std::string(argv[i]) == "--g4-geometry" ||
145 std::string(argv[i]) == "-g4g")
146 g4Geometry = argv[i + 1];
147 else if (std::string(argv[i]) == "--g4-physics-list" ||
148 std::string(argv[i]) == "-g4pl")
149 g4PhysicsList = argv[i + 1];
150 else if (std::string(argv[i]) == "--g4-special-physics" ||
151 std::string(argv[i]) == "-g4sp")
152 g4SpecialPhysics = argv[i + 1];
153 else if (std::string(argv[i]) == "--g4-macro" ||
154 std::string(argv[i]) == "-g4m")
155 g4Macro = argv[i + 1];
156 else if (std::string(argv[i]) == "--g4-vis-macro" ||
157 std::string(argv[i]) == "-g4vm")
158 g4VisMacro = argv[i + 1];
159 else if (std::string(argv[i]) == "--g4-session" ||
160 std::string(argv[i]) == "-g4s")
161 g4Session = argv[i + 1];
162 else if (std::string(argv[i]) == "--root-macro" ||
163 std::string(argv[i]) == "-rm")
164 rootMacro = argv[i + 1];
165#else
166 if (std::string(argv[i]) == "--root-macro" || std::string(argv[i]) == "-rm")
167 rootMacro = argv[i + 1];
168#endif
169 else if (std::string(argv[i]) == "--verbose" ||
170 std::string(argv[i]) == "-v")
171 verbose = argv[i + 1];
172 else {
173 PrintUsage("testMonopole");
174 return 1;
175 }
176 }
177
178 if (verbose == "yes") {
179#ifdef USE_GEANT4
180 PrintG4Configuration("testMonopole", g4Geometry, g4PhysicsList,
181 g4SpecialPhysics, g4Macro, g4Macro2, g4VisMacro, g4Session, rootMacro);
182#endif
183 }
184 //
185 // end of code to process arguments
186
187 // Create MC application (thread local)
189 "ExampleMonopole", "The example Monopole MC MC application");
190
191 // Set detector parameters
192 // /testex/det/setMat G4_Si
193 // /testex/det/setSizeX 10 cm
194 // /testex/det/setSizeYZ 20 cm
195 // /testex/det/setStepSize 0.2 mm
196 // /testex/run/binSize 0.2 mm
199 detector->SetAbsorberMaterial("Si");
200 detector->SetAbsorberSizeX(10);
201 detector->SetAbsorberSizeYZ(20);
202 detector->SetMaxStepSize(0.02);
203 appl->SetBinSize(0.02);
204
205#ifdef USE_GEANT4
206 // RunConfiguration for Geant4
207 TG4RunConfiguration* runConfiguration = new TG4RunConfiguration(
208 g4Geometry, g4PhysicsList, g4SpecialPhysics, false, false);
209
210 // TGeant4
211 TGeant4* geant4 = new TGeant4(
212 "TGeant4", "The Geant4 Monte Carlo", runConfiguration, argc, argv);
213
214 // Customise Geant4 setting
215 // (verbose level, global range cut, ..)
216 if (g4Macro.size()) {
217 geant4->ProcessGeantMacro(g4Macro.data());
218 }
219#endif
220
221 // Run example
222 if (!rootMacro.size()) {
223 appl->InitMC("");
224#ifdef USE_GEANT4
225 if (g4Macro2.size()) {
226 // Customise Geant4 setting after initialization:
227 geant4->ProcessGeantMacro("g4config2.in");
228 }
229
230 // Setting Geant4 visualization
231 if (g4VisMacro.size()) {
232 geant4->ProcessGeantMacro(g4VisMacro.data());
233 }
234#endif
235 appl->RunMC(100);
236 }
237 else {
238 // Run from Root macro
239 gROOT->Macro(rootMacro.data());
240 }
241
242 delete appl;
243}
The detector construction (via TGeo )
void SetAbsorberMaterial(const TString &name)
Implementation of the TVirtualMCApplication.
void InitMC(const char *setup)
void SetBinSize(Double_t binSize)
void RunMC(Int_t nofEvents)
DetectorConstruction * GetDetectorConstruction() const
std::string verbose
Definition testE03c.cxx:75
std::string rootMacro
Definition testE03c.cxx:74