Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TransportationManager.hh
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// G4TransportationManager
27//
28// Class description:
29//
30// A singleton class which stores the (volume) navigator used by
31// the transportation process to do the geometrical tracking.
32// It also stores a pointer to the propagator used in a (magnetic)
33// field and to the field manager.
34// The class instance is created before main() is called, and
35// in turn creates the navigator and the rest.
36
37// Created: John Apostolakis (CERN), 10 March 1997
38// Reviewed: Gabriele Cosmo (CERN), 26 April 2006
39// --------------------------------------------------------------------
40#ifndef G4TransportationManager_hh
41#define G4TransportationManager_hh 1
42
43#include "G4Navigator.hh"
44#include "G4SafetyHelper.hh"
45
46#include <vector>
47
50class G4FieldManager;
52
53/**
54 * @brief G4TransportationManager is a singleton class which stores the
55 * navigator used by the transportation process to do the geometrical tracking.
56 * It also stores a pointer to the propagator used in a (magnetic) field and
57 * to the field manager.
58 */
59
60class G4TransportationManager
61{
62 public:
63
64 /**
65 * Retrieve the static instance.
66 */
67 static G4TransportationManager* GetTransportationManager();
68
69 /**
70 * Retrieve singleton instance pointer.
71 */
72 static G4TransportationManager* GetInstanceIfExist();
73
74 /**
75 * Accessors and modifiers for field handling.
76 */
78 inline void SetPropagatorInField(G4PropagatorInField* newFieldPropagator);
80 void SetFieldManager( G4FieldManager* newFieldManager );
81
82 /**
83 * Accessor and modifier for the navigator for tracking.
84 */
86 void SetNavigatorForTracking( G4Navigator* newNavigator );
87
88 /**
89 * Sets the world volume for tracking.
90 * This method is to be invoked by G4RunManagerKernel.
91 */
92 inline void SetWorldForTracking(G4VPhysicalVolume* theWorld);
93
94 /**
95 * Accessors for the active navigators.
96 * @returns An iterator to the list of active navigators.
97 */
98 inline std::vector<G4Navigator*>::iterator GetActiveNavigatorsIterator();
99 inline std::size_t GetNoActiveNavigators() const;
100
101 /**
102 * Accessors for the registered worlds.
103 * @returns An iterator to the list of registered worlds.
104 */
105 inline std::vector<G4VPhysicalVolume*>::iterator GetWorldsIterator();
106 inline std::size_t GetNoWorlds() const;
107
108 /**
109 * Returns the pointer to the navigation safety helper instance.
110 * @returns Pointer to the navigation safety helper instance.
111 */
113
114 /**
115 * Returns an exact copy of the tracking world volume.
116 * If already existing just returns the pointer.
117 * @returns Pointer to the tracking world volume.
118 */
119 G4VPhysicalVolume* GetParallelWorld ( const G4String& worldName );
120
121 /**
122 * Verifies existance or not of an istance of the world volume with
123 * same name in the collection.
124 * @returns Pointer to the tracking world volume.
125 */
126 G4VPhysicalVolume* IsWorldExisting ( const G4String& worldName );
127
128 /**
129 * Returns a navigator associated to either the world volume name
130 * or associated to the pointer to the world physical volume.
131 * If not existing already, creates it and registers it in the collection.
132 * @returns Pointer to a tracking navigator.
133 */
134 G4Navigator* GetNavigator ( const G4String& worldName );
136
137 /**
138 * Methods for handling navigators. Navigator for tracking is always the
139 * first (i.e. position 0 in the collection) and cannot be de-registered.
140 */
142 void DeRegisterNavigator( G4Navigator* aNavigator );
143 G4int ActivateNavigator( G4Navigator* aNavigator );
144 void DeActivateNavigator( G4Navigator* aNavigator );
145 void InactivateAll();
146
147 /**
148 * Accessor and modifier for the tracking navigator.
149 * Retrieves/sets the first navigator pointer for the 'mass' geometry.
150 * It will be used as a template for cloning the tracking navigator of
151 * additional threads.
152 */
154 static void SetFirstTrackingNavigator(G4Navigator *nav);
155
156 /**
157 * Clears collection of navigators and deletes the allocated objects
158 * associated with parallel worlds. Internal method, called only
159 * by the RunManager when the entire geometry is rebuilt from scratch.
160 */
161 void ClearParallelWorlds();
162
163 /**
164 * Destructor. Called internally only by G4RunManagerKernel.
165 */
167
168 public:
169
170 /** Navigator identifier. Accessed by G4CoupledTransportation. */
171 static constexpr G4int kMassNavigatorId = 0;
172
173 private:
174
175 /**
176 * Private Constructor.
177 */
178 G4TransportationManager();
179
180 /**
181 * Clears collection of navigators and deletes allocated objects.
182 */
183 void ClearNavigators();
184
185 /**
186 * De-registers an already allocated world volume.
187 * The pointed object is not deleted.
188 */
189 void DeRegisterWorld( G4VPhysicalVolume* aWorld );
190
191 private:
192
193 /** The collection of all navigators registered. */
194 std::vector<G4Navigator*> fNavigators;
195
196 /** The collection of only active navigators. */
197 std::vector<G4Navigator*> fActiveNavigators;
198
199 /** The collection of worlds associated to the registered navigators. */
200 std::vector<G4VPhysicalVolume*> fWorlds;
201
202 G4PropagatorInField* fPropagatorInField;
203 G4FieldManager* fFieldManager;
204 G4GeometryMessenger* fGeomMessenger;
205 G4SafetyHelper* fSafetyHelper;
206
207 static G4ThreadLocal G4TransportationManager* fTransportationManager;
208
209 static G4Navigator* fFirstTrackingNavigator;
210};
211
212#include "G4TransportationManager.icc"
213
214#endif
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4FieldManager is a manager (store) for a pointer to the Field subclass that describes the field of a...
G4GeometryMessenger is a messenger defining commands for debugging, verifying and controlling the det...
G4Navigator is a class for use by the tracking management, able to obtain/calculate dynamic tracking ...
G4PropagatorInField performs the navigation/propagation of a particle/track in a magnetic field....
G4SafetyHelper is a helper class for physics processes which require knowledge of the safety,...
G4bool RegisterWorld(G4VPhysicalVolume *aWorld)
static constexpr G4int kMassNavigatorId
std::size_t GetNoActiveNavigators() const
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator()
G4VPhysicalVolume * GetParallelWorld(const G4String &worldName)
static G4TransportationManager * GetTransportationManager()
void SetFieldManager(G4FieldManager *newFieldManager)
static G4TransportationManager * GetInstanceIfExist()
static void SetFirstTrackingNavigator(G4Navigator *nav)
G4PropagatorInField * GetPropagatorInField() const
G4SafetyHelper * GetSafetyHelper() const
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
void SetWorldForTracking(G4VPhysicalVolume *theWorld)
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
void SetPropagatorInField(G4PropagatorInField *newFieldPropagator)
G4Navigator * GetNavigatorForTracking() const
G4int ActivateNavigator(G4Navigator *aNavigator)
void DeActivateNavigator(G4Navigator *aNavigator)
G4Navigator * GetNavigator(const G4String &worldName)
std::size_t GetNoWorlds() const
G4FieldManager * GetFieldManager() const
void DeRegisterNavigator(G4Navigator *aNavigator)
void SetNavigatorForTracking(G4Navigator *newNavigator)
static G4Navigator * GetFirstTrackingNavigator()
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
#define G4ThreadLocal
Definition tls.hh:77