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