Geant4 11.2.2
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 92 of file G4TransportationManager.cc.

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

◆ 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}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
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 318 of file G4TransportationManager.cc.

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

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

◆ ClearParallelWorlds()

void G4TransportationManager::ClearParallelWorlds ( )

Definition at line 464 of file G4TransportationManager.cc.

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

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

◆ DeActivateNavigator()

void G4TransportationManager::DeActivateNavigator ( G4Navigator * aNavigator)

Definition at line 350 of file G4TransportationManager.cc.

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

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

◆ DeRegisterNavigator()

void G4TransportationManager::DeRegisterNavigator ( G4Navigator * aNavigator)

Definition at line 280 of file G4TransportationManager.cc.

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

◆ GetActiveNavigatorsIterator()

◆ GetFieldManager()

◆ GetFirstTrackingNavigator()

G4Navigator * G4TransportationManager::GetFirstTrackingNavigator ( )
static

Definition at line 486 of file G4TransportationManager.cc.

487{
488 return fFirstTrackingNavigator;
489}

◆ GetInstanceIfExist()

G4TransportationManager * G4TransportationManager::GetInstanceIfExist ( )
static

Definition at line 120 of file G4TransportationManager.cc.

121{
122 return fTransportationManager;
123}

Referenced by G4RunManagerKernel::~G4RunManagerKernel().

◆ GetNavigator() [1/2]

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

Definition at line 204 of file G4TransportationManager.cc.

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

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

◆ GetNavigator() [2/2]

G4Navigator * G4TransportationManager::GetNavigator ( G4VPhysicalVolume * aWorld)

Definition at line 246 of file G4TransportationManager.cc.

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

◆ GetNavigatorForTracking()

◆ GetNoActiveNavigators()

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

◆ GetNoWorlds()

◆ GetParallelWorld()

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

Definition at line 180 of file G4TransportationManager.cc.

181{
182 G4VPhysicalVolume* wPV = IsWorldExisting(worldName);
183 if (wPV == nullptr)
184 {
186 G4LogicalVolume* wLV = wPV->GetLogicalVolume();
187 wLV = new G4LogicalVolume(wLV->GetSolid(), nullptr,
188 worldName);
189 wPV = new G4PVPlacement (wPV->GetRotation(),
190 wPV->GetTranslation(),
191 wLV, worldName, nullptr, false, 0);
192 RegisterWorld(wPV);
193 }
194 return wPV;
195}
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(), G4ParallelWorldProcess::SetParallelWorld(), G4ParallelWorldScoringProcess::SetParallelWorld(), G4WeightCutOffProcess::SetParallelWorld(), G4WeightWindowProcess::SetParallelWorld(), G4IStore::SetParallelWorldVolume(), and G4WeightWindowStore::SetParallelWorldVolume().

◆ GetPropagatorInField()

◆ GetSafetyHelper()

◆ GetTransportationManager()

G4TransportationManager * G4TransportationManager::GetTransportationManager ( )
static

Definition at line 106 of file G4TransportationManager.cc.

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

Referenced by G4Scene::AddWorldIfEmpty(), G4RayTrajectory::AppendStep(), G4DecayWithSpin::AtRestDoIt(), G4ErrorSurfaceTrajState::BuildErrorMatrix(), G4RunManagerKernel::CheckRegions(), G4VPrimaryGenerator::CheckVertexInsideWorld(), G4AdjointPrimaryGenerator::ComputeAccumulatedDepthVectorAlongBackRay(), G4ParallelWorldPhysics::ConstructProcess(), G4MTRunManager::ConstructScoringWorlds(), G4RunManager::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(), 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 380 of file G4TransportationManager.cc.

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

Referenced by G4CoupledTransportation::EndTracking().

◆ IsWorldExisting()

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

Definition at line 401 of file G4TransportationManager.cc.

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

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 420 of file G4TransportationManager.cc.

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

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

◆ SetFieldManager()

void G4TransportationManager::SetFieldManager ( G4FieldManager * newFieldManager)

Definition at line 130 of file G4TransportationManager.cc.

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

◆ SetFirstTrackingNavigator()

void G4TransportationManager::SetFirstTrackingNavigator ( G4Navigator * nav)
static

Definition at line 496 of file G4TransportationManager.cc.

497{
498 fFirstTrackingNavigator= nav;
499}

◆ SetNavigatorForTracking()

void G4TransportationManager::SetNavigatorForTracking ( G4Navigator * newNavigator)

Definition at line 149 of file G4TransportationManager.cc.

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

◆ 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: