LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
clGeometry.cc File Reference

Main program of the g3tog4/clGeometry example. More...

#include "G3toG4DetectorConstruction.hh"
#include "G3toG4ActionInitialization.hh"
#include "G4RunManager.hh"
#include "FTFP_BERT.hh"
#include "G3VolTable.hh"
#include "G4UImanager.hh"
#include "G4ios.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the g3tog4/clGeometry example.

Definition in file clGeometry.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 77 of file clGeometry.cc.

References in, PrintUsage(), and session.

78 {
79  // Evaluate arguments
80  //
81  G4cout << "argc " << argc << G4endl;
82  if ( argc < 2 || argc > 8 ) {
83  PrintUsage();
84  return 1;
85  }
86 
87  G4String inFile;
88  G4String macro = "";
90 #ifdef G4MULTITHREADED
91  G4int nofThreads = 4;
92 #endif
93 
94  // First argument is mandatory
95  inFile = argv[1];
96  G4cout << "Geometry data file: " << inFile << G4endl;
97  std::ifstream in(inFile);
98  if ( ! in ) {
99  G4cerr << "Cannot open input file \"" << inFile << "\"" << G4endl;
100  return EXIT_FAILURE;
101  }
102 
103  // Optional arguments
104  for ( G4int i=2; i<argc; i=i+2 ) {
105  G4cout << "evaluating " << argv[i] << G4endl;
106  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
107  else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
108 #ifdef G4MULTITHREADED
109  else if ( G4String(argv[i]) == "-t" ) {
110  nofThreads = G4UIcommand::ConvertToInt(argv[i+1]);
111  }
112 #endif
113  else {
114  PrintUsage();
115  return 1;
116  }
117  }
118 
119  // Construct the default run manager
120 #ifdef G4MULTITHREADED
121  G4MTRunManager* runManager = new G4MTRunManager;
122  runManager->SetNumberOfThreads(nofThreads);
123 #else
124  G4RunManager* runManager = new G4RunManager;
125 #endif
126 
127  // Set mandatory initialization classes
128  //
129  // Detector construction
130  runManager->SetUserInitialization(new G3toG4DetectorConstruction(inFile));
131 
132  // Physics list
133  runManager->SetUserInitialization(new FTFP_BERT);
134 
135  // User action initialization
136  runManager->SetUserInitialization(new G3toG4ActionInitialization());
137 
138  // Initialize G4 kernel
139  //
140  runManager->Initialize();
141 
142  //--------------------
143  // Visualization & UI
144  //--------------------
145 
146 #ifdef G4VIS_USE
147  // Initialize visualization
148  G4VisManager* visManager = new G4VisExecutive;
149  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
150  // G4VisManager* visManager = new G4VisExecutive("Quiet");
151  visManager->Initialize();
152 #endif
153 
154  // Get the pointer to the User Interface manager
155  G4UImanager* uiManager = G4UImanager::GetUIpointer();
156 
157  if ( macro.size() ) {
158  // batch mode
159  G4String command = "/control/execute ";
160  uiManager->ApplyCommand(command+macro);
161  }
162  else {
163  // interactive mode : define UI session
164 #ifdef G4UI_USE
165  G4UIExecutive* ui = new G4UIExecutive(argc, argv, session);
166 #ifdef G4VIS_USE
167  uiManager->ApplyCommand("/control/execute init_vis.mac");
168 #else
169  uiManager->ApplyCommand("/control/execute init.mac");
170 #endif
171  ui->SessionStart();
172  delete ui;
173 #endif
174  }
175 
176  // Job termination
177  // Free the store: user actions, physics_list and detector_description are
178  // owned and deleted by the run manager, so they should not be deleted
179  // in the main() program !
180 
181 #ifdef G4VIS_USE
182  delete visManager;
183 #endif
184  delete runManager;
185 
186  return 0;
187 }
static G4UIterminal * session
void PrintUsage()
ifstream in
Definition: comparison.C:7