Loading...
Searching...
No Matches
clGeometry.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26/// \file g3tog4/clGeometry/clGeometry.cc
27/// \brief Main program of the g3tog4/clGeometry example
28//
29//
30//
31//
32
33// package includes
36
37// geant4 includes
38#include "G4RunManagerFactory.hh"
39
40#include "FTFP_BERT.hh"
41#include "G3VolTable.hh"
42#include "G4UImanager.hh"
43#include "G4ios.hh"
44
45#include "G4VisExecutive.hh"
46#include "G4UIExecutive.hh"
47
48//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49
50namespace {
51 void PrintUsage() {
52 G4cerr << " Usage: " << G4endl;
53 G4cerr
54 << "clGeometry <call_list_file> [-m macro ] [-u UIsession] [-t nThreads]"
55 << G4endl;
56 G4cerr
57 << " note: -t option is relevant only for multi-threaded mode."
58 << G4endl;
59 }
60}
61
62//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63
64int main(int argc, char** argv)
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}
Definition of the G3toG4ActionInitialization class.
Definition of the G3toG4DetectorConstruction class.
Action initialization class.
Detector construction class.
void PrintUsage()
int main()
Definition testCommon.cc:47

Applications | User Support | Publications | Collaboration