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