source: trunk/examples/novice/N02/exampleN02.cc @ 807

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

update

File size: 4.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: exampleN02.cc,v 1.14 2007/07/02 13:09:30 vnivanch Exp $
28// GEANT4 tag $Name:  $
29//
30//
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33
34#include "ExN02DetectorConstruction.hh"
35#include "ExN02PhysicsList.hh"
36#include "ExN02PrimaryGeneratorAction.hh"
37#include "ExN02RunAction.hh"
38#include "ExN02EventAction.hh"
39#include "ExN02SteppingAction.hh"
40#include "ExN02SteppingVerbose.hh"
41
42#include "G4RunManager.hh"
43#include "G4UImanager.hh"
44#include "G4UIterminal.hh"
45#include "G4UItcsh.hh"
46
47#ifdef G4VIS_USE
48#include "G4VisExecutive.hh"
49#endif
50
51//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52
53int main(int argc,char** argv)
54{
55  // User Verbose output class
56  //
57  G4VSteppingVerbose* verbosity = new ExN02SteppingVerbose;
58  G4VSteppingVerbose::SetInstance(verbosity);
59 
60  // Run manager
61  //
62  G4RunManager * runManager = new G4RunManager;
63
64  // User Initialization classes (mandatory)
65  //
66  ExN02DetectorConstruction* detector = new ExN02DetectorConstruction;
67  runManager->SetUserInitialization(detector);
68  //
69  G4VUserPhysicsList* physics = new ExN02PhysicsList;
70  runManager->SetUserInitialization(physics);
71   
72  // User Action classes
73  //
74  G4VUserPrimaryGeneratorAction* gen_action = new ExN02PrimaryGeneratorAction(detector);
75  runManager->SetUserAction(gen_action);
76  //
77  G4UserRunAction* run_action = new ExN02RunAction;
78  runManager->SetUserAction(run_action);
79  //
80  G4UserEventAction* event_action = new ExN02EventAction;
81  runManager->SetUserAction(event_action);
82  //
83  G4UserSteppingAction* stepping_action = new ExN02SteppingAction;
84  runManager->SetUserAction(stepping_action);
85
86  // Initialize G4 kernel
87  //
88  runManager->Initialize();
89     
90  // Get the pointer to the User Interface manager
91  //
92  G4UImanager * UI = G4UImanager::GetUIpointer(); 
93
94  if (argc!=1)   // batch mode 
95    {
96     G4String command = "/control/execute ";
97     G4String fileName = argv[1];
98     UI->ApplyCommand(command+fileName);
99    }
100   
101  else           // interactive mode : define visualization and UI terminal
102    { 
103#ifdef G4VIS_USE
104      G4VisManager* visManager = new G4VisExecutive;
105      visManager->Initialize();
106#endif   
107     
108      G4UIsession * session = 0;
109#ifdef G4UI_USE_TCSH
110      session = new G4UIterminal(new G4UItcsh);     
111#else
112      session = new G4UIterminal();
113#endif
114      UI->ApplyCommand("/control/execute vis.mac");     
115      session->SessionStart();
116      delete session;
117     
118#ifdef G4VIS_USE
119      delete visManager;
120#endif     
121    }
122
123  // Free the store: user actions, physics_list and detector_description are
124  //                 owned and deleted by the run manager, so they should not
125  //                 be deleted in the main() program !
126
127  delete runManager;
128  delete verbosity;
129
130  return 0;
131}
132
133//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
134
Note: See TracBrowser for help on using the repository browser.