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 | // $Id: A01app.cc,v 1.8 2006/11/06 19:46:06 allison Exp $ |
---|
27 | // -------------------------------------------------------------- |
---|
28 | // |
---|
29 | // -------------------------------------------------------------- |
---|
30 | // GEANT 4 - A01app |
---|
31 | // -------------------------------------------------------------- |
---|
32 | // Comments |
---|
33 | // Tutorial for Geant4 lectures |
---|
34 | // -------------------------------------------------------------- |
---|
35 | |
---|
36 | |
---|
37 | #include "G4RunManager.hh" |
---|
38 | #include "G4UImanager.hh" |
---|
39 | #include "G4UIterminal.hh" |
---|
40 | #ifdef G4UI_USE_TCSH |
---|
41 | #include "G4UItcsh.hh" |
---|
42 | #endif |
---|
43 | |
---|
44 | #include "A01DetectorConstruction.hh" |
---|
45 | #include "A01PhysicsList.hh" |
---|
46 | #include "A01PrimaryGeneratorAction.hh" |
---|
47 | |
---|
48 | #include "A01EventAction.hh" |
---|
49 | |
---|
50 | #ifdef G4VIS_USE |
---|
51 | #include "G4VisExecutive.hh" |
---|
52 | #endif |
---|
53 | |
---|
54 | //OSC:begin |
---|
55 | #include <G4Lab/UIOnX.h> |
---|
56 | #include "A01AnalysisManager.hh" |
---|
57 | #include <AIDA/IAnalysisFactory.h> |
---|
58 | //OSC:end |
---|
59 | |
---|
60 | int main(int argc,char** argv) |
---|
61 | { |
---|
62 | // RunManager construction |
---|
63 | G4RunManager* runManager = new G4RunManager; |
---|
64 | |
---|
65 | //OSC:begin |
---|
66 | G4UIsession* session = 0; |
---|
67 | if (argc!=1) { // batch mode |
---|
68 | A01AnalysisManager::setAIDA(AIDA_createAnalysisFactory()); |
---|
69 | } else { |
---|
70 | std::string GUI_onx = "main.onx"; |
---|
71 | //std::string GUI_onx = "simple_main.onx"; |
---|
72 | G4Lab::UIOnX* uiOnX = new G4Lab::UIOnX(*runManager,GUI_onx,argc,argv); |
---|
73 | // Enforce the creation of the GUI here, else |
---|
74 | // the AIDA plotter factory will create its own |
---|
75 | // that will interfer with the G4Lab::UIOnX one. |
---|
76 | uiOnX->createUI(); |
---|
77 | A01AnalysisManager::setAIDA(uiOnX->findAIDA()); |
---|
78 | session = uiOnX; |
---|
79 | } |
---|
80 | //OSC:end |
---|
81 | |
---|
82 | #ifdef G4VIS_USE |
---|
83 | // Visualization manager construction |
---|
84 | G4VisManager* visManager = new G4VisExecutive; |
---|
85 | visManager->Initialize(); |
---|
86 | #endif |
---|
87 | |
---|
88 | // mandatory user initialization classes |
---|
89 | runManager->SetUserInitialization(new A01DetectorConstruction); |
---|
90 | runManager->SetUserInitialization(new A01PhysicsList); |
---|
91 | |
---|
92 | // initialize Geant4 kernel |
---|
93 | runManager->Initialize(); |
---|
94 | |
---|
95 | // mandatory user action class |
---|
96 | runManager->SetUserAction(new A01PrimaryGeneratorAction); |
---|
97 | |
---|
98 | // optional user action classes |
---|
99 | runManager->SetUserAction(new A01EventAction); |
---|
100 | |
---|
101 | if(argc>1) |
---|
102 | // execute an argument macro file if exist |
---|
103 | { |
---|
104 | G4UImanager* UImanager = G4UImanager::GetUIpointer(); |
---|
105 | G4String command = "/control/execute "; |
---|
106 | G4String fileName = argv[1]; |
---|
107 | UImanager->ApplyCommand(command+fileName); |
---|
108 | } |
---|
109 | else |
---|
110 | // start interactive session |
---|
111 | { |
---|
112 | #ifdef G4UI_USE_TCSH |
---|
113 | G4UIsession* session = new G4UIterminal(new G4UItcsh); |
---|
114 | #else |
---|
115 | //OSC:begin |
---|
116 | // G4UIsession* session = new G4UIterminal(); |
---|
117 | //OSC:end |
---|
118 | #endif |
---|
119 | session->SessionStart(); |
---|
120 | //OSC:begin |
---|
121 | // delete session; |
---|
122 | //OSC:end |
---|
123 | } |
---|
124 | |
---|
125 | #ifdef G4VIS_USE |
---|
126 | delete visManager; |
---|
127 | #endif |
---|
128 | |
---|
129 | delete runManager; |
---|
130 | |
---|
131 | //OSC:begin |
---|
132 | // The delete of the run manager may induce, |
---|
133 | // through the user action classes, |
---|
134 | // a delete / closing of the AIDA resources |
---|
135 | // as AIDA trees and various factories. |
---|
136 | // Then we delete the UIOnX that manages the |
---|
137 | // AIDA implementation after the delete |
---|
138 | // of the G4 run manager. |
---|
139 | delete session; |
---|
140 | //OSC:end |
---|
141 | |
---|
142 | return 0; |
---|
143 | } |
---|
144 | |
---|