45G4TransportationManager::fTransportationManager =
nullptr;
49G4Navigator* G4TransportationManager::fFirstTrackingNavigator=
nullptr;
56 if (fTransportationManager !=
nullptr)
58 G4Exception(
"G4TransportationManager::G4TransportationManager()",
60 "Only ONE instance of G4TransportationManager is allowed!");
66 if( (fFirstTrackingNavigator !=
nullptr) && (fFirstTrackingNavigator->GetExternalNavigation() !=
nullptr) )
68 trackingNavigator = fFirstTrackingNavigator->
Clone();
73 if( fFirstTrackingNavigator ==
nullptr )
75 fFirstTrackingNavigator = trackingNavigator;
79 fNavigators.push_back(trackingNavigator);
80 fActiveNavigators.push_back(trackingNavigator);
97 delete fPropagatorInField;
98 delete fGeomMessenger;
100 fTransportationManager =
nullptr;
110 if (fTransportationManager ==
nullptr)
114 return fTransportationManager;
124 return fTransportationManager;
134 fFieldManager = newFieldManager;
140 if( fPropagatorInField !=
nullptr )
142 fPropagatorInField -> SetDetectorFieldManager( newFieldManager );
154 fNavigators[0] = newNavigator;
155 fActiveNavigators[0] = newNavigator;
156 fPropagatorInField->SetNavigatorForPropagating(newNavigator);
165void G4TransportationManager::ClearNavigators()
167 for (
const auto & fNavigator : fNavigators)
172 fActiveNavigators.clear();
194 wLV, worldName,
nullptr,
false, 0);
211 for (
const auto & fNavigator : fNavigators)
213 if (fNavigator->GetWorldVolume()->GetName() == worldName)
224 if(aWorld !=
nullptr)
228 fNavigators.push_back(aNavigator);
233 =
"World volume with name -" + worldName
234 +
"- does not exist. Create it first by GetParallelWorld() method!";
235 G4Exception(
"G4TransportationManager::GetNavigator(name)",
251 for (
const auto & fNavigator : fNavigators)
253 if (fNavigator->GetWorldVolume() == aWorld) {
return fNavigator; }
256 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
257 if (pWorld != fWorlds.cend())
261 fNavigators.push_back(aNavigator);
266 =
"World volume with name -" + aWorld->
GetName()
267 +
"- does not exist. Create it first by GetParallelWorld() method!";
268 G4Exception(
"G4TransportationManager::GetNavigator(pointer)",
285 if (aNavigator == fNavigators[0])
287 G4Exception(
"G4TransportationManager::DeRegisterNavigator()",
289 "The navigator for tracking CANNOT be deregistered!");
291 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
292 if (pNav != fNavigators.cend())
296 DeRegisterWorld((*pNav)->GetWorldVolume());
300 fNavigators.erase(pNav);
306 +
"- not found in memory!";
307 G4Exception(
"G4TransportationManager::DeRegisterNavigator()",
323 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
324 if (pNav == fNavigators.cend())
328 +
"- not found in memory!";
329 G4Exception(
"G4TransportationManager::ActivateNavigator()",
336 for(
const auto & fActiveNavigator : fActiveNavigators)
338 if (fActiveNavigator == aNavigator) {
return id; }
342 fActiveNavigators.push_back(aNavigator);
355 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
356 if (pNav != fNavigators.cend())
358 (*pNav)->Activate(
false);
364 +
"- not found in memory!";
365 G4Exception(
"G4TransportationManager::DeActivateNavigator()",
369 auto pActiveNav = std::find(fActiveNavigators.cbegin(),
370 fActiveNavigators.cend(), aNavigator);
371 if (pActiveNav != fActiveNavigators.cend())
373 fActiveNavigators.erase(pActiveNav);
385 for (
const auto & fActiveNavigator : fActiveNavigators)
387 fActiveNavigator->Activate(
false);
389 fActiveNavigators.clear();
393 fNavigators[0]->Activate(
true);
394 fActiveNavigators.push_back(fNavigators[0]);
406 auto pWorld = fWorlds.begin();
407 if ( *pWorld==
nullptr ) { *pWorld=fNavigators[0]->GetWorldVolume(); }
409 for (
const auto & fWorld : fWorlds)
411 if (fWorld->GetName() == name ) {
return fWorld; }
427 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
428 if (pWorld == fWorlds.cend())
430 fWorlds.push_back(aWorld);
445 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
446 if (pWorld != fWorlds.cend())
448 fWorlds.erase(pWorld);
453 =
"World volume -" + aWorld->
GetName() +
"- not found in memory!";
454 G4Exception(
"G4TransportationManager::DeRegisterWorld()",
469 auto pNav = fNavigators.cbegin();
471 for (pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
473 if (*pNav != trackingNavigator) {
delete *pNav; }
476 fActiveNavigators.clear();
479 fNavigators.push_back(trackingNavigator);
480 fActiveNavigators.push_back(trackingNavigator);
481 fWorlds.push_back(
nullptr);
491 return fFirstTrackingNavigator;
501 fFirstTrackingNavigator= nav;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static void SetGlobalFieldManager(G4FieldManager *fieldManager)
G4VSolid * GetSolid() const
void Activate(G4bool flag)
G4Navigator * Clone() const
void SetWorldVolume(G4VPhysicalVolume *pWorld)
G4VPhysicalVolume * GetWorldVolume() const
G4TransportationManager()
G4bool RegisterWorld(G4VPhysicalVolume *aWorld)
G4VPhysicalVolume * GetParallelWorld(const G4String &worldName)
static G4TransportationManager * GetTransportationManager()
void SetFieldManager(G4FieldManager *newFieldManager)
static G4TransportationManager * GetInstanceIfExist()
static void SetFirstTrackingNavigator(G4Navigator *nav)
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
G4Navigator * GetNavigatorForTracking() const
~G4TransportationManager()
G4int ActivateNavigator(G4Navigator *aNavigator)
void DeActivateNavigator(G4Navigator *aNavigator)
G4Navigator * GetNavigator(const G4String &worldName)
void ClearParallelWorlds()
void DeRegisterNavigator(G4Navigator *aNavigator)
void SetNavigatorForTracking(G4Navigator *newNavigator)
static G4Navigator * GetFirstTrackingNavigator()
const G4RotationMatrix * GetRotation() const
const G4ThreeVector GetTranslation() const
G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const