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: exampleN03.cc,v 1.36 2008/11/24 13:54:38 lgarnier Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | // |
---|
31 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
33 | |
---|
34 | #include "G4RunManager.hh" |
---|
35 | #include "G4UImanager.hh" |
---|
36 | |
---|
37 | #include "Randomize.hh" |
---|
38 | |
---|
39 | #include "ExN03DetectorConstruction.hh" |
---|
40 | #include "ExN03PhysicsList.hh" |
---|
41 | #include "ExN03PrimaryGeneratorAction.hh" |
---|
42 | #include "ExN03RunAction.hh" |
---|
43 | #include "ExN03EventAction.hh" |
---|
44 | #include "ExN03SteppingAction.hh" |
---|
45 | #include "ExN03SteppingVerbose.hh" |
---|
46 | |
---|
47 | #ifdef G4VIS_USE |
---|
48 | #include "G4VisExecutive.hh" |
---|
49 | #endif |
---|
50 | |
---|
51 | #if defined(G4UI_USE_TCSH) |
---|
52 | #include "G4UIterminal.hh" |
---|
53 | #include "G4UItcsh.hh" |
---|
54 | #elif defined(G4UI_USE_XM) |
---|
55 | #include "G4UIXm.hh" |
---|
56 | #elif defined(G4UI_USE_WIN32) |
---|
57 | #include "G4UIWin32.hh" |
---|
58 | #elif defined(G4UI_USE_QT) |
---|
59 | #include "G4UIQt.hh" |
---|
60 | #include "G4Qt.hh" |
---|
61 | #else |
---|
62 | #include "G4UIterminal.hh" |
---|
63 | #endif |
---|
64 | |
---|
65 | |
---|
66 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
67 | |
---|
68 | int main(int argc,char** argv) |
---|
69 | { |
---|
70 | // Choose the Random engine |
---|
71 | // |
---|
72 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); |
---|
73 | |
---|
74 | // User Verbose output class |
---|
75 | // |
---|
76 | G4VSteppingVerbose::SetInstance(new ExN03SteppingVerbose); |
---|
77 | |
---|
78 | // Construct the default run manager |
---|
79 | // |
---|
80 | G4RunManager * runManager = new G4RunManager; |
---|
81 | |
---|
82 | // Set mandatory initialization classes |
---|
83 | // |
---|
84 | ExN03DetectorConstruction* detector = new ExN03DetectorConstruction; |
---|
85 | runManager->SetUserInitialization(detector); |
---|
86 | // |
---|
87 | G4VUserPhysicsList* physics = new ExN03PhysicsList; |
---|
88 | runManager->SetUserInitialization(physics); |
---|
89 | |
---|
90 | // Set user action classes |
---|
91 | // |
---|
92 | G4VUserPrimaryGeneratorAction* gen_action = |
---|
93 | new ExN03PrimaryGeneratorAction(detector); |
---|
94 | runManager->SetUserAction(gen_action); |
---|
95 | // |
---|
96 | ExN03RunAction* run_action = new ExN03RunAction; |
---|
97 | runManager->SetUserAction(run_action); |
---|
98 | // |
---|
99 | ExN03EventAction* event_action = new ExN03EventAction(run_action); |
---|
100 | runManager->SetUserAction(event_action); |
---|
101 | // |
---|
102 | G4UserSteppingAction* stepping_action = |
---|
103 | new ExN03SteppingAction(detector, event_action); |
---|
104 | runManager->SetUserAction(stepping_action); |
---|
105 | |
---|
106 | // Initialize G4 kernel |
---|
107 | // |
---|
108 | runManager->Initialize(); |
---|
109 | |
---|
110 | #ifdef G4VIS_USE |
---|
111 | // Initialize visualization |
---|
112 | // |
---|
113 | G4VisManager* visManager = new G4VisExecutive; |
---|
114 | visManager->Initialize(); |
---|
115 | #endif |
---|
116 | |
---|
117 | // Get the pointer to the User Interface manager |
---|
118 | // |
---|
119 | G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
120 | |
---|
121 | if (argc!=1) // batch mode |
---|
122 | { |
---|
123 | G4String command = "/control/execute "; |
---|
124 | G4String fileName = argv[1]; |
---|
125 | UI->ApplyCommand(command+fileName); |
---|
126 | } |
---|
127 | else // interactive mode : define visualization UI terminal |
---|
128 | { |
---|
129 | G4UIsession* session = 0; |
---|
130 | #if defined(G4UI_USE_TCSH) |
---|
131 | session = new G4UIterminal(new G4UItcsh); |
---|
132 | #elif defined(G4UI_USE_XM) |
---|
133 | session = new G4UIXm(argc,argv); |
---|
134 | UI->ApplyCommand("/control/execute visTutor/gui.mac"); |
---|
135 | #elif defined(G4UI_USE_WIN32) |
---|
136 | session = new G4UIWin32(); |
---|
137 | UI->ApplyCommand("/control/execute visTutor/gui.mac"); |
---|
138 | #elif defined(G4UI_USE_QT) |
---|
139 | session = new G4UIQt(argc,argv); |
---|
140 | UI->ApplyCommand("/control/execute visTutor/gui.mac"); |
---|
141 | #else |
---|
142 | session = new G4UIterminal(); |
---|
143 | #endif |
---|
144 | #ifdef G4VIS_USE |
---|
145 | UI->ApplyCommand("/control/execute vis.mac"); |
---|
146 | #endif |
---|
147 | session->SessionStart(); |
---|
148 | delete session; |
---|
149 | } |
---|
150 | |
---|
151 | // Job termination |
---|
152 | // Free the store: user actions, physics_list and detector_description are |
---|
153 | // owned and deleted by the run manager, so they should not |
---|
154 | // be deleted in the main() program ! |
---|
155 | #ifdef G4VIS_USE |
---|
156 | delete visManager; |
---|
157 | #endif |
---|
158 | delete runManager; |
---|
159 | |
---|
160 | return 0; |
---|
161 | } |
---|
162 | |
---|
163 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|