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

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

update to geant4.9.3

File size: 5.6 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//
[1190]27// $Id: exampleN05.cc,v 1.17 2009/10/30 15:10:56 allison Exp $
[1230]28// GEANT4 tag $Name: geant4-09-03-cand-01 $
[807]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 "G4UImanager.hh"
66#include "G4RunManager.hh"
67#include "G4RunManagerKernel.hh"
68
69#ifdef G4VIS_USE
70#include "G4VisExecutive.hh"
71#endif
72
[1190]73#ifdef G4UI_USE
74#include "G4UIExecutive.hh"
75#endif
[807]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 // Initialize Run manager
113 runManager->Initialize();
114
115 //----------------
116 // Visualization:
117 //----------------
118#ifdef G4VIS_USE
119 G4cout << "Instantiating Visualization Manager......." << G4endl;
120 G4VisManager* visManager = new G4VisExecutive;
121 visManager -> Initialize ();
122#endif
123
124 // Setup commands
125 //
[1190]126 G4UImanager * UImanager = G4UImanager::GetUIpointer();
127 UImanager->ApplyCommand("/Step/Verbose 0");
128 UImanager->ApplyCommand("/tracking/Verbose 1");
129 UImanager->ApplyCommand("/gun/particle e-");
130 UImanager->ApplyCommand("/gun/energy 100 MeV");
131 UImanager->ApplyCommand("/gun/direction 0 0 1");
132 UImanager->ApplyCommand("/gun/position 0 0 0");
133 UImanager->ApplyCommand("/gun/direction 0 .3 1.");
[807]134
135 if(argc==1)
136 {
137 //--------------------------
138 // Define (G)UI
139 //--------------------------
[1190]140#ifdef G4UI_USE
141 G4UIExecutive * ui = new G4UIExecutive(argc,argv);
142 ui->SessionStart();
143 delete ui;
144#endif
[807]145 }
146 else
147 {
148 G4String command = "/control/execute ";
149 G4String fileName = argv[1];
150 UImanager->ApplyCommand(command+fileName);
151 }
152
153 // Free the store: user actions, physics_list and detector_description are
154 // owned and deleted by the run manager, so they should not
155 // be deleted in the main() program !
156
157#ifdef G4VIS_USE
158 delete visManager;
159#endif
160 delete runManager;
161
162 return 0;
163}
Note: See TracBrowser for help on using the repository browser.