45G4TransportationManager::fTransportationManager =
nullptr;
49G4Navigator* G4TransportationManager::fFirstTrackingNavigator=
nullptr;
56 if (fTransportationManager)
58 G4Exception(
"G4TransportationManager::G4TransportationManager()",
60 "Only ONE instance of G4TransportationManager is allowed!");
68 trackingNavigator = fFirstTrackingNavigator->
Clone();
73 if( fFirstTrackingNavigator ==
nullptr )
74 fFirstTrackingNavigator = trackingNavigator;
77 fNavigators.push_back(trackingNavigator);
78 fActiveNavigators.push_back(trackingNavigator);
93 delete fPropagatorInField;
94 delete fGeomMessenger;
96 fTransportationManager =
nullptr;
106 if (fTransportationManager ==
nullptr)
110 return fTransportationManager;
120 return fTransportationManager;
130 fFieldManager = newFieldManager;
135 if( fPropagatorInField )
137 fPropagatorInField -> SetDetectorFieldManager( newFieldManager );
149 fNavigators[0] = newNavigator;
150 fActiveNavigators[0] = newNavigator;
160void G4TransportationManager::ClearNavigators()
162 for (
auto pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
167 fActiveNavigators.clear();
189 wLV, worldName,
nullptr,
false, 0);
206 for (
auto pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
208 if ((*pNav)->GetWorldVolume()->GetName() == worldName) {
return *pNav; }
216 if(aWorld !=
nullptr)
220 fNavigators.push_back(aNavigator);
225 =
"World volume with name -" + worldName
226 +
"- does not exist. Create it first by GetParallelWorld() method!";
227 G4Exception(
"G4TransportationManager::GetNavigator(name)",
243 for (
auto pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
245 if ((*pNav)->GetWorldVolume() == aWorld) {
return *pNav; }
248 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
249 if (pWorld != fWorlds.cend())
253 fNavigators.push_back(aNavigator);
258 =
"World volume with name -" + aWorld->
GetName()
259 +
"- does not exist. Create it first by GetParallelWorld() method!";
260 G4Exception(
"G4TransportationManager::GetNavigator(pointer)",
277 if (aNavigator == fNavigators[0])
279 G4Exception(
"G4TransportationManager::DeRegisterNavigator()",
281 "The navigator for tracking CANNOT be deregistered!");
283 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
284 if (pNav != fNavigators.cend())
288 DeRegisterWorld((*pNav)->GetWorldVolume());
292 fNavigators.erase(pNav);
298 +
"- not found in memory!";
299 G4Exception(
"G4TransportationManager::DeRegisterNavigator()",
315 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
316 if (pNav == fNavigators.cend())
320 +
"- not found in memory!";
321 G4Exception(
"G4TransportationManager::ActivateNavigator()",
328 for(
auto pActiveNav=fActiveNavigators.cbegin();
329 pActiveNav!=fActiveNavigators.cend(); ++pActiveNav)
331 if (*pActiveNav == aNavigator) {
return id; }
335 fActiveNavigators.push_back(aNavigator);
348 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
349 if (pNav != fNavigators.cend())
351 (*pNav)->Activate(
false);
357 +
"- not found in memory!";
358 G4Exception(
"G4TransportationManager::DeActivateNavigator()",
362 auto pActiveNav = std::find(fActiveNavigators.cbegin(),
363 fActiveNavigators.cend(), aNavigator);
364 if (pActiveNav != fActiveNavigators.cend())
366 fActiveNavigators.erase(pActiveNav);
378 for (
auto pNav=fActiveNavigators.cbegin();
379 pNav!=fActiveNavigators.cend(); ++pNav)
381 (*pNav)->Activate(
false);
383 fActiveNavigators.clear();
387 fNavigators[0]->Activate(
true);
388 fActiveNavigators.push_back(fNavigators[0]);
400 auto pWorld = fWorlds.begin();
401 if ( *pWorld==
nullptr ) { *pWorld=fNavigators[0]->GetWorldVolume(); }
403 for (
auto cpWorld=fWorlds.cbegin(); cpWorld!=fWorlds.cend(); ++cpWorld)
405 if ((*cpWorld)->GetName() == name ) {
return *cpWorld; }
421 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
422 if (pWorld == fWorlds.cend())
424 fWorlds.push_back(aWorld);
439 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
440 if (pWorld != fWorlds.cend())
442 fWorlds.erase(pWorld);
447 =
"World volume -" + aWorld->
GetName() +
"- not found in memory!";
448 G4Exception(
"G4TransportationManager::DeRegisterWorld()",
463 auto pNav = fNavigators.cbegin();
465 for (pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
467 if (*pNav != trackingNavigator) {
delete *pNav; }
470 fActiveNavigators.clear();
473 fNavigators.push_back(trackingNavigator);
474 fActiveNavigators.push_back(trackingNavigator);
475 fWorlds.push_back(0);
485 return fFirstTrackingNavigator;
495 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