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

Last change on this file was 1313, checked in by garnier, 14 years ago

geant4.9.4 beta rc0

File size: 5.7 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 "DMXAnalysisManager.hh"
58#include "DMXDetectorConstruction.hh"
59#include "DMXPhysicsList.hh"
60#include "DMXPrimaryGeneratorAction.hh"
61#include "DMXRunAction.hh"
62#include "DMXEventAction.hh"
63#include "DMXSteppingAction.hh"
64#include "DMXStackingAction.hh"
65
66#include <vector>
67
68int main(int argc,char** argv) {
69
70  // choose the Random engine
71  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
72 
73  // Construct the default run manager
74  G4RunManager * runManager = new G4RunManager;
75
76  // set mandatory initialization classes
77  DMXDetectorConstruction* detector = new DMXDetectorConstruction;
78  runManager->SetUserInitialization(detector);
79  runManager->SetUserInitialization(new DMXPhysicsList);
80 
81 G4UIsession* session=0;
82 
83#ifdef G4VIS_USE
84  // visualization manager
85  G4VisManager* visManager = 0;
86#endif
87
88  if (argc==1)   // Define UI session for interactive mode.
89    {
90      // G4UIterminal is a (dumb) terminal.
91#ifdef G4UI_USE_XM
92      session = new G4UIXm(argc,argv);
93#else           
94#ifdef G4UI_USE_TCSH
95      session = new G4UIterminal(new G4UItcsh);     
96#else
97      session = new G4UIterminal();
98#endif
99#endif
100#ifdef G4VIS_USE
101  // visualization manager
102  visManager = new G4VisExecutive;
103  visManager->Initialize();
104#endif
105
106    }
107 
108  // output environment variables:
109#ifdef G4ANALYSIS_USE
110  G4cout << G4endl << G4endl << G4endl
111         << " User Environment " << G4endl
112         << " Using AIDA 3.2.1 analysis " << G4endl;
113#else
114  G4cout << G4endl << G4endl << G4endl
115         << " User Environment " << G4endl
116         << " G4ANALYSIS_USE environment variable not set, NO ANALYSIS " 
117         << G4endl;
118#endif
119
120#ifdef DMXENV_GPS_USE
121  G4cout << " Using GPS and not DMX gun " << G4endl;
122#else
123  G4cout << " Using the DMX gun " << G4endl;
124#endif
125   
126  // set user action classes
127  DMXPrimaryGeneratorAction* DMXGenerator = new DMXPrimaryGeneratorAction;
128  runManager->SetUserAction(DMXGenerator);
129  //  runManager->SetUserAction(new DMXPrimaryGeneratorAction);
130  // RunAction is inherited by EventAction for output filenames - will all
131  // change when implement proper analysis manager?
132  DMXRunAction* DMXRun = new DMXRunAction;
133  runManager->SetUserAction(DMXRun);
134  DMXEventAction* eventAction = new DMXEventAction(DMXRun,DMXGenerator);
135  runManager->SetUserAction(eventAction);
136  // eventAction is inherited by SteppingAction in order to switch colour
137  // flag:
138  runManager->SetUserAction(new DMXSteppingAction(eventAction));
139  runManager->SetUserAction(new DMXStackingAction);
140
141  //Initialize G4 kernel
142  runManager->Initialize();
143   
144  // get the pointer to the User Interface manager
145  G4UImanager* UI = G4UImanager::GetUIpointer(); 
146
147  // Define UI session for interactive mode.
148  if(session) {
149
150      // G4UIterminal is a (dumb) terminal.
151      UI->ApplyCommand("/control/execute initInter.mac");   
152      /*
153        #ifdef G4UI_USE_XM
154        // Customize the G4UIXm menubar with a macro file :
155        UI->ApplyCommand("/control/execute gui.mac");
156        #endif
157      */
158      session->SessionStart();
159      delete session;
160    }
161  // Batch mode
162  else
163    { 
164      G4String command = "/control/execute ";
165      G4String fileName = argv[1];
166      UI->ApplyCommand(command+fileName);
167    }
168
169  // job termination
170#ifdef G4ANALYSIS_USE 
171  DMXAnalysisManager::getInstance()->Finish(); 
172  G4cout << "Analysis files closed" << G4endl;
173#endif
174
175#ifdef G4VIS_USE
176  if(visManager) delete visManager;
177#endif
178  delete runManager;
179
180  return 0;
181}
182
Note: See TracBrowser for help on using the repository browser.