Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // $Id: G4ErrorRunManagerHelper.cc 69766 2013-05-14 14:33:55Z gcosmo $
27 //
28 // ------------------------------------------------------------
29 // GEANT 4 class implementation file
30 // ------------------------------------------------------------
31 //
32 
33 #include "G4Navigator.hh"
34 
35 #include "G4Timer.hh"
36 
38 
39 #include "G4RunManagerKernel.hh"
41 #include "G4ErrorPhysicsList.hh"
43 #include "G4RunManager.hh"
44 
45 //-----------------------------------------------------------------------
46 
47 G4ErrorRunManagerHelper* G4ErrorRunManagerHelper::fRunManagerKernel = 0;
48 
49 //-----------------------------------------------------------------------
51 { return fRunManagerKernel; }
52 
53 
54 //-----------------------------------------------------------------------
56 {
57  if(fRunManagerKernel) {
58  G4Exception("G4ErrorRunManagerHelper::G4ErrorRunManagerHelper()",
59  "InvalidSetup", FatalException,
60  "G4eRunManageKernel constructed twice.");
61  }
62  fRunManagerKernel = this;
63 
64  //----- Look if somebody has created a G4RunManagerKernel
65  theG4RunManagerKernel = G4RunManagerKernel::GetRunManagerKernel();
66  if( theG4RunManagerKernel == 0 ) {
67  //--- if not create it
68  theG4RunManagerKernel = new G4RunManagerKernel();
69  G4cout << " creating G4RunManagerKernel " << theG4RunManagerKernel << G4endl;
70  }
71 
72  theG4RunManagerKernel->SetVerboseLevel(2);
73  theUserPhysicsList = 0;
74  theUserWorld = 0;
75 
76 }
77 
78 
79 //-----------------------------------------------------------------------
81 {
82 }
83 
84 
85 //-----------------------------------------------------------------------
87 {
88  theUserWorld = userInit->Construct();
89 }
90 
91 
92 //-----------------------------------------------------------------------
94 {
95  theUserWorld = userInit;
96 }
97 
98 
99 //-----------------------------------------------------------------------
101 {
102  theUserPhysicsList = userInit;
103 }
104 
105 
106 //-----------------------------------------------------------------------
108 {
109  //check if user world has been directly called or someone initialized the world volume already
110  //----- First option: geometry has been defined to GEANT4e
111  if( theUserWorld != 0 ) {
112  theG4RunManagerKernel->DefineWorldVolume( theUserWorld );
113 
114  //----- Second option: geometry has been defined to GEANT4, do nothing GEANT4 should take care
115  } else {
116  // G4cerr << "G4 TM " << G4TransportationManager::GetTransportationManager()
117  // << " NAV " << G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()
118  // << " WORLD " << G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume() << G4endl;
119  //--- Check that indeed geometry has been defined to GEANT4
121  ->GetNavigatorForTracking()->GetWorldVolume() == 0 ) {
122  G4Exception("G4ErrorRunManagerHelper::InitializeGeometry()",
123  "InvalisSetup", FatalException,
124  "No world defined in your geometry!" );
125  }
126 
127  }
128 }
129 
130 
131 //-----------------------------------------------------------------------
133 {
134 
135  G4cout << " G4ErrorRunManagerHelper::InitializePhysics " << G4endl;
136 
137  //----- First option: physics list has been defined to GEANT4e
138  if( theUserPhysicsList != 0 ) {
139  theG4RunManagerKernel->SetPhysics(theUserPhysicsList);
140  theG4RunManagerKernel->InitializePhysics();
141  }else {
142  //----- Second option: physics list has been defined to GEANT4, do nothing GEANT4 should take care
144  //--- Physics should be G4ErrorPhysicsList, else send a warning
145  if( static_cast<const G4ErrorPhysicsList*>(G4RunManager::GetRunManager()->GetUserPhysicsList()) == 0 ) {
146  G4cerr << " WARNING G4ErrorRunManagerHelper::InitializePhysics() physics list is not G4ErrorPhysicsList. Are you sure? " << G4endl;
147  }
148  } else {
149  //----- Third option: no physics list has been defined, define a G4ErrorPhysicsList
150  theG4RunManagerKernel->SetPhysics(new G4ErrorPhysicsList);
151  // theG4RunManagerKernel->SetPhysics(new ExN02PhysicsList);
152  theG4RunManagerKernel->InitializePhysics();
153  }
154  }
155 
156 }
157 
158 
159 //-----------------------------------------------------------------------
161 {
162  theG4RunManagerKernel->RunInitialization();
163 }
164 
165 
166 //-----------------------------------------------------------------------
168 {
169 
171 }
172 
173 
174 //-----------------------------------------------------------------------
176 {
178 }
179 
180 
181 //-----------------------------------------------------------------------
183 {
184  theG4RunManagerKernel->RunTermination();
185 }
186