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);
95 delete fPropagatorInField;
96 delete fGeomMessenger;
98 fTransportationManager =
nullptr;
108 if (fTransportationManager ==
nullptr)
112 return fTransportationManager;
122 return fTransportationManager;
132 fFieldManager = newFieldManager;
137 if( fPropagatorInField !=
nullptr )
139 fPropagatorInField -> SetDetectorFieldManager( newFieldManager );
151 fNavigators[0] = newNavigator;
152 fActiveNavigators[0] = newNavigator;
162void G4TransportationManager::ClearNavigators()
164 for (
const auto & fNavigator : fNavigators)
169 fActiveNavigators.clear();
191 wLV, worldName,
nullptr,
false, 0);
208 for (
const auto & fNavigator : fNavigators)
210 if (fNavigator->GetWorldVolume()->GetName() == worldName)
221 if(aWorld !=
nullptr)
225 fNavigators.push_back(aNavigator);
230 =
"World volume with name -" + worldName
231 +
"- does not exist. Create it first by GetParallelWorld() method!";
232 G4Exception(
"G4TransportationManager::GetNavigator(name)",
248 for (
const auto & fNavigator : fNavigators)
250 if (fNavigator->GetWorldVolume() == aWorld) {
return fNavigator; }
253 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
254 if (pWorld != fWorlds.cend())
258 fNavigators.push_back(aNavigator);
263 =
"World volume with name -" + aWorld->
GetName()
264 +
"- does not exist. Create it first by GetParallelWorld() method!";
265 G4Exception(
"G4TransportationManager::GetNavigator(pointer)",
282 if (aNavigator == fNavigators[0])
284 G4Exception(
"G4TransportationManager::DeRegisterNavigator()",
286 "The navigator for tracking CANNOT be deregistered!");
288 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
289 if (pNav != fNavigators.cend())
293 DeRegisterWorld((*pNav)->GetWorldVolume());
297 fNavigators.erase(pNav);
303 +
"- not found in memory!";
304 G4Exception(
"G4TransportationManager::DeRegisterNavigator()",
320 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
321 if (pNav == fNavigators.cend())
325 +
"- not found in memory!";
326 G4Exception(
"G4TransportationManager::ActivateNavigator()",
333 for(
const auto & fActiveNavigator : fActiveNavigators)
335 if (fActiveNavigator == aNavigator) {
return id; }
339 fActiveNavigators.push_back(aNavigator);
352 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
353 if (pNav != fNavigators.cend())
355 (*pNav)->Activate(
false);
361 +
"- not found in memory!";
362 G4Exception(
"G4TransportationManager::DeActivateNavigator()",
366 auto pActiveNav = std::find(fActiveNavigators.cbegin(),
367 fActiveNavigators.cend(), aNavigator);
368 if (pActiveNav != fActiveNavigators.cend())
370 fActiveNavigators.erase(pActiveNav);
382 for (
const auto & fActiveNavigator : fActiveNavigators)
384 fActiveNavigator->Activate(
false);
386 fActiveNavigators.clear();
390 fNavigators[0]->Activate(
true);
391 fActiveNavigators.push_back(fNavigators[0]);
403 auto pWorld = fWorlds.begin();
404 if ( *pWorld==
nullptr ) { *pWorld=fNavigators[0]->GetWorldVolume(); }
406 for (
const auto & fWorld : fWorlds)
408 if (fWorld->GetName() == name ) {
return fWorld; }
424 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
425 if (pWorld == fWorlds.cend())
427 fWorlds.push_back(aWorld);
442 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
443 if (pWorld != fWorlds.cend())
445 fWorlds.erase(pWorld);
450 =
"World volume -" + aWorld->
GetName() +
"- not found in memory!";
451 G4Exception(
"G4TransportationManager::DeRegisterWorld()",
466 auto pNav = fNavigators.cbegin();
468 for (pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
470 if (*pNav != trackingNavigator) {
delete *pNav; }
473 fActiveNavigators.clear();
476 fNavigators.push_back(trackingNavigator);
477 fActiveNavigators.push_back(trackingNavigator);
478 fWorlds.push_back(
nullptr);
488 return fFirstTrackingNavigator;
498 fFirstTrackingNavigator= nav;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4VSolid * GetSolid() const
void Activate(G4bool flag)
G4VExternalNavigation * GetExternalNavigation() const
G4Navigator * Clone() const
void SetWorldVolume(G4VPhysicalVolume *pWorld)
G4VPhysicalVolume * GetWorldVolume() const
void SetNavigatorForPropagating(G4Navigator *SimpleOrMultiNavigator)
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