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

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

r659@mac-90108: laurentgarnier | 2007-11-16 12:02:01 +0100
mise a jour de Geant4 au head ET qq mise a jour pour Qt de mon cote

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