source: trunk/geant4/N03/exampleN03.cc @ 486

Last change on this file since 486 was 484, checked in by garnier, 17 years ago

r573@mac-90108: laurentgarnier | 2007-06-05 16:12:24 +0200
remise a jour

File size: 5.5 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// $Id: exampleN03.cc,v 1.28 2006/06/29 17:48:30 gunter Exp $
28// GEANT4 tag $Name: geant4-08-01 $
29//
30//
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33
34#include "G4RunManager.hh"
35#include "G4UImanager.hh"
36#include "G4UIterminal.hh"
37#include "G4UItcsh.hh"
38
39#ifdef G4UI_USE_XM
40#include "G4UIXm.hh"
41#endif
42
43#ifdef G4UI_USE_QT
44#include "G4UIQt.hh"
45#endif
46
47#ifdef G4UI_USE_WIN32
48#include "G4UIWin32.hh"
49#endif
50
51#include "Randomize.hh"
52
53#ifdef G4VIS_USE
54#include "G4VisExecutive.hh"
55#endif
56
57#include "ExN03DetectorConstruction.hh"
58#include "ExN03PhysicsList.hh"
59#include "ExN03PrimaryGeneratorAction.hh"
60#include "ExN03RunAction.hh"
61#include "ExN03EventAction.hh"
62#include "ExN03SteppingAction.hh"
63#include "ExN03SteppingVerbose.hh"
64
65//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66
67int main(int argc,char** argv)
68{
69  // Choose the Random engine
70  //
71  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
72 
73  // User Verbose output class
74  //
75  G4VSteppingVerbose* verbosity = new ExN03SteppingVerbose;
76  G4VSteppingVerbose::SetInstance(verbosity);
77     
78  // Construct the default run manager
79  //
80  G4RunManager * runManager = new G4RunManager;
81
82  // Set mandatory initialization classes
83  //
84  ExN03DetectorConstruction* detector = new ExN03DetectorConstruction;
85  runManager->SetUserInitialization(detector);
86  //
87  G4VUserPhysicsList* physics = new ExN03PhysicsList;
88  runManager->SetUserInitialization(physics);
89
90  G4UIsession* session=0;
91 
92  if (argc==1)   // Define UI session for interactive mode.
93    {
94      // G4UIterminal is a (dumb) terminal
95      //
96#if defined(G4UI_USE_XM)
97      session = new G4UIXm(argc,argv);
98#elif defined(G4UI_USE_WIN32)
99      session = new G4UIWin32();
100#elif defined(G4UI_USE_QT)
101      session = new G4UIQt(argc,argv);
102#elif defined(G4UI_USE_TCSH)
103      session = new G4UIterminal(new G4UItcsh);     
104#else
105      session = new G4UIterminal();
106#endif
107    }
108 
109#ifdef G4VIS_USE
110  // Visualization manager
111  //
112  G4VisManager* visManager = new G4VisExecutive;
113  visManager->Initialize();
114#endif
115   
116  // Set user action classes
117  //
118  G4VUserPrimaryGeneratorAction* gen_action = new ExN03PrimaryGeneratorAction(detector);
119  runManager->SetUserAction(gen_action);
120  //
121  ExN03RunAction* run_action = new ExN03RunAction; 
122  runManager->SetUserAction(run_action);
123  //
124  ExN03EventAction* event_action = new ExN03EventAction(run_action);
125  runManager->SetUserAction(event_action);
126  //
127  G4UserSteppingAction* stepping_action =
128    new ExN03SteppingAction(detector, event_action);
129  runManager->SetUserAction(stepping_action);
130 
131  // Initialize G4 kernel
132  //
133  runManager->Initialize();
134   
135  // Get the pointer to the User Interface manager
136  //
137  G4UImanager* UI = G4UImanager::GetUIpointer(); 
138
139  if (session)   // Define UI session for interactive mode
140    {
141      // G4UIterminal is a (dumb) terminal
142      //
143      UI->ApplyCommand("/control/execute vis.mac");   
144#if defined(G4UI_USE_XM) || defined(G4UI_USE_WIN32) || defined(G4UI_USE_QT)
145      // Customize the G4UIXm,Win32 menubar with a macro file
146      //
147      UI->ApplyCommand("/control/execute visTutor/gui.mac");
148#endif
149      session->SessionStart();
150      delete session;
151    }
152  else           // Batch mode
153    { 
154#ifdef G4VIS_USE
155      visManager->SetVerboseLevel("quiet");
156#endif
157      G4String command = "/control/execute ";
158      G4String fileName = argv[1];
159      UI->ApplyCommand(command+fileName);
160    }
161
162  // Job termination
163  // Free the store: user actions, physics_list and detector_description are
164  //                 owned and deleted by the run manager, so they should not
165  //                 be deleted in the main() program !
166
167#ifdef G4VIS_USE
168  delete visManager;
169#endif
170  delete runManager;
171  delete verbosity;
172
173  return 0;
174}
175
176//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.