source: trunk/examples/novice/N04/exampleN04.cc@ 1179

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

update

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