Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TransportationManager Class Reference

#include <G4TransportationManager.hh>

Public Member Functions

G4PropagatorInFieldGetPropagatorInField () const
 
void SetPropagatorInField (G4PropagatorInField *newFieldPropagator)
 
G4FieldManagerGetFieldManager () const
 
void SetFieldManager (G4FieldManager *newFieldManager)
 
G4NavigatorGetNavigatorForTracking () const
 
void SetNavigatorForTracking (G4Navigator *newNavigator)
 
void SetWorldForTracking (G4VPhysicalVolume *theWorld)
 
size_t GetNoActiveNavigators () const
 
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator ()
 
size_t GetNoWorlds () const
 
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator ()
 
G4SafetyHelperGetSafetyHelper () const
 
G4VPhysicalVolumeGetParallelWorld (const G4String &worldName)
 
G4VPhysicalVolumeIsWorldExisting (const G4String &worldName)
 
G4NavigatorGetNavigator (const G4String &worldName)
 
G4NavigatorGetNavigator (G4VPhysicalVolume *aWorld)
 
G4bool RegisterWorld (G4VPhysicalVolume *aWorld)
 
void DeRegisterNavigator (G4Navigator *aNavigator)
 
G4int ActivateNavigator (G4Navigator *aNavigator)
 
void DeActivateNavigator (G4Navigator *aNavigator)
 
void InactivateAll ()
 
void ClearParallelWorlds ()
 
 ~G4TransportationManager ()
 

Static Public Member Functions

static G4TransportationManagerGetTransportationManager ()
 
static G4TransportationManagerGetInstanceIfExist ()
 
static G4NavigatorGetFirstTrackingNavigator ()
 
static void SetFirstTrackingNavigator (G4Navigator *nav)
 

Protected Member Functions

 G4TransportationManager ()
 

Detailed Description

Definition at line 53 of file G4TransportationManager.hh.

Constructor & Destructor Documentation

◆ ~G4TransportationManager()

G4TransportationManager::~G4TransportationManager ( )

Definition at line 90 of file G4TransportationManager.cc.

91{
92 delete fSafetyHelper;
93 delete fPropagatorInField;
94 delete fGeomMessenger;
95 ClearNavigators();
96 fTransportationManager = nullptr;
97}

◆ G4TransportationManager()

G4TransportationManager::G4TransportationManager ( )
protected

Definition at line 54 of file G4TransportationManager.cc.

55{
56 if (fTransportationManager)
57 {
58 G4Exception("G4TransportationManager::G4TransportationManager()",
59 "GeomNav0002", FatalException,
60 "Only ONE instance of G4TransportationManager is allowed!");
61 }
62
63 // Create the navigator for tracking and activate it; add to collections
64 //
65 G4Navigator* trackingNavigator= nullptr;
66 if( fFirstTrackingNavigator && fFirstTrackingNavigator->GetExternalNavigation() )
67 {
68 trackingNavigator = fFirstTrackingNavigator->Clone();
69 }
70 else
71 {
72 trackingNavigator = new G4Navigator();
73 if( fFirstTrackingNavigator == nullptr )
74 fFirstTrackingNavigator = trackingNavigator;
75 }
76 trackingNavigator->Activate(true);
77 fNavigators.push_back(trackingNavigator);
78 fActiveNavigators.push_back(trackingNavigator);
79 fWorlds.push_back(trackingNavigator->GetWorldVolume()); // NULL registered
80
81 fGeomMessenger = new G4GeometryMessenger(this);
82 fFieldManager = new G4FieldManager(); // deleted by G4FieldManagerStore
83 fPropagatorInField= new G4PropagatorInField(trackingNavigator,fFieldManager);
84 fSafetyHelper = new G4SafetyHelper();
85}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
void Activate(G4bool flag)
G4VExternalNavigation * GetExternalNavigation() const
G4Navigator * Clone() const
G4VPhysicalVolume * GetWorldVolume() const

Referenced by GetTransportationManager().

Member Function Documentation

◆ ActivateNavigator()

G4int G4TransportationManager::ActivateNavigator ( G4Navigator aNavigator)

Definition at line 313 of file G4TransportationManager.cc.

314{
315 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
316 if (pNav == fNavigators.cend())
317 {
318 G4String message
319 = "Navigator for volume -" + aNavigator->GetWorldVolume()->GetName()
320 + "- not found in memory!";
321 G4Exception("G4TransportationManager::ActivateNavigator()",
322 "GeomNav1002", FatalException, message);
323 return -1;
324 }
325
326 aNavigator->Activate(true);
327 G4int id = 0;
328 for(auto pActiveNav=fActiveNavigators.cbegin();
329 pActiveNav!=fActiveNavigators.cend(); ++pActiveNav)
330 {
331 if (*pActiveNav == aNavigator) { return id; }
332 ++id;
333 }
334
335 fActiveNavigators.push_back(aNavigator);
336 return id;
337}
int G4int
Definition: G4Types.hh:85
const G4String & GetName() const

Referenced by G4CoupledTransportation::G4CoupledTransportation(), G4SafetyHelper::InitialiseNavigator(), G4ParallelGeometriesLimiterProcess::StartTracking(), G4ImportanceProcess::StartTracking(), G4WeightCutOffProcess::StartTracking(), G4WeightWindowProcess::StartTracking(), G4FastSimulationManagerProcess::StartTracking(), G4ParallelWorldProcess::StartTracking(), G4ParallelWorldScoringProcess::StartTracking(), and G4CoupledTransportation::StartTracking().

◆ ClearParallelWorlds()

void G4TransportationManager::ClearParallelWorlds ( )

Definition at line 461 of file G4TransportationManager.cc.

462{
463 auto pNav = fNavigators.cbegin();
464 G4Navigator* trackingNavigator = *pNav;
465 for (pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
466 {
467 if (*pNav != trackingNavigator) { delete *pNav; }
468 }
469 fNavigators.clear();
470 fActiveNavigators.clear();
471 fWorlds.clear();
472
473 fNavigators.push_back(trackingNavigator);
474 fActiveNavigators.push_back(trackingNavigator);
475 fWorlds.push_back(0); // NULL registered
476}

Referenced by G4WorkerRunManager::InitializeGeometry(), and G4RunManager::ReinitializeGeometry().

◆ DeActivateNavigator()

void G4TransportationManager::DeActivateNavigator ( G4Navigator aNavigator)

Definition at line 346 of file G4TransportationManager.cc.

347{
348 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
349 if (pNav != fNavigators.cend())
350 {
351 (*pNav)->Activate(false);
352 }
353 else
354 {
355 G4String message
356 = "Navigator for volume -" + aNavigator->GetWorldVolume()->GetName()
357 + "- not found in memory!";
358 G4Exception("G4TransportationManager::DeActivateNavigator()",
359 "GeomNav1002", JustWarning, message);
360 }
361
362 auto pActiveNav = std::find(fActiveNavigators.cbegin(),
363 fActiveNavigators.cend(), aNavigator);
364 if (pActiveNav != fActiveNavigators.cend())
365 {
366 fActiveNavigators.erase(pActiveNav);
367 }
368}
@ JustWarning

Referenced by G4ParallelGeometriesLimiterProcess::EndTracking(), and G4FastSimulationManagerProcess::EndTracking().

◆ DeRegisterNavigator()

void G4TransportationManager::DeRegisterNavigator ( G4Navigator aNavigator)

Definition at line 275 of file G4TransportationManager.cc.

276{
277 if (aNavigator == fNavigators[0])
278 {
279 G4Exception("G4TransportationManager::DeRegisterNavigator()",
280 "GeomNav0003", FatalException,
281 "The navigator for tracking CANNOT be deregistered!");
282 }
283 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
284 if (pNav != fNavigators.cend())
285 {
286 // Deregister associated world volume
287 //
288 DeRegisterWorld((*pNav)->GetWorldVolume());
289
290 // Deregister the navigator
291 //
292 fNavigators.erase(pNav);
293 }
294 else
295 {
296 G4String message
297 = "Navigator for volume -" + aNavigator->GetWorldVolume()->GetName()
298 + "- not found in memory!";
299 G4Exception("G4TransportationManager::DeRegisterNavigator()",
300 "GeomNav1002", JustWarning, message);
301 }
302}

◆ GetActiveNavigatorsIterator()

◆ GetFieldManager()

◆ GetFirstTrackingNavigator()

G4Navigator * G4TransportationManager::GetFirstTrackingNavigator ( )
static

Definition at line 483 of file G4TransportationManager.cc.

484{
485 return fFirstTrackingNavigator;
486}

◆ GetInstanceIfExist()

G4TransportationManager * G4TransportationManager::GetInstanceIfExist ( )
static

Definition at line 118 of file G4TransportationManager.cc.

119{
120 return fTransportationManager;
121}

Referenced by G4RunManagerKernel::~G4RunManagerKernel().

◆ GetNavigator() [1/2]

G4Navigator * G4TransportationManager::GetNavigator ( const G4String worldName)

Definition at line 202 of file G4TransportationManager.cc.

203{
204 // If already existing, return the stored pointer to the navigator
205 //
206 for (auto pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
207 {
208 if ((*pNav)->GetWorldVolume()->GetName() == worldName) { return *pNav; }
209 }
210
211 // Check if world of that name already exists,
212 // create a navigator and register it
213 //
214 G4Navigator* aNavigator = nullptr;
215 G4VPhysicalVolume* aWorld = IsWorldExisting(worldName);
216 if(aWorld != nullptr)
217 {
218 aNavigator = new G4Navigator();
219 aNavigator->SetWorldVolume(aWorld);
220 fNavigators.push_back(aNavigator);
221 }
222 else
223 {
224 G4String message
225 = "World volume with name -" + worldName
226 + "- does not exist. Create it first by GetParallelWorld() method!";
227 G4Exception("G4TransportationManager::GetNavigator(name)",
228 "GeomNav0002", FatalException, message);
229 }
230
231 return aNavigator;
232}
void SetWorldVolume(G4VPhysicalVolume *pWorld)
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)

Referenced by G4ImportanceProcess::SetParallelWorld(), G4WeightCutOffProcess::SetParallelWorld(), G4WeightWindowProcess::SetParallelWorld(), G4ParallelWorldProcess::SetParallelWorld(), G4ParallelWorldScoringProcess::SetParallelWorld(), and G4FastSimulationManagerProcess::StartTracking().

◆ GetNavigator() [2/2]

G4Navigator * G4TransportationManager::GetNavigator ( G4VPhysicalVolume aWorld)

Definition at line 241 of file G4TransportationManager.cc.

242{
243 for (auto pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
244 {
245 if ((*pNav)->GetWorldVolume() == aWorld) { return *pNav; }
246 }
247 G4Navigator* aNavigator = nullptr;
248 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
249 if (pWorld != fWorlds.cend())
250 {
251 aNavigator = new G4Navigator();
252 aNavigator->SetWorldVolume(aWorld);
253 fNavigators.push_back(aNavigator);
254 }
255 else
256 {
257 G4String message
258 = "World volume with name -" + aWorld->GetName()
259 + "- does not exist. Create it first by GetParallelWorld() method!";
260 G4Exception("G4TransportationManager::GetNavigator(pointer)",
261 "GeomNav0002", FatalException, message);
262 }
263
264 return aNavigator;
265}

◆ GetNavigatorForTracking()

◆ GetNoActiveNavigators()

size_t G4TransportationManager::GetNoActiveNavigators ( ) const
inline

◆ GetNoWorlds()

◆ GetParallelWorld()

G4VPhysicalVolume * G4TransportationManager::GetParallelWorld ( const G4String worldName)

Definition at line 178 of file G4TransportationManager.cc.

179{
180 G4VPhysicalVolume* wPV = IsWorldExisting(worldName);
181 if (wPV == nullptr)
182 {
184 G4LogicalVolume* wLV = wPV->GetLogicalVolume();
185 wLV = new G4LogicalVolume(wLV->GetSolid(), nullptr,
186 worldName);
187 wPV = new G4PVPlacement (wPV->GetRotation(),
188 wPV->GetTranslation(),
189 wLV, worldName, nullptr, false, 0);
190 RegisterWorld(wPV);
191 }
192 return wPV;
193}
G4VSolid * GetSolid() const
G4bool RegisterWorld(G4VPhysicalVolume *aWorld)
G4Navigator * GetNavigatorForTracking() const
const G4RotationMatrix * GetRotation() const
const G4ThreeVector GetTranslation() const
G4LogicalVolume * GetLogicalVolume() const

Referenced by G4ParallelWorldPhysics::ConstructProcess(), G4RunManager::ConstructScoringWorlds(), G4ImportanceConfigurator::G4ImportanceConfigurator(), G4VUserParallelWorld::GetWorld(), G4FastSimHitMaker::make(), GFlashHitMaker::make(), G4ImportanceProcess::SetParallelWorld(), G4WeightCutOffProcess::SetParallelWorld(), G4WeightWindowProcess::SetParallelWorld(), G4ParallelWorldProcess::SetParallelWorld(), G4ParallelWorldScoringProcess::SetParallelWorld(), G4IStore::SetParallelWorldVolume(), and G4WeightWindowStore::SetParallelWorldVolume().

◆ GetPropagatorInField()

◆ GetSafetyHelper()

◆ GetTransportationManager()

G4TransportationManager * G4TransportationManager::GetTransportationManager ( )
static

Definition at line 104 of file G4TransportationManager.cc.

105{
106 if (fTransportationManager == nullptr)
107 {
108 fTransportationManager = new G4TransportationManager;
109 }
110 return fTransportationManager;
111}

Referenced by G4Scene::AddWorldIfEmpty(), G4RayTrajectory::AppendStep(), G4DecayWithSpin::AtRestDoIt(), G4ErrorSurfaceTrajState::BuildErrorMatrix(), G4RunManagerKernel::CheckRegions(), G4VPrimaryGenerator::CheckVertexInsideWorld(), G4AdjointPrimaryGenerator::ComputeAccumulatedDepthVectorAlongBackRay(), G4ParallelWorldPhysics::ConstructProcess(), G4MTRunManager::ConstructScoringWorlds(), G4RunManager::ConstructScoringWorlds(), G4WorkerRunManager::ConstructScoringWorlds(), G4TaskRunManager::ConstructScoringWorlds(), G4TheRayTracer::CreateBitMap(), G4RunManagerKernel::DefineWorldVolume(), G4VFieldModel::DescribeYourselfTo(), G4ITTransportation::DoesGlobalFieldExist(), G4TrajectoryDrawByOriginVolume::Draw(), G4DrawVoxels::DrawVoxels(), G4CoupledTransportation::EndTracking(), G4TrajectoryOriginVolumeFilter::Evaluate(), G4TouchableUtils::FindTouchableProperties(), G4CoupledTransportation::G4CoupledTransportation(), G4ElNeutrinoNucleusProcess::G4ElNeutrinoNucleusProcess(), G4ErrorFreeTrajState::G4ErrorFreeTrajState(), G4FastSimulationManagerProcess::G4FastSimulationManagerProcess(), G4GeometrySampler::G4GeometrySampler(), G4ImportanceConfigurator::G4ImportanceConfigurator(), G4ImportanceProcess::G4ImportanceProcess(), G4ITTransportation::G4ITTransportation(), G4MultiNavigator::G4MultiNavigator(), G4MuNeutrinoNucleusProcess::G4MuNeutrinoNucleusProcess(), G4NeutrinoElectronProcess::G4NeutrinoElectronProcess(), G4ParallelGeometriesLimiterProcess::G4ParallelGeometriesLimiterProcess(), G4ParallelWorldProcess::G4ParallelWorldProcess(), G4ParallelWorldScoringProcess::G4ParallelWorldScoringProcess(), G4PathFinder::G4PathFinder(), G4SteppingManager::G4SteppingManager(), G4SynchrotronRadiation::G4SynchrotronRadiation(), G4SynchrotronRadiationInMat::G4SynchrotronRadiationInMat(), G4Transportation::G4Transportation(), G4VEnergyLossProcess::G4VEnergyLossProcess(), G4WeightCutOffProcess::G4WeightCutOffProcess(), G4WeightWindowProcess::G4WeightWindowProcess(), G4VisManager::GeometryHasChanged(), G4VMscModel::GetParticleChangeForMSC(), G4VUserParallelWorld::GetWorld(), G4ErrorPropagatorManager::InitFieldForBackwards(), G4TDNAOneStepThermalizationModel< MODEL >::Initialise(), G4SafetyHelper::InitialiseNavigator(), G4BOptnForceCommonTruncatedExp::Initialize(), G4ErrorRunManagerHelper::InitializeGeometry(), G4WorkerRunManager::InitializeGeometry(), G4FastSimulationManager::ListTitle(), G4FastSimHitMaker::make(), GFlashHitMaker::make(), G4UCNBoundaryProcess::PostStepDoIt(), G4MicroElecSurface::PostStepDoIt(), G4OpBoundaryProcess::PostStepDoIt(), G4VTransitionRadiation::PostStepDoIt(), G4ErrorMagFieldLimitProcess::PostStepGetPhysicalInteractionLength(), G4VMultipleScattering::PreparePhysicsTable(), G4ErrorFreeTrajState::PropagateError(), G4RunManager::ReinitializeGeometry(), G4VisCommandSceneAddVolume::SetNewValue(), G4VisCommandSetTouchable::SetNewValue(), G4VisCommandSetVolumeForField::SetNewValue(), G4VisCommandsTouchable::SetNewValue(), G4VisCommandViewerCentreOn::SetNewValue(), G4TrackingMessenger::SetNewValue(), G4IStore::SetParallelWorldVolume(), G4WeightWindowStore::SetParallelWorldVolume(), G4RTPrimaryGeneratorAction::SetUp(), G4IStore::SetWorldVolume(), G4WeightWindowStore::SetWorldVolume(), G4GlobalFastSimulationManager::ShowSetup(), G4FastSimulationManagerProcess::StartTracking(), G4CoupledTransportation::StartTracking(), G4PhysicalVolumeModel::Validate(), G4RunManagerKernel::WorkerDefineWorldVolume(), and G4RunManagerKernel::WorkerUpdateWorldVolume().

◆ GetWorldsIterator()

◆ InactivateAll()

void G4TransportationManager::InactivateAll ( )

Definition at line 376 of file G4TransportationManager.cc.

377{
378 for (auto pNav=fActiveNavigators.cbegin();
379 pNav!=fActiveNavigators.cend(); ++pNav)
380 {
381 (*pNav)->Activate(false);
382 }
383 fActiveNavigators.clear();
384
385 // Restore status for the navigator for tracking
386 //
387 fNavigators[0]->Activate(true);
388 fActiveNavigators.push_back(fNavigators[0]);
389}

Referenced by G4CoupledTransportation::EndTracking().

◆ IsWorldExisting()

G4VPhysicalVolume * G4TransportationManager::IsWorldExisting ( const G4String worldName)

Definition at line 398 of file G4TransportationManager.cc.

399{
400 auto pWorld = fWorlds.begin();
401 if ( *pWorld==nullptr ) { *pWorld=fNavigators[0]->GetWorldVolume(); }
402
403 for (auto cpWorld=fWorlds.cbegin(); cpWorld!=fWorlds.cend(); ++cpWorld)
404 {
405 if ((*cpWorld)->GetName() == name ) { return *cpWorld; }
406 }
407 return 0;
408}

Referenced by G4ParallelGeometriesLimiterProcess::AddParallelWorld(), G4RunManager::ConstructScoringWorlds(), G4WorkerRunManager::ConstructScoringWorlds(), GetNavigator(), GetParallelWorld(), G4ParallelGeometriesLimiterProcess::GetParallelWorldIndex(), G4ParallelGeometriesLimiterProcess::RemoveParallelWorld(), G4FastSimulationManagerProcess::SetWorldVolume(), and G4RunManagerKernel::WorkerUpdateWorldVolume().

◆ RegisterWorld()

G4bool G4TransportationManager::RegisterWorld ( G4VPhysicalVolume aWorld)

Definition at line 417 of file G4TransportationManager.cc.

418{
419 G4bool done = false;
420
421 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
422 if (pWorld == fWorlds.cend())
423 {
424 fWorlds.push_back(aWorld);
425 done = true;
426 }
427 return done;
428}
bool G4bool
Definition: G4Types.hh:86

Referenced by GetParallelWorld(), G4RunManagerKernel::WorkerDefineWorldVolume(), and G4RunManagerKernel::WorkerUpdateWorldVolume().

◆ SetFieldManager()

void G4TransportationManager::SetFieldManager ( G4FieldManager newFieldManager)

Definition at line 128 of file G4TransportationManager.cc.

129{
130 fFieldManager = newFieldManager;
131
132 // Message the PropagatorInField,
133 // which also maintains this information (to be reviewed)
134 //
135 if( fPropagatorInField )
136 {
137 fPropagatorInField -> SetDetectorFieldManager( newFieldManager );
138 }
139}

◆ SetFirstTrackingNavigator()

void G4TransportationManager::SetFirstTrackingNavigator ( G4Navigator nav)
static

Definition at line 493 of file G4TransportationManager.cc.

494{
495 fFirstTrackingNavigator= nav;
496}

◆ SetNavigatorForTracking()

void G4TransportationManager::SetNavigatorForTracking ( G4Navigator newNavigator)

Definition at line 147 of file G4TransportationManager.cc.

148{
149 fNavigators[0] = newNavigator;
150 fActiveNavigators[0] = newNavigator;
151 fPropagatorInField->SetNavigatorForPropagating(newNavigator);
152}
void SetNavigatorForPropagating(G4Navigator *SimpleOrMultiNavigator)

◆ SetPropagatorInField()

void G4TransportationManager::SetPropagatorInField ( G4PropagatorInField newFieldPropagator)
inline

◆ SetWorldForTracking()

void G4TransportationManager::SetWorldForTracking ( G4VPhysicalVolume theWorld)
inline

The documentation for this class was generated from the following files: