source: trunk/examples/novice/N07/exampleN07.cc@ 1036

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

update

File size: 4.2 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: exampleN07.cc,v 1.10 2007/05/04 01:49:28 asaim Exp $
28// GEANT4 tag $Name: $
29//
30//
31// --------------------------------------------------------------
32// GEANT 4 - exampleN07
33// --------------------------------------------------------------
34
35#include "G4RunManager.hh"
36#include "G4UImanager.hh"
37#include "G4UIterminal.hh"
38#include "G4UItcsh.hh"
39
40#ifdef G4VIS_USE
41#include "G4VisExecutive.hh"
42#endif
43#include "ExN07DetectorConstruction.hh"
44#include "ExN07ParallelWorld.hh"
45#include "ExN07PhysicsList.hh"
46#include "ExN07PrimaryGeneratorAction.hh"
47#include "ExN07RunAction.hh"
48#include "ExN07SteppingVerbose.hh"
49
50int main(int argc,char** argv)
51{
52 // Construct the stepping verbose class
53 ExN07SteppingVerbose* verbosity = new ExN07SteppingVerbose;
54 G4VSteppingVerbose::SetInstance(verbosity);
55
56 // Construct the run manager
57 //
58 G4RunManager * runManager = new G4RunManager;
59
60 // Set mandatory initialization classes
61 //
62 G4VUserDetectorConstruction* detector = new ExN07DetectorConstruction;
63 detector->RegisterParallelWorld(new ExN07ParallelWorld("ParallelScoringWorld"));
64 runManager->SetUserInitialization(detector);
65 //
66 G4VUserPhysicsList* physics = new ExN07PhysicsList;
67 runManager->SetUserInitialization(physics);
68
69 // Set user action classes
70 //
71 G4VUserPrimaryGeneratorAction* gen_action = new ExN07PrimaryGeneratorAction;
72 runManager->SetUserAction(gen_action);
73 //
74 G4UserRunAction* run_action = new ExN07RunAction;
75 runManager->SetUserAction(run_action);
76
77#ifdef G4VIS_USE
78 // Visualization manager
79 //
80 G4VisManager* visManager = new G4VisExecutive;
81 visManager->Initialize();
82#endif
83
84 // Initialize G4 kernel
85 //
86 runManager->Initialize();
87
88 // Get the pointer to the User Interface manager
89 //
90 G4UImanager* UI = G4UImanager::GetUIpointer();
91
92 if (argc==1) // Define UI session for interactive mode
93 {
94 G4UIsession* session=0;
95
96 // G4UIterminal is a (dumb) terminal
97 //
98#ifdef G4UI_USE_TCSH
99 session = new G4UIterminal(new G4UItcsh);
100#else
101 session = new G4UIterminal();
102#endif
103
104 UI->ApplyCommand("/control/execute vis.mac");
105 session->SessionStart();
106
107 delete session;
108 }
109 else // Batch mode
110 {
111 G4String command = "/control/execute ";
112 G4String fileName = argv[1];
113 UI->ApplyCommand(command+fileName);
114 }
115
116 // Job termination
117 // Free the store: user actions, physics_list and detector_description are
118 // owned and deleted by the run manager, so they should not
119 // be deleted in the main() program !
120
121#ifdef G4VIS_USE
122 delete visManager;
123#endif
124 delete runManager;
125
126 return 0;
127}
Note: See TracBrowser for help on using the repository browser.