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.37 2009/10/30 15:06:01 allison Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
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 "qcoreapplication.h" |
---|
40 | |
---|
41 | #include "ExN03DetectorConstruction.hh" |
---|
42 | #include "ExN03PhysicsList.hh" |
---|
43 | #include "ExN03PrimaryGeneratorAction.hh" |
---|
44 | #include "ExN03RunAction.hh" |
---|
45 | #include "ExN03EventAction.hh" |
---|
46 | #include "ExN03SteppingAction.hh" |
---|
47 | #include "ExN03SteppingVerbose.hh" |
---|
48 | |
---|
49 | #ifdef G4VIS_USE |
---|
50 | #include "G4VisExecutive.hh" |
---|
51 | #endif |
---|
52 | |
---|
53 | #ifdef G4UI_USE |
---|
54 | #include "G4UIExecutive.hh" |
---|
55 | #endif |
---|
56 | |
---|
57 | //#define MAC_OSX_APP 1 |
---|
58 | |
---|
59 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
60 | |
---|
61 | int main(int argc,char** argv) |
---|
62 | { |
---|
63 | // Choose the Random engine |
---|
64 | // |
---|
65 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); |
---|
66 | |
---|
67 | // User Verbose output class |
---|
68 | // |
---|
69 | G4VSteppingVerbose::SetInstance(new ExN03SteppingVerbose); |
---|
70 | |
---|
71 | // Construct the default run manager |
---|
72 | // |
---|
73 | G4RunManager * runManager = new G4RunManager; |
---|
74 | |
---|
75 | // Set mandatory initialization classes |
---|
76 | // |
---|
77 | ExN03DetectorConstruction* detector = new ExN03DetectorConstruction; |
---|
78 | runManager->SetUserInitialization(detector); |
---|
79 | // |
---|
80 | G4VUserPhysicsList* physics = new ExN03PhysicsList; |
---|
81 | runManager->SetUserInitialization(physics); |
---|
82 | |
---|
83 | // Set user action classes |
---|
84 | // |
---|
85 | G4VUserPrimaryGeneratorAction* gen_action = |
---|
86 | new ExN03PrimaryGeneratorAction(detector); |
---|
87 | runManager->SetUserAction(gen_action); |
---|
88 | // |
---|
89 | ExN03RunAction* run_action = new ExN03RunAction; |
---|
90 | runManager->SetUserAction(run_action); |
---|
91 | // |
---|
92 | ExN03EventAction* event_action = new ExN03EventAction(run_action); |
---|
93 | runManager->SetUserAction(event_action); |
---|
94 | // |
---|
95 | G4UserSteppingAction* stepping_action = |
---|
96 | new ExN03SteppingAction(detector, event_action); |
---|
97 | runManager->SetUserAction(stepping_action); |
---|
98 | |
---|
99 | // Initialize G4 kernel |
---|
100 | // |
---|
101 | runManager->Initialize(); |
---|
102 | |
---|
103 | #ifdef G4VIS_USE |
---|
104 | // Initialize visualization |
---|
105 | // |
---|
106 | G4VisManager* visManager = new G4VisExecutive; |
---|
107 | visManager->Initialize(); |
---|
108 | #endif |
---|
109 | |
---|
110 | // Get the pointer to the User Interface manager |
---|
111 | // |
---|
112 | G4UImanager* UImanager = G4UImanager::GetUIpointer(); |
---|
113 | |
---|
114 | |
---|
115 | #ifdef MAC_OSX_APP |
---|
116 | std::string progName = argv[0]; |
---|
117 | std::string::size_type pos = progName.find(".app/Contents/MacOS/",0); |
---|
118 | if (pos != std::string::npos) { |
---|
119 | std::string progDir = progName.substr(0,pos+4); |
---|
120 | chdir((progDir+"/Contents/macros").c_str()); |
---|
121 | argc = 1; |
---|
122 | } |
---|
123 | #endif |
---|
124 | |
---|
125 | if (argc!=1) // batch mode |
---|
126 | { |
---|
127 | G4String command = "/control/execute "; |
---|
128 | G4String fileName = argv[1]; |
---|
129 | UImanager->ApplyCommand(command+fileName); |
---|
130 | } |
---|
131 | else |
---|
132 | { // interactive mode : define UI session |
---|
133 | #ifdef G4UI_USE |
---|
134 | G4UIExecutive* ui = new G4UIExecutive(argc,argv); |
---|
135 | #ifdef G4VIS_USE |
---|
136 | UImanager->ApplyCommand("/control/execute vis.mac"); |
---|
137 | #endif |
---|
138 | if (ui->IsGUI()) |
---|
139 | UImanager->ApplyCommand("/control/execute visTutor/gui.mac"); |
---|
140 | ui->SessionStart(); |
---|
141 | delete ui; |
---|
142 | #endif |
---|
143 | } |
---|
144 | |
---|
145 | // Job termination |
---|
146 | // Free the store: user actions, physics_list and detector_description are |
---|
147 | // owned and deleted by the run manager, so they should not |
---|
148 | // be deleted in the main() program ! |
---|
149 | #ifdef G4VIS_USE |
---|
150 | delete visManager; |
---|
151 | #endif |
---|
152 | delete runManager; |
---|
153 | |
---|
154 | return 0; |
---|
155 | } |
---|
156 | |
---|
157 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|