source: trunk/examples/extended/g3tog4/clGeometry/clGeometry.cc@ 1330

Last change on this file since 1330 was 1230, checked in by garnier, 16 years ago

update to geant4.9.3

File size: 5.0 KB
RevLine 
[807]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//
27// $Id: clGeometry.cc,v 1.7 2006/06/29 17:20:00 gunter Exp $
[1230]28// GEANT4 tag $Name: geant4-09-03-cand-01 $
[807]29//
30//
31
32// controls whether drawing is to be Done or not
33
34#include <fstream>
35#include <cmath>
36#include "G4ios.hh"
37
38// package includes
39
40#include "G3toG4DetectorConstruction.hh"
41#include "G3toG4RunAction.hh"
42#include "G3toG4PrimaryGeneratorAction.hh"
43#include "G3toG4PhysicsList.hh"
44#include "G3toG4EventAction.hh"
45#include "G4LogicalVolume.hh"
46#include "G3VolTable.hh"
47
48// geant4 includes
49
50#include "G4RunManager.hh"
51#include "G4UImanager.hh"
52#include "G4UIterminal.hh"
53
54// visualization
55#ifdef G4VIS_USE
56#include "G4VisExecutive.hh"
57#endif
58
59int main(int argc, char** argv)
60{
61 G4String inFile;
62 G4String macroFile = "";
63
64 if (argc < 2) {
65 G4cerr << "clGeometry: Correct syntax: clGeometry <call_list_file> [ <macro_file> ]"
66 << G4endl;
67 G4cerr << "If only one argument is specified, interactive mode will be "
68 << "entered." << G4endl << "The second argument, if specified, is "
69 << "the name of the macro file (batch mode)." << G4endl;
70
71 return EXIT_FAILURE;
72 }
73 if (argc >= 2) {
74 // Process the command line
75 inFile = argv[1];
76 std::ifstream in(inFile);
77 if (!in) {
78 G4cerr << "Cannot open input file \"" << inFile << "\"" << G4endl;
79 return EXIT_FAILURE;
80 }
81 }
82 if (argc >= 3) {
83 macroFile = argv[2];
84 std::ifstream mac(macroFile);
85 if (!mac) {
86 G4cout << "Cannot open macro file """ << macroFile << """" << G4endl;
87 return 2;
88 }
89 }
90 if (argc >= 4) {
91 G4cerr << "Too many command line arguments (" << argc <<")" << G4endl;
92 return EXIT_FAILURE;
93 }
94
95 // Construct the default run manager
96 G4RunManager* RunManager = new G4RunManager;
97
98 // set mandatory initialization classes
99 RunManager->SetUserInitialization(new G3toG4DetectorConstruction(inFile));
100
101 G3toG4PhysicsList* thePhysicsList = new G3toG4PhysicsList;
102
103 // set verbosity of PhysicsList
104 thePhysicsList->SetVerboseLevel(2);
105 RunManager->SetUserInitialization(thePhysicsList);
106
107 //----------------
108 // Visualization:
109 //----------------
110
111#ifdef G4VIS_USE
112 G4VisManager* VisManager = new G4VisExecutive;
113 VisManager -> Initialize();
114#endif
115
116 // set user action classes
117
118 RunManager->SetUserAction(new G3toG4RunAction);
119
120 G3toG4EventAction* theEventAction = new G3toG4EventAction;
121 theEventAction->SetDrawFlag("all");
122 RunManager->SetUserAction(theEventAction);
123
124 RunManager->SetUserAction(new G3toG4PrimaryGeneratorAction);
125
126 // the pointer to the User Interface manager
127 G4UImanager* UI = G4UImanager::GetUIpointer();
128
129 // set some additional defaults and initial actions
130
131 UI->ApplyCommand("/control/verbose 1");
132 UI->ApplyCommand("/run/verbose 1");
133 UI->ApplyCommand("/tracking/verbose 1");
134 UI->ApplyCommand("/tracking/storeTrajectory 1");
135 UI->ApplyCommand("/run/initialize");
136
137 G4bool batch_mode = macroFile != "";
138
139 if(!batch_mode) {
140 G4UIsession * session = new G4UIterminal;
141 if (session != 0) {
142 session->SessionStart();
143 delete session;
144 // G4cout << "deleted G4UITerminal..." << G4endl;
145 }
146 }
147 else {
148 // Batch mode
149 G4String command = "/control/execute ";
150 UI->ApplyCommand(command+macroFile);
151 }
152#ifdef G4VIS_USE
153 if (VisManager !=0) delete VisManager;
154#endif
155 delete RunManager;
156 return EXIT_SUCCESS;
157}
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
Note: See TracBrowser for help on using the repository browser.