LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.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 68 of file clGeometry.cc.

References in, PrintUsage(), and session.

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