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: test19.cc,v 1.29 2007/01/05 16:00:48 allison Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | // |
---|
31 | |
---|
32 | // Usage: test19 [<session>] [<verbosity>] |
---|
33 | // Without verbosity, verbosity=warnings. |
---|
34 | // Without session, session=new G4UIterminal(), or if G4UI_USE_TCSH is set |
---|
35 | // session=new G4UIterminal(new G4UItcsh), |
---|
36 | |
---|
37 | #include <stdio.h> |
---|
38 | #include <ctype.h> |
---|
39 | #include <stdlib.h> |
---|
40 | |
---|
41 | #include "globals.hh" |
---|
42 | //#include "SharedSolidDetectorConstruction.hh" |
---|
43 | #include "test19DetectorConstruction.hh" |
---|
44 | #include "MyPhysicsList.hh" |
---|
45 | #include "MyRunAction.hh" |
---|
46 | #include "MyPrimaryGeneratorAction.hh" |
---|
47 | #include "MyEventAction.hh" |
---|
48 | #include "MySteppingAction.hh" |
---|
49 | |
---|
50 | #include "G4UIterminal.hh" |
---|
51 | #ifdef G4UI_USE_TCSH |
---|
52 | #include "G4UItcsh.hh" |
---|
53 | #endif |
---|
54 | #include "G4UIGAG.hh" |
---|
55 | #ifdef G4UI_USE_WO |
---|
56 | #include "G4UIWo.hh" |
---|
57 | #endif |
---|
58 | #ifdef G4UI_USE_XM |
---|
59 | #include "G4UIXm.hh" |
---|
60 | #endif |
---|
61 | #ifdef G4UI_USE_XAW |
---|
62 | #include "G4UIXaw.hh" |
---|
63 | #endif |
---|
64 | #ifdef G4UI_USE_WIN32 |
---|
65 | #include "G4UIWin32.hh" |
---|
66 | #endif |
---|
67 | |
---|
68 | #include "G4RunManager.hh" |
---|
69 | |
---|
70 | #ifdef G4VIS_USE |
---|
71 | #include "G4VisExecutive.hh" |
---|
72 | // G4VisExecutive is a G4VisManager that implements graphics system |
---|
73 | // registration in the user domain. |
---|
74 | #include "G4XXX.hh" |
---|
75 | #include "G4XXXFile.hh" |
---|
76 | #include "G4XXXStored.hh" |
---|
77 | #ifdef G4VIS_USE_XXXSG |
---|
78 | #include "G4XXXSG.hh" |
---|
79 | #endif |
---|
80 | #endif |
---|
81 | |
---|
82 | |
---|
83 | #ifdef G4UI_USE_WIN32 |
---|
84 | #include <windows.h> |
---|
85 | int WINAPI WinMain ( |
---|
86 | HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow) { |
---|
87 | #else |
---|
88 | int main (int argc, char** argv) { |
---|
89 | #endif |
---|
90 | |
---|
91 | G4String verbosityString("warnings"); |
---|
92 | #ifndef G4UI_USE_WIN32 |
---|
93 | if ((argc >= 3)) verbosityString = argv[2]; |
---|
94 | #endif |
---|
95 | |
---|
96 | // Choose (G)UI. |
---|
97 | G4UIsession* session; |
---|
98 | #ifdef G4UI_USE_WIN32 |
---|
99 | session = new G4UIWin32 (hInstance,hPrevInstance,lpszCmdLine,nCmdShow); |
---|
100 | #else |
---|
101 | if (argc >= 2) { |
---|
102 | #ifdef G4UI_USE_TCSH |
---|
103 | if (strcmp (argv[1], "tcsh")==0) session = |
---|
104 | new G4UIterminal(new G4UItcsh); |
---|
105 | #endif |
---|
106 | #ifdef G4UI_USE_WO |
---|
107 | else if (strcmp (argv[1], "Wo")==0) session = new G4UIWo (argc, argv); |
---|
108 | #endif |
---|
109 | #ifdef G4UI_USE_XM |
---|
110 | else if (strcmp (argv[1], "Xm")==0) session = new G4UIXm (argc, argv); |
---|
111 | #endif |
---|
112 | #ifdef G4UI_USE_XAW |
---|
113 | else if (strcmp (argv[1], "Xaw")==0) session = new G4UIXaw (argc, argv); |
---|
114 | #endif |
---|
115 | else if (strcmp (argv[1], "gag")==0) session = new G4UIGAG ; |
---|
116 | else session = |
---|
117 | new G4UIterminal(); |
---|
118 | } |
---|
119 | else session = |
---|
120 | #ifdef G4UI_USE_TCSH |
---|
121 | new G4UIterminal(new G4UItcsh); |
---|
122 | #else |
---|
123 | new G4UIterminal(); |
---|
124 | #endif |
---|
125 | #endif |
---|
126 | G4UImanager::GetUIpointer()->SetSession(session); //So that Pause works.. |
---|
127 | |
---|
128 | // Run manager |
---|
129 | G4cout << "RunManager is constructing...." << G4endl; |
---|
130 | G4RunManager * runManager = new G4RunManager; |
---|
131 | |
---|
132 | // User initialization classes |
---|
133 | runManager -> SetUserInitialization (new test19DetectorConstruction); |
---|
134 | //runManager -> SetUserInitialization (new SharedSolidDetectorConstruction); |
---|
135 | runManager -> SetUserInitialization (new MyPhysicsList); |
---|
136 | |
---|
137 | // UserAction classes. |
---|
138 | runManager -> SetUserAction (new MyRunAction); |
---|
139 | runManager -> SetUserAction (new MyPrimaryGeneratorAction); |
---|
140 | runManager -> SetUserAction (new MyEventAction); |
---|
141 | runManager -> SetUserAction (new MySteppingAction); |
---|
142 | |
---|
143 | //Initialize G4 kernel |
---|
144 | //runManager->Initialize(); // Do this with /run/initialize so that |
---|
145 | // you can, optionally, choose detector |
---|
146 | // (/test19det/detector N) first. |
---|
147 | |
---|
148 | #ifdef G4VIS_USE |
---|
149 | // Instantiate and initialise Visualization Manager. |
---|
150 | G4VisManager* visManager = new G4VisExecutive; |
---|
151 | visManager -> SetVerboseLevel (verbosityString); |
---|
152 | visManager -> RegisterGraphicsSystem(new G4XXX); |
---|
153 | visManager -> RegisterGraphicsSystem(new G4XXXFile); |
---|
154 | visManager -> RegisterGraphicsSystem(new G4XXXStored); |
---|
155 | #ifdef G4VIS_USE_XXXSG |
---|
156 | visManager -> RegisterGraphicsSystem(new G4XXXSG); |
---|
157 | #endif |
---|
158 | visManager -> Initialize (); |
---|
159 | #endif |
---|
160 | |
---|
161 | G4UImanager* UI = G4UImanager::GetUIpointer (); |
---|
162 | |
---|
163 | #ifdef G4UI_USE_WIN32 |
---|
164 | G4cout << "Reading win32.g4m file...." << G4endl; |
---|
165 | UI -> ApplyCommand ("/control/execute win32.g4m"); |
---|
166 | #else |
---|
167 | G4cout << "Reading test19.g4m file...." << G4endl; |
---|
168 | UI -> ApplyCommand ("/control/execute test19.g4m"); |
---|
169 | #endif |
---|
170 | |
---|
171 | G4cout << |
---|
172 | "Choose a detector with /test19det/detector (or let default be" |
---|
173 | " constructed)." |
---|
174 | << G4endl; |
---|
175 | |
---|
176 | // Start an interactive session. |
---|
177 | session -> SessionStart(); |
---|
178 | |
---|
179 | #ifdef G4VIS_USE |
---|
180 | G4cout << "vis_test19: Deleting vis manager..." << G4endl; |
---|
181 | delete visManager; |
---|
182 | G4cout << "vis_test19: Vis manager deleted." << G4endl; |
---|
183 | #endif |
---|
184 | G4cout << "vis_test19: Deleting run manager..." << G4endl; |
---|
185 | delete runManager; |
---|
186 | G4cout << "vis_test19: Run manager deleted." << G4endl; |
---|
187 | G4cout << "vis_test19: Deleting session..." << G4endl; |
---|
188 | delete session; |
---|
189 | G4cout << "vis_test19: Session deleted." << G4endl; |
---|
190 | |
---|
191 | return 0; |
---|
192 | } |
---|