Loading...
Searching...
No Matches
Functions
clGeometry.cc File Reference

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

#include "G3toG4DetectorConstruction.hh"
#include "G3toG4ActionInitialization.hh"
#include "G4RunManagerFactory.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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 64 of file clGeometry.cc.

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

Applications | User Support | Publications | Collaboration