source: trunk/examples/advanced/underground_physics/DMX.cc@ 1152

Last change on this file since 1152 was 807, checked in by garnier, 17 years ago

update

File size: 5.6 KB
Line 
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// GEANT 4 - Underground Dark Matter Detector Advanced Example
29//
30// For information related to this code contact: Alex Howard
31// e-mail: alexander.howard@cern.ch
32// --------------------------------------------------------------
33// Comments
34//
35// Underground Advanced example main program
36// by A. Howard and H. Araujo
37// (27th November 2001)
38//
39// main program
40// --------------------------------------------------------------
41
42#include "G4RunManager.hh"
43#include "G4UImanager.hh"
44#include "G4UIterminal.hh"
45#include "G4UItcsh.hh"
46
47#ifdef G4UI_USE_XM
48#include "G4UIXm.hh"
49#endif
50
51#include "Randomize.hh"
52
53#ifdef G4VIS_USE
54#include "G4VisExecutive.hh"
55#endif
56
57#include "DMXDetectorConstruction.hh"
58#include "DMXPhysicsList.hh"
59#include "DMXPrimaryGeneratorAction.hh"
60#include "DMXRunAction.hh"
61#include "DMXEventAction.hh"
62#include "DMXSteppingAction.hh"
63#include "DMXStackingAction.hh"
64
65#include <vector>
66
67int main(int argc,char** argv) {
68
69 // choose the Random engine
70 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
71
72 // Construct the default run manager
73 G4RunManager * runManager = new G4RunManager;
74
75 // set mandatory initialization classes
76 DMXDetectorConstruction* detector = new DMXDetectorConstruction;
77 runManager->SetUserInitialization(detector);
78 runManager->SetUserInitialization(new DMXPhysicsList);
79
80 G4UIsession* session=0;
81
82#ifdef G4VIS_USE
83 // visualization manager
84 G4VisManager* visManager = 0;
85#endif
86
87 if (argc==1) // Define UI session for interactive mode.
88 {
89 // G4UIterminal is a (dumb) terminal.
90#ifdef G4UI_USE_XM
91 session = new G4UIXm(argc,argv);
92#else
93#ifdef G4UI_USE_TCSH
94 session = new G4UIterminal(new G4UItcsh);
95#else
96 session = new G4UIterminal();
97#endif
98#endif
99#ifdef G4VIS_USE
100 // visualization manager
101 visManager = new G4VisExecutive;
102 visManager->Initialize();
103#endif
104
105 }
106
107 // output environment variables:
108#ifdef G4ANALYSIS_USE
109 G4cout << G4endl << G4endl << G4endl
110 << " User Environment " << G4endl
111 << " Using AIDA 3.2.1 analysis " << G4endl;
112#else
113 G4cout << G4endl << G4endl << G4endl
114 << " User Environment " << G4endl
115 << " G4ANALYSIS_USE environment variable not set, NO ANALYSIS "
116 << G4endl;
117#endif
118
119#ifdef DMXENV_GPS_USE
120 G4cout << " Using GPS and not DMX gun " << G4endl;
121#else
122 G4cout << " Using the DMX gun " << G4endl;
123#endif
124
125 // set user action classes
126 DMXPrimaryGeneratorAction* DMXGenerator = new DMXPrimaryGeneratorAction;
127 runManager->SetUserAction(DMXGenerator);
128 // runManager->SetUserAction(new DMXPrimaryGeneratorAction);
129 // RunAction is inherited by EventAction for output filenames - will all
130 // change when implement proper analysis manager?
131 DMXRunAction* DMXRun = new DMXRunAction;
132 runManager->SetUserAction(DMXRun);
133 DMXEventAction* eventAction = new DMXEventAction(DMXRun,DMXGenerator);
134 runManager->SetUserAction(eventAction);
135 // eventAction is inherited by SteppingAction in order to switch colour
136 // flag:
137 runManager->SetUserAction(new DMXSteppingAction(eventAction));
138 runManager->SetUserAction(new DMXStackingAction);
139
140 //Initialize G4 kernel
141 runManager->Initialize();
142
143 // get the pointer to the User Interface manager
144 G4UImanager* UI = G4UImanager::GetUIpointer();
145
146 // Define UI session for interactive mode.
147 if(session) {
148
149 // G4UIterminal is a (dumb) terminal.
150 UI->ApplyCommand("/control/execute initInter.mac");
151 /*
152 #ifdef G4UI_USE_XM
153 // Customize the G4UIXm menubar with a macro file :
154 UI->ApplyCommand("/control/execute gui.mac");
155 #endif
156 */
157 session->SessionStart();
158 delete session;
159 }
160 // Batch mode
161 else
162 {
163 G4String command = "/control/execute ";
164 G4String fileName = argv[1];
165 UI->ApplyCommand(command+fileName);
166 }
167
168 // job termination
169#ifdef G4VIS_USE
170 if(visManager) delete visManager;
171#endif
172 delete runManager;
173
174 return 0;
175}
176
Note: See TracBrowser for help on using the repository browser.