Loading...
Searching...
No Matches
Functions | Variables
exampleVecGeomNav.cc File Reference
#include <iostream>
#include <iomanip>
#include "G4RunManager.hh"
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "G4UIsession.hh"
#include "G4UIterminal.hh"
#include "G4VModularPhysicsList.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"
#include "Randomize.hh"
#include "VG01DetectorConstruction.hh"
#include "VG01ActionInitialization.hh"
#include "VG01SteppingVerboseWithDir.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"

Go to the source code of this file.

Functions

void GetInputArguments (int argc, char **argv)
 
void PrintUsage ()
 
int main (int argc, char **argv)
 
void horizontal_line (char c)
 

Variables

static G4bool parUseVecGeom = true
 
static G4bool parCompareG4 = false
 
static G4bool parInteractive = false
 
static std::string parMacroFileName = ""
 
static std::string parGDMLFile = "TestNTST.gdml"
 

Function Documentation

◆ GetInputArguments()

void GetInputArguments ( int  argc,
char **  argv 
)

Definition at line 179 of file exampleVecGeomNav.cc.

179 {
180 // process arguments
181 if (argc == 1) {
182 PrintUsage();
183 exit(0);
184 }
185 if (argc == 2) {
186 parMacroFileName = argv[1];
187 G4cout << " argc = 2 -- Filename = " << parMacroFileName << G4endl;
188 return;
189 }
190
191 // Adapted from examples/basic/B4/exampleB4a.cc
192 for ( G4int i=1; i<argc; ++i ) {
193 if ( G4String(argv[i]) == "-m" ) {
194 if( ++i < argc ) {
195 parMacroFileName = argv[i];
196 G4cout << " arg-parsing: Macro file name= " << parMacroFileName << G4endl;
197 }
198 else{
199 G4cerr << " Parse Error: '-m' cannot be last argument. Use it : -m <filename>" << G4endl;
200 PrintUsage();
201 exit(1);
202 }
203 }
204 else if ( G4String(argv[i]) == "-g" ) {
205 if( ++i < argc ) { parGDMLFile = argv[i];
206 G4cout << " arg-parsing: GDML file name= " << parGDMLFile << G4endl;
207 }
208 else{
209 G4cerr << " Parse Error: '-m' cannot be last argument. Use it : -m <filename>" << G4endl;
210 PrintUsage();
211 exit(1);
212 }
213 }
214 else if ( G4String(argv[i]) == "-v" ) { parUseVecGeom = true; }
215 else if ( G4String(argv[i]) == "-o" ) { parUseVecGeom = false; }
216 else if ( G4String(argv[i]) == "-c" ) { parCompareG4 = true; parUseVecGeom= true; }
217 else {
218 G4cerr << " Unknown argument : " << argv[i] << G4endl;
219 PrintUsage();
220 exit(1);
221 }
222 }
223
224 // check if mandatory Geant4 macro file was provided
225 if (parMacroFileName=="" && !parInteractive ) {
226 G4cerr << " *** ERROR : either interactive mode or a Geant4 macro file is required. "
227 << G4endl;
228 PrintUsage();
229 exit(-1);
230 }
231}
static G4bool parUseVecGeom
static G4bool parInteractive
static G4bool parCompareG4
static std::string parGDMLFile
void PrintUsage()
static std::string parMacroFileName

◆ PrintUsage()

void PrintUsage ( )

Definition at line 156 of file exampleVecGeomNav.cc.

156 {
157 horizontal_line('=');
158 std::cout << " Geant4 application to demonstrate interface to VecGeom Navigation. \n"
159 << std::endl
160 << " Two modes: \n\n"
161 << " * 1 parameter this is treated as Geant4 macro file \n"
162 << " \n"
163 << " * Multiple Parameters: \n"
164 << " at least one of the following: \n"
165 << " -m : the standard Geant4 macro file \n"
166 << " -i : interactive (after batch, if any) \n"
167 << " optionally one of the following: \n"
168 << " -v : flag ==> run using VecGeom navigation (default). \n"
169 << " -o : flag ==> run using Geant4 navigation. \n"
170 << " -c : flag ==> compare VecGeom and Geant4 navigation"
171 << " (and report differences.) \n"
172 << " and other(s): \n"
173 << " -g : GDML file with geometry \n"
174 << "\n"
175 << std::endl;
176 horizontal_line('=');
177}
void horizontal_line(char c)

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 64 of file exampleVecGeomNav.cc.

64 {
65 //
66 // get input arguments
67 GetInputArguments(argc, argv);
68 G4cout<< " ========== Running exampleVecGeomNav ================ " << G4endl
69 << " GDML geometry file = " << parGDMLFile << G4endl
70 << " Geant4 macro = " << parMacroFileName << G4endl
71 << " Use VecGeom (VG) navigation = " << parUseVecGeom << G4endl
72 << " Compare G4 vs VG navigation = " << parCompareG4 << G4endl
73 << " ===================================================== " << G4endl;
74
75 // Use custom stepping verbosity
76 G4VSteppingVerbose::SetInstance( new VG01SteppingVerboseWithDir() );
77
78 // Construct the run manager
79 //
80 G4RunManager* runManager
81 = G4RunManagerFactory::CreateRunManager( G4RunManagerType::Serial);
82 // or G4RunManagerType::Default to get Task or Multithreading
83
84 // set mandatory initialization classes
85 //
86 // 1. Detector construction
87 //
91 runManager->SetUserInitialization(detector);
92
93 // 2. Physics list
94 //
95 G4VModularPhysicsList* physicsList = new FTFP_BERT;
96 physicsList->RegisterPhysics(new G4StepLimiterPhysics());
97 runManager->SetUserInitialization(physicsList);
98
99 // 3. User action
100 //
101 runManager->SetUserInitialization(new VG01ActionInitialization());
102
103 // 4. Run the simulation in batch mode, except if macroFile == "-"
104 //
105 G4UImanager* UImgr = G4UImanager::GetUIpointer();
106 G4String command = "/control/execute ";
107 if( parMacroFileName != "-")
108 UImgr->ApplyCommand(command+parMacroFileName);
109
110 // 5. Run the simulation in Interactive mode if requested ( flag: -i )
111 //
112 if( parInteractive )
113 {
114 G4UIExecutive* uiExec = 0;
115 uiExec = new G4UIExecutive(argc, argv);
116
117 // Initialize visualization
118 //
119 G4VisManager* visManager = new G4VisExecutive;
120 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
121 // G4VisManager* visManager = new G4VisExecutive("Quiet");
122 visManager->Initialize();
123
124 // UImgr->ApplyCommand("/control/execute init_vis.mac");
125
126 // interactive mode
127 uiExec->SessionStart();
128
129 // Cleanup
130 delete uiExec;
131 delete visManager;
132 }
133 else
134 {
135
136 // Print out the final random number - for batch only runs
137 G4cout << G4endl
138 << " ================================================================= " << G4endl
139 << " Final random number = " << G4UniformRand() << G4endl
140 << " ================================================================= " << G4endl
141 << G4endl;
142 }
143 //
144
145 // Delete the RunManager
146 delete runManager;
147 return 0;
148}
Action initialization class.
void SetGDMLFileName(const G4String &gdmlfile)
void GetInputArguments(int argc, char **argv)

◆ horizontal_line()

void horizontal_line ( char  c)

Definition at line 150 of file exampleVecGeomNav.cc.

151{
152 std::cout <<"\n " << std::setw(100) << std::setfill(c)
153 << "" << std::setfill(' ') << std::endl;
154}

Variable Documentation

◆ parUseVecGeom

G4bool parUseVecGeom = true
static

Definition at line 55 of file exampleVecGeomNav.cc.

◆ parCompareG4

G4bool parCompareG4 = false
static

Definition at line 56 of file exampleVecGeomNav.cc.

◆ parInteractive

G4bool parInteractive = false
static

Definition at line 57 of file exampleVecGeomNav.cc.

◆ parMacroFileName

std::string parMacroFileName = ""
static

Definition at line 58 of file exampleVecGeomNav.cc.

◆ parGDMLFile

std::string parGDMLFile = "TestNTST.gdml"
static

Definition at line 59 of file exampleVecGeomNav.cc.


Applications | User Support | Publications | Collaboration