source: trunk/examples/novice/N05/exampleN05.cc@ 1158

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

update

File size: 5.7 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: exampleN05.cc,v 1.16 2007/05/11 14:29:16 mverderi Exp $
28// GEANT4 tag $Name: $
29//
30//
31// --------------------------------------------------------------
32// GEANT 4 - exampleN05
33// --------------------------------------------------------------
34// Comments
35//
36// Example of a main program making use of parameterisation
37// i.e. "Fast Simulation"
38//-------------------------------------------------------------------
39
40//------------------------------
41// Run, Generator etc.. actions:
42//------------------------------
43#include "ExN05RunAction.hh"
44#include "ExN05PrimaryGeneratorAction.hh"
45#include "ExN05EventAction.hh"
46#include "ExN05SteppingAction.hh"
47
48//---------------------------
49// Parameterisation manager:
50//---------------------------
51#include "G4GlobalFastSimulationManager.hh"
52
53//------------
54// Geometries:
55//------------
56#include "ExN05DetectorConstruction.hh"
57#include "ExN05ParallelWorldForPion.hh"
58
59//-----------------------------------
60// ExN05PhysicsList (makes use of the
61// G4ParameterisationManagerProcess):
62//-----------------------------------
63#include "ExN05PhysicsList.hh"
64
65#include "G4UIterminal.hh"
66#include "G4UImanager.hh"
67#include "G4RunManager.hh"
68#include "G4RunManagerKernel.hh"
69
70
71#ifdef G4VIS_USE
72#include "G4VisExecutive.hh"
73#endif
74
75#include "G4ios.hh"
76
77int main(int argc, char** argv)
78{
79 //-------------------------------
80 // Initialization of Run manager
81 //-------------------------------
82 G4cout << "RunManager construction starting...." << G4endl;
83 G4RunManager * runManager = new G4RunManager;
84
85 // Detector/mass geometry and parallel geometry(ies):
86 G4VUserDetectorConstruction* detector = new ExN05DetectorConstruction();
87 // -- Parallel geometry for pion parameterisation
88 detector->RegisterParallelWorld(new ExN05ParallelWorldForPion("pionGhostWorld"));
89 // -- The name passed must be the same passed to the
90 // -- G4FastSimulationManagerProcess attached to the pions
91 runManager->SetUserInitialization(detector);
92
93 // PhysicsList (including G4FastSimulationManagerProcess)
94 G4VUserPhysicsList* physicsList = new ExN05PhysicsList;
95 runManager->SetUserInitialization(physicsList);
96
97 //-------------------------------
98 // UserAction classes
99 //-------------------------------
100 G4UserRunAction* run_action = new ExN05RunAction;
101 runManager->SetUserAction(run_action);
102 //
103 G4VUserPrimaryGeneratorAction* gen_action = new ExN05PrimaryGeneratorAction;
104 runManager->SetUserAction(gen_action);
105 //
106 G4UserEventAction* event_action = new ExN05EventAction;
107 runManager->SetUserAction(event_action);
108 //
109 G4UserSteppingAction* stepping_action = new ExN05SteppingAction;
110 runManager->SetUserAction(stepping_action);
111
112
113 // Initialize Run manager
114 runManager->Initialize();
115
116 //----------------
117 // Visualization:
118 //----------------
119#ifdef G4VIS_USE
120 G4cout << "Instantiating Visualization Manager......." << G4endl;
121 G4VisManager* visManager = new G4VisExecutive;
122 visManager -> Initialize ();
123#endif
124
125 // Setup commands
126 //
127 G4UImanager * UI = G4UImanager::GetUIpointer();
128 UI->ApplyCommand("/Step/Verbose 0");
129 UI->ApplyCommand("/tracking/Verbose 1");
130 UI->ApplyCommand("/gun/particle e-");
131 UI->ApplyCommand("/gun/energy 100 MeV");
132 UI->ApplyCommand("/gun/direction 0 0 1");
133 UI->ApplyCommand("/gun/position 0 0 0");
134 UI->ApplyCommand("/gun/direction 0 .3 1.");
135
136 if(argc==1)
137 {
138 //--------------------------
139 // Define (G)UI
140 //--------------------------
141 // G4UIterminal is a (dumb) terminal
142 //
143 G4UIsession* session = new G4UIterminal;
144 session->SessionStart();
145 delete session;
146 }
147 else
148 {
149#ifdef G4VIS_USE
150 visManager->SetVerboseLevel("quiet");
151#endif
152 G4UImanager* UImanager = G4UImanager::GetUIpointer();
153 G4String command = "/control/execute ";
154 G4String fileName = argv[1];
155 UImanager->ApplyCommand(command+fileName);
156 }
157
158 // Free the store: user actions, physics_list and detector_description are
159 // owned and deleted by the run manager, so they should not
160 // be deleted in the main() program !
161
162#ifdef G4VIS_USE
163 delete visManager;
164#endif
165 delete runManager;
166
167 return 0;
168}
Note: See TracBrowser for help on using the repository browser.