Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
clGeometry.cc
이 파일의 문서화 페이지로 가기
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 //
28 //
29 //
30 // $Id: clGeometry.cc 106392 2017-10-09 09:44:29Z gcosmo $
31 //
32 //
33 
34 // package includes
37 
38 // geant4 includes
39 #ifdef G4MULTITHREADED
40 #include "G4MTRunManager.hh"
41 #else
42 #include "G4RunManager.hh"
43 #endif
44 
45 #include "FTFP_BERT.hh"
46 #include "G3VolTable.hh"
47 #include "G4UImanager.hh"
48 #include "G4ios.hh"
49 
50 #include "G4VisExecutive.hh"
51 #include "G4UIExecutive.hh"
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
55 namespace {
56  void PrintUsage() {
57  G4cerr << " Usage: " << G4endl;
58  G4cerr
59  << "clGeometry <call_list_file> [-m macro ] [-u UIsession] [-t nThreads]"
60  << G4endl;
61  G4cerr
62  << " note: -t option is available only for multi-threaded mode."
63  << G4endl;
64  }
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
69 int main(int argc, char** argv)
70 {
71  // Evaluate arguments
72  //
73  G4cout << "argc " << argc << G4endl;
74  if ( argc < 2 || argc > 8 ) {
75  PrintUsage();
76  return 1;
77  }
78 
79  G4String inFile;
80  G4String macro = "";
82 #ifdef G4MULTITHREADED
83  G4int nofThreads = 4;
84 #endif
85 
86  // First argument is mandatory
87  inFile = argv[1];
88  G4cout << "Geometry data file: " << inFile << G4endl;
89  std::ifstream in(inFile);
90  if ( ! in ) {
91  G4cerr << "Cannot open input file \"" << inFile << "\"" << G4endl;
92  return EXIT_FAILURE;
93  }
94 
95  // Optional arguments
96  for ( G4int i=2; i<argc; i=i+2 ) {
97  G4cout << "evaluating " << argv[i] << G4endl;
98  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
99  else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
100 #ifdef G4MULTITHREADED
101  else if ( G4String(argv[i]) == "-t" ) {
102  nofThreads = G4UIcommand::ConvertToInt(argv[i+1]);
103  }
104 #endif
105  else {
106  PrintUsage();
107  return 1;
108  }
109  }
110 
111  // Detect interactive mode (if no macro provided) and define UI session
112  //
113  G4UIExecutive* ui = nullptr;
114  if ( ! macro.size() ) {
115  ui = new G4UIExecutive(argc, argv, session);
116  }
117 
118  // Construct the default run manager
119 #ifdef G4MULTITHREADED
120  G4MTRunManager* runManager = new G4MTRunManager;
121  runManager->SetNumberOfThreads(nofThreads);
122 #else
123  G4RunManager* runManager = new G4RunManager;
124 #endif
125 
126  // Set mandatory initialization classes
127  //
128  // Detector construction
129  runManager->SetUserInitialization(new G3toG4DetectorConstruction(inFile));
130 
131  // Physics list
132  runManager->SetUserInitialization(new FTFP_BERT);
133 
134  // User action initialization
136 
137  // Initialize visualization
138  //
139  auto visManager = new G4VisExecutive;
140  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
141  // G4VisManager* visManager = new G4VisExecutive("Quiet");
142  visManager->Initialize();
143 
144  // Get the pointer to the User Interface manager
145  auto UImanager = G4UImanager::GetUIpointer();
146 
147  // Process macro or start UI session
148  //
149  if ( macro.size() ) {
150  // batch mode
151  G4String command = "/control/execute ";
152  UImanager->ApplyCommand(command+macro);
153  }
154  else {
155  // interactive mode : define UI session
156  UImanager->ApplyCommand("/control/execute init_vis.mac");
157  ui->SessionStart();
158  delete ui;
159  }
160 
161  // Job termination
162  // Free the store: user actions, physics_list and detector_description are
163  // owned and deleted by the run manager, so they should not be deleted
164  // in the main() program !
165 
166  delete visManager;
167  delete runManager;
168 }
void SetNumberOfThreads(G4int n)
static G4UIterminal * session
#define G4endl
Definition: G4ios.hh:61
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:449
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
Definition of the G3toG4ActionInitialization class.
int main(int argc, char **argv)
Definition: genwindef.cc:359
G4GLOB_DLL std::ostream G4cerr
int G4int
Definition: G4Types.hh:78
ifstream in
Definition: comparison.C:7
G4GLOB_DLL std::ostream G4cout
void Initialize()
Definition of the G3toG4DetectorConstruction class.