Geant4 11.3.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)
 
std::size_t GetNoActiveNavigators () const
 
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator ()
 
std::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)
 

Static Public Attributes

static constexpr G4int kMassNavigatorId = 0
 

Protected Member Functions

 G4TransportationManager ()
 

Detailed Description

Definition at line 53 of file G4TransportationManager.hh.

Constructor & Destructor Documentation

◆ ~G4TransportationManager()

G4TransportationManager::~G4TransportationManager ( )

Definition at line 94 of file G4TransportationManager.cc.

95{
96 delete fSafetyHelper;
97 delete fPropagatorInField;
98 delete fGeomMessenger;
99 ClearNavigators();
100 fTransportationManager = nullptr;
101}

◆ G4TransportationManager()

G4TransportationManager::G4TransportationManager ( )
protected

Definition at line 54 of file G4TransportationManager.cc.

55{
56 if (fTransportationManager != nullptr)
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 != nullptr) && (fFirstTrackingNavigator->GetExternalNavigation() != nullptr) )
67 {
68 trackingNavigator = fFirstTrackingNavigator->Clone();
69 }
70 else
71 {
72 trackingNavigator = new G4Navigator();
73 if( fFirstTrackingNavigator == nullptr )
74 {
75 fFirstTrackingNavigator = trackingNavigator;
76 }
77 }
78 trackingNavigator->Activate(true);
79 fNavigators.push_back(trackingNavigator);
80 fActiveNavigators.push_back(trackingNavigator);
81 fWorlds.push_back(trackingNavigator->GetWorldVolume()); // NULL registered
82
83 fGeomMessenger = new G4GeometryMessenger(this);
84 fFieldManager = new G4FieldManager(); // deleted by G4FieldManagerStore
85 fPropagatorInField= new G4PropagatorInField(trackingNavigator,fFieldManager);
86 fSafetyHelper = new G4SafetyHelper();
87
89}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static void SetGlobalFieldManager(G4FieldManager *fieldManager)
void Activate(G4bool flag)
G4Navigator * Clone() const
G4VPhysicalVolume * GetWorldVolume() const

Referenced by GetInstanceIfExist(), GetSafetyHelper(), and GetTransportationManager().

Member Function Documentation

◆ ActivateNavigator()

G4int G4TransportationManager::ActivateNavigator ( G4Navigator * aNavigator)

Definition at line 321 of file G4TransportationManager.cc.

322{
323 auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
324 if (pNav == fNavigators.cend())
325 {
326 G4String message
327 = "Navigator for volume -" + aNavigator->GetWorldVolume()->GetName()
328 + "- not found in memory!";
329 G4Exception("G4TransportationManager::ActivateNavigator()",
330 "GeomNav1002", FatalException, message);
331 return -1;
332 }
333
334 aNavigator->Activate(true);
335 G4int id = 0;
336 for(const auto & fActiveNavigator : fActiveNavigators)
337 {
338 if (fActiveNavigator == aNavigator) { return id; }
339 ++id;
340 }
341
342 fActiveNavigators.push_back(aNavigator);
343 return id;
344}
int G4int
Definition G4Types.hh:85
const G4String & GetName() const

Referenced by G4FastSimulationManagerProcess::StartTracking().

◆ ClearParallelWorlds()

void G4TransportationManager::ClearParallelWorlds ( )

Definition at line 467 of file G4TransportationManager.cc.

468{
469 auto pNav = fNavigators.cbegin();
470 G4Navigator* trackingNavigator = *pNav;
471 for (pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
472 {
473 if (*pNav != trackingNavigator) { delete *pNav; }
474 }
475 fNavigators.clear();
476 fActiveNavigators.clear();
477 fWorlds.clear();
478
479 fNavigators.push_back(trackingNavigator);
480 fActiveNavigators.push_back(trackingNavigator);
481 fWorlds.push_back(nullptr); // NULL registered
482}

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

◆ DeActivateNavigator()

void G4TransportationManager::DeActivateNavigator ( G4Navigator * aNavigator)

Definition at line 353 of file G4TransportationManager.cc.

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

◆ DeRegisterNavigator()

void G4TransportationManager::DeRegisterNavigator ( G4Navigator * aNavigator)

Definition at line 283 of file G4TransportationManager.cc.

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

◆ GetActiveNavigatorsIterator()

std::vector< G4Navigator * >::iterator G4TransportationManager::GetActiveNavigatorsIterator ( )
inline

◆ GetFieldManager()

◆ GetFirstTrackingNavigator()

G4Navigator * G4TransportationManager::GetFirstTrackingNavigator ( )
static

Definition at line 489 of file G4TransportationManager.cc.

490{
491 return fFirstTrackingNavigator;
492}

◆ GetInstanceIfExist()

G4TransportationManager * G4TransportationManager::GetInstanceIfExist ( )
static

Definition at line 122 of file G4TransportationManager.cc.

123{
124 return fTransportationManager;
125}

Referenced by G4RunManagerKernel::~G4RunManagerKernel().

◆ GetNavigator() [1/2]

G4Navigator * G4TransportationManager::GetNavigator ( const G4String & worldName)

Definition at line 207 of file G4TransportationManager.cc.

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

Referenced by G4FastSimulationManagerProcess::StartTracking().

◆ GetNavigator() [2/2]

G4Navigator * G4TransportationManager::GetNavigator ( G4VPhysicalVolume * aWorld)

Definition at line 249 of file G4TransportationManager.cc.

250{
251 for (const auto & fNavigator : fNavigators)
252 {
253 if (fNavigator->GetWorldVolume() == aWorld) { return fNavigator; }
254 }
255 G4Navigator* aNavigator = nullptr;
256 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
257 if (pWorld != fWorlds.cend())
258 {
259 aNavigator = new G4Navigator();
260 aNavigator->SetWorldVolume(aWorld);
261 fNavigators.push_back(aNavigator);
262 }
263 else
264 {
265 G4String message
266 = "World volume with name -" + aWorld->GetName()
267 + "- does not exist. Create it first by GetParallelWorld() method!";
268 G4Exception("G4TransportationManager::GetNavigator(pointer)",
269 "GeomNav0002", FatalException, message);
270 }
271
272 return aNavigator;
273}

◆ GetNavigatorForTracking()

◆ GetNoActiveNavigators()

std::size_t G4TransportationManager::GetNoActiveNavigators ( ) const
inline

◆ GetNoWorlds()

◆ GetParallelWorld()

G4VPhysicalVolume * G4TransportationManager::GetParallelWorld ( const G4String & worldName)

Definition at line 183 of file G4TransportationManager.cc.

184{
185 G4VPhysicalVolume* wPV = IsWorldExisting(worldName);
186 if (wPV == nullptr)
187 {
189 G4LogicalVolume* wLV = wPV->GetLogicalVolume();
190 wLV = new G4LogicalVolume(wLV->GetSolid(), nullptr,
191 worldName);
192 wPV = new G4PVPlacement (wPV->GetRotation(),
193 wPV->GetTranslation(),
194 wLV, worldName, nullptr, false, 0);
195 RegisterWorld(wPV);
196 }
197 return wPV;
198}
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(), G4IStore::SetParallelWorldVolume(), and G4WeightWindowStore::SetParallelWorldVolume().

◆ GetPropagatorInField()

◆ GetSafetyHelper()

◆ GetTransportationManager()

G4TransportationManager * G4TransportationManager::GetTransportationManager ( )
static

Definition at line 108 of file G4TransportationManager.cc.

109{
110 if (fTransportationManager == nullptr)
111 {
112 fTransportationManager = new G4TransportationManager;
113 }
114 return fTransportationManager;
115}

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

◆ GetWorldsIterator()

◆ InactivateAll()

void G4TransportationManager::InactivateAll ( )

Definition at line 383 of file G4TransportationManager.cc.

384{
385 for (const auto & fActiveNavigator : fActiveNavigators)
386 {
387 fActiveNavigator->Activate(false);
388 }
389 fActiveNavigators.clear();
390
391 // Restore status for the navigator for tracking
392 //
393 fNavigators[0]->Activate(true);
394 fActiveNavigators.push_back(fNavigators[0]);
395}

Referenced by G4CoupledTransportation::EndTracking().

◆ IsWorldExisting()

G4VPhysicalVolume * G4TransportationManager::IsWorldExisting ( const G4String & worldName)

Definition at line 404 of file G4TransportationManager.cc.

405{
406 auto pWorld = fWorlds.begin();
407 if ( *pWorld==nullptr ) { *pWorld=fNavigators[0]->GetWorldVolume(); }
408
409 for (const auto & fWorld : fWorlds)
410 {
411 if (fWorld->GetName() == name ) { return fWorld; }
412 }
413 return nullptr;
414}

Referenced by G4RunManager::ConstructScoringWorlds(), G4WorkerRunManager::ConstructScoringWorlds(), GetNavigator(), GetParallelWorld(), and G4RunManagerKernel::WorkerUpdateWorldVolume().

◆ RegisterWorld()

G4bool G4TransportationManager::RegisterWorld ( G4VPhysicalVolume * aWorld)

Definition at line 423 of file G4TransportationManager.cc.

424{
425 G4bool done = false;
426
427 auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
428 if (pWorld == fWorlds.cend())
429 {
430 fWorlds.push_back(aWorld);
431 done = true;
432 }
433 return done;
434}
bool G4bool
Definition G4Types.hh:86

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

◆ SetFieldManager()

void G4TransportationManager::SetFieldManager ( G4FieldManager * newFieldManager)

Definition at line 132 of file G4TransportationManager.cc.

133{
134 fFieldManager = newFieldManager;
136
137 // Message the PropagatorInField,
138 // which also maintains this information (to be reviewed)
139 //
140 if( fPropagatorInField != nullptr )
141 {
142 fPropagatorInField -> SetDetectorFieldManager( newFieldManager );
143 }
144}

◆ SetFirstTrackingNavigator()

void G4TransportationManager::SetFirstTrackingNavigator ( G4Navigator * nav)
static

Definition at line 499 of file G4TransportationManager.cc.

500{
501 fFirstTrackingNavigator= nav;
502}

◆ SetNavigatorForTracking()

void G4TransportationManager::SetNavigatorForTracking ( G4Navigator * newNavigator)

Definition at line 152 of file G4TransportationManager.cc.

153{
154 fNavigators[0] = newNavigator;
155 fActiveNavigators[0] = newNavigator;
156 fPropagatorInField->SetNavigatorForPropagating(newNavigator);
157}

◆ SetPropagatorInField()

void G4TransportationManager::SetPropagatorInField ( G4PropagatorInField * newFieldPropagator)
inline

◆ SetWorldForTracking()

void G4TransportationManager::SetWorldForTracking ( G4VPhysicalVolume * theWorld)
inline

Member Data Documentation

◆ kMassNavigatorId

G4int G4TransportationManager::kMassNavigatorId = 0
staticconstexpr

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