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 | // * * |
---|
28 | // * cosmicray_charging advanced example for Geant4 * |
---|
29 | // * (adapted simulation of test-mass charging in the LISA mission) * |
---|
30 | // * * |
---|
31 | // * Henrique Araujo (h.araujo@imperial.ac.uk) & Peter Wass * |
---|
32 | // * Imperial College London * |
---|
33 | // * * |
---|
34 | // * main program class * |
---|
35 | // * * |
---|
36 | // ******************************************************************** |
---|
37 | // |
---|
38 | // HISTORY |
---|
39 | // 22/02/2004: migrated from LISA-V04 |
---|
40 | // |
---|
41 | // ******************************************************************** |
---|
42 | |
---|
43 | #include "G4RunManager.hh" |
---|
44 | #include "G4UImanager.hh" |
---|
45 | #include "G4UIterminal.hh" |
---|
46 | #include "G4UItcsh.hh" |
---|
47 | |
---|
48 | #ifdef G4UI_USE_XM |
---|
49 | #include "G4UIXm.hh" |
---|
50 | #endif |
---|
51 | |
---|
52 | #ifdef G4UI_USE_QT |
---|
53 | #include "G4UIQt.hh" |
---|
54 | #include "G4Qt.hh" |
---|
55 | #include <qapplication.h> |
---|
56 | #endif |
---|
57 | #include "Randomize.hh" |
---|
58 | |
---|
59 | #ifdef G4VIS_USE |
---|
60 | #include "G4VisExecutive.hh" |
---|
61 | #endif |
---|
62 | |
---|
63 | #include "LISADetectorConstruction.hh" |
---|
64 | #include "LISAPhysicsList.hh" |
---|
65 | #include "LISAPrimaryGeneratorAction.hh" |
---|
66 | #include "LISARunAction.hh" |
---|
67 | #include "LISAEventAction.hh" |
---|
68 | #include "LISASteppingAction.hh" |
---|
69 | #include "LISAStackingAction.hh" |
---|
70 | |
---|
71 | #include <vector> |
---|
72 | |
---|
73 | |
---|
74 | int main(int argc,char** argv) { |
---|
75 | |
---|
76 | // choose the Random engine |
---|
77 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); |
---|
78 | |
---|
79 | // Construct the default run manager |
---|
80 | G4RunManager* runManager = new G4RunManager; |
---|
81 | |
---|
82 | // set mandatory initialization classes |
---|
83 | LISADetectorConstruction* detector = new LISADetectorConstruction; |
---|
84 | runManager->SetUserInitialization(detector); |
---|
85 | runManager->SetUserInitialization(new LISAPhysicsList); |
---|
86 | LISAPrimaryGeneratorAction* generatorAction = new LISAPrimaryGeneratorAction; |
---|
87 | runManager->SetUserAction(generatorAction); |
---|
88 | |
---|
89 | // set user action classes |
---|
90 | LISASteppingAction* steppingAction = new LISASteppingAction; |
---|
91 | runManager->SetUserAction(steppingAction); |
---|
92 | runManager->SetUserAction(new LISAStackingAction); |
---|
93 | runManager->SetUserAction( |
---|
94 | new LISAEventAction(generatorAction,steppingAction)); |
---|
95 | runManager->SetUserAction(new LISARunAction); |
---|
96 | |
---|
97 | |
---|
98 | //Initialize G4 kernel |
---|
99 | runManager->Initialize(); |
---|
100 | |
---|
101 | // get the pointer to the User Interface manager |
---|
102 | G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
103 | |
---|
104 | #ifdef G4VIS_USE |
---|
105 | // visualization manager |
---|
106 | G4VisManager* visManager = new G4VisExecutive; |
---|
107 | visManager->Initialize(); |
---|
108 | #endif |
---|
109 | |
---|
110 | G4UIsession* session=0; |
---|
111 | if (argc==1) { // Define UI session for interactive mode. |
---|
112 | // G4UIterminal is a (dumb) terminal. |
---|
113 | #ifdef G4UI_USE_XM |
---|
114 | session = new G4UIXm(argc,argv); |
---|
115 | #elif defined(G4UI_USE_QT) |
---|
116 | session = new G4UIQt(argc,argv); |
---|
117 | #else |
---|
118 | #ifdef G4UI_USE_TCSH |
---|
119 | session = new G4UIterminal(new G4UItcsh); |
---|
120 | #else |
---|
121 | session = new G4UIterminal(); |
---|
122 | #endif |
---|
123 | #endif |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | |
---|
128 | |
---|
129 | // Define UI session for interactive mode. |
---|
130 | if(session) { |
---|
131 | // G4UIterminal is a (dumb) terminal. |
---|
132 | UI->ApplyCommand("/control/execute init.mac"); |
---|
133 | session->SessionStart(); |
---|
134 | delete session; |
---|
135 | } |
---|
136 | // Batch mode |
---|
137 | else { |
---|
138 | G4String command = "/control/execute "; |
---|
139 | G4String fileName = argv[1]; |
---|
140 | UI->ApplyCommand(command+fileName); |
---|
141 | } |
---|
142 | |
---|
143 | // job termination |
---|
144 | #ifdef G4VIS_USE |
---|
145 | delete visManager; |
---|
146 | #endif |
---|
147 | delete runManager; |
---|
148 | |
---|
149 | return 0; |
---|
150 | } |
---|
151 | |
---|