Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ErrorRunManagerHelper.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// ------------------------------------------------------------
28// GEANT 4 class implementation file
29// ------------------------------------------------------------
30//
31
32#include "G4Navigator.hh"
33
34#include "G4Timer.hh"
35
37
38#include "G4RunManagerKernel.hh"
40#include "G4ErrorPhysicsList.hh"
42#include "G4RunManager.hh"
43
44//-----------------------------------------------------------------------
45
47 G4ErrorRunManagerHelper::fRunManagerKernel = 0;
48
49//-----------------------------------------------------------------------
51{
52 return fRunManagerKernel;
53}
54
55//-----------------------------------------------------------------------
57{
58 if(fRunManagerKernel)
59 {
60 G4Exception("G4ErrorRunManagerHelper::G4ErrorRunManagerHelper()",
61 "InvalidSetup", FatalException,
62 "G4eRunManageKernel constructed twice.");
63 }
64 fRunManagerKernel = this;
65
66 //----- Look if somebody has created a G4RunManagerKernel
67 theG4RunManagerKernel = G4RunManagerKernel::GetRunManagerKernel();
68 if(theG4RunManagerKernel == 0)
69 {
70 //--- if not create it
71 theG4RunManagerKernel = new G4RunManagerKernel();
72 G4cout << " creating G4RunManagerKernel " << theG4RunManagerKernel
73 << G4endl;
74 }
75
76 theG4RunManagerKernel->SetVerboseLevel(2);
77 theUserPhysicsList = 0;
78 theUserWorld = 0;
79}
80
81//-----------------------------------------------------------------------
83
84//-----------------------------------------------------------------------
87{
88 theUserWorld = userInit->Construct();
89}
90
91//-----------------------------------------------------------------------
93{
94 theUserWorld = userInit;
95}
96
97//-----------------------------------------------------------------------
99 G4VUserPhysicsList* userInit)
100{
101 theUserPhysicsList = userInit;
102}
103
104//-----------------------------------------------------------------------
106{
107 // check if user world has been directly called or someone initialized the
108 // world volume already
109 //----- First option: geometry has been defined to GEANT4e
110 if(theUserWorld != 0)
111 {
112 theG4RunManagerKernel->DefineWorldVolume(theUserWorld);
113
114 //----- Second option: geometry has been defined to GEANT4, do nothing
115 //GEANT4 should take care
116 }
117 else
118 {
119 //--- Check that indeed geometry has been defined to GEANT4
121 ->GetNavigatorForTracking()
122 ->GetWorldVolume() == 0)
123 {
124 G4Exception("G4ErrorRunManagerHelper::InitializeGeometry()",
125 "InvalisSetup", FatalException,
126 "No world defined in your geometry!");
127 }
128 }
129}
130
131//-----------------------------------------------------------------------
133{
134 G4cout << " G4ErrorRunManagerHelper::InitializePhysics " << G4endl;
135
136 //----- First option: physics list has been defined to GEANT4e
137 if(theUserPhysicsList != 0)
138 {
139 theG4RunManagerKernel->SetPhysics(theUserPhysicsList);
140 theG4RunManagerKernel->InitializePhysics();
141 }
142 else
143 {
144 //----- Second option: physics list has been defined to GEANT4, do nothing
145 //GEANT4 should take care
146 if(G4RunManager::GetRunManager() != 0 &&
148 {
149 //--- Physics should be G4ErrorPhysicsList, else send a warning
150 if(static_cast<const G4ErrorPhysicsList*>(
152 {
153 std::ostringstream message;
154 message << "Physics list is not G4ErrorPhysicsList. Are you sure?";
155 G4Exception("G4ErrorRunManagerHelper::InitializePhysics()",
156 "GEANT4e-Notification", JustWarning, message);
157 }
158 }
159 else
160 {
161 //----- Third option: no physics list has been defined, define a
162 //G4ErrorPhysicsList
163 theG4RunManagerKernel->SetPhysics(new G4ErrorPhysicsList);
164 // theG4RunManagerKernel->SetPhysics(new ExN02PhysicsList);
165 theG4RunManagerKernel->InitializePhysics();
166 }
167 }
168}
169
170//-----------------------------------------------------------------------
172{
173 theG4RunManagerKernel->RunInitialization();
174}
175
176//-----------------------------------------------------------------------
178{
180}
181
182//-----------------------------------------------------------------------
184{
186}
187
188//-----------------------------------------------------------------------
190{
191 theG4RunManagerKernel->RunTermination();
192}
@ JustWarning
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4VUserPhysicsList * GetUserPhysicsList() const
static G4ErrorRunManagerHelper * GetRunManagerKernel()
void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetUserAction(G4UserTrackingAction *userAction)
void SetUserAction(G4UserEventAction *userAction)
static G4EventManager * GetEventManager()
static G4RunManagerKernel * GetRunManagerKernel()
void SetPhysics(G4VUserPhysicsList *uPhys)
void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4bool RunInitialization(G4bool fakeRun=false)
void SetVerboseLevel(G4int vl)
static G4RunManager * GetRunManager()
static G4TransportationManager * GetTransportationManager()
virtual G4VPhysicalVolume * Construct()=0
#define G4ThreadLocal
Definition: tls.hh:77