42 fParallelWorldSafety( 0.0 ),
43 fIsTrackingTime ( false ),
64 <<
"': adding a parallel world volume at tracking time is not allowed." <<
G4endl;
65 G4Exception(
"G4ParallelGeometriesLimiterProcess::AddParallelWorld(const G4String& parallelWorldName)",
81 tellWhatIsWrong <<
"Volume `" << parallelWorldName
82 <<
"' is not a parallel world nor the mass world volume."
84 G4Exception(
"G4ParallelGeometriesLimiterProcess::SetWorldVolume(const G4String)",
95 <<
"': trying to add the world volume for tracking as a parallel world." <<
G4endl;
96 G4Exception(
"G4ParallelGeometriesLimiterProcess::AddParallelWorld(const G4String& parallelWorldName)",
105 for (
auto knownWorld : fParallelWorlds )
107 if ( knownWorld == newWorld ) isNew =
false;
109 if ( isNew ) fParallelWorlds.push_back( newWorld );
114 <<
"': trying to re-add the parallel world volume `" << parallelWorldName <<
"'." <<
G4endl;
115 G4Exception(
"G4ParallelGeometriesLimiterProcess::AddParallelWorld(const G4String& parallelWorldName)",
134 <<
"': removing a parallel world volume at tracking time is not allowed." <<
G4endl;
135 G4Exception(
"G4ParallelGeometriesLimiterProcess::RemoveParallelWorld(const G4String& parallelWorldName)",
152 <<
"': trying to remove an inexisting parallel world '" << parallelWorldName <<
"'." <<
G4endl;
153 G4Exception(
"G4ParallelGeometriesLimiterProcess::RemoveParallelWorld(const G4String& parallelWorldName)",
162 for (
auto knownWorld : fParallelWorlds )
164 if ( knownWorld == newWorld )
break;
168 if ( iWorld == fParallelWorlds.size() )
172 <<
"': trying to remove an non-registerered parallel world '" << parallelWorldName <<
"'." <<
G4endl;
173 G4Exception(
"G4ParallelGeometriesLimiterProcess::RemoveParallelWorld(const G4String& parallelWorldName)",
181 fParallelWorlds.erase( fParallelWorlds.begin() + iWorld );
195 fIsTrackingTime =
true;
198 fParallelWorldNavigators .clear();
199 fParallelWorldNavigatorIndeces.clear();
200 fParallelWorldSafeties .clear();
201 fParallelWorldIsLimiting .clear();
202 fParallelWorldWasLimiting .clear();
203 fCurrentVolumes .clear();
204 fPreviousVolumes .clear();
205 for (
auto parallelWorld : fParallelWorlds )
207 fParallelWorldNavigators .push_back( fTransportationManager->
GetNavigator( parallelWorld ) );
208 fParallelWorldNavigatorIndeces.push_back( fTransportationManager->
ActivateNavigator( fParallelWorldNavigators.back() ) );
209 fParallelWorldSafeties .push_back( 0.0 );
210 fParallelWorldIsLimiting .push_back(
false );
211 fParallelWorldWasLimiting .push_back(
false );
216 for (
auto navigatorIndex : fParallelWorldNavigatorIndeces )
218 fPreviousVolumes.push_back(
nullptr );
219 fCurrentVolumes .push_back( fPathFinder->
GetLocatedVolume( navigatorIndex ) );
223 fParallelWorldSafety = 0.0;
224 for (
size_t i = 0 ; i < fParallelWorldNavigatorIndeces.size() ; i++ ) fParallelWorldSafeties[i] = 0.0;
230 fIsTrackingTime =
false;
231 for (
auto parallelWorldNavigator : fParallelWorldNavigators )
241 fParallelWorldWasLimiting = fParallelWorldIsLimiting;
242 fPreviousVolumes = fCurrentVolumes;
246 for (
auto navigatorIndex : fParallelWorldNavigatorIndeces ) fCurrentVolumes[i++] = fPathFinder->
GetLocatedVolume( navigatorIndex );
269 if (!endTrack_G4MT_TLS_) endTrack_G4MT_TLS_ =
new G4FieldTrack (
'0') ;
273 if (!eLimited_G4MT_TLS_) eLimited_G4MT_TLS_ =
new ELimited ;
274 ELimited &eLimited = *eLimited_G4MT_TLS_;
280 if ( previousStepSize > 0.0 )
282 for (
auto& parallelWorldSafety : fParallelWorldSafeties )
284 parallelWorldSafety -= previousStepSize;
285 if ( parallelWorldSafety < 0. ) parallelWorldSafety = 0.0;
286 fParallelWorldSafety = parallelWorldSafety < fParallelWorldSafety ? parallelWorldSafety : fParallelWorldSafety ;
294 if ( ( currentMinimumStep <= fParallelWorldSafety ) && ( currentMinimumStep > 0. ) )
298 returnedStep = currentMinimumStep;
299 proposedSafety = fParallelWorldSafety - currentMinimumStep;
304 G4double smallestReturnedStep = -1.0;
306 for (
size_t i = 0 ; i < fParallelWorldNavigatorIndeces.size() ; i++ )
309 if ( currentMinimumStep >= fParallelWorldSafeties[i] )
314 fParallelWorldNavigatorIndeces[i],
316 fParallelWorldSafeties[i],
321 if ( ( smallestReturnedStep < 0.0 ) || ( tmpReturnedStep <= smallestReturnedStep ) )
323 smallestReturnedStep = tmpReturnedStep;
324 eLimitedForSmallestStep = eLimited;
330 fParallelWorldSafeties[i] = fParallelWorldNavigators[i]->ComputeSafety(endTrack.
GetPosition());
331 fParallelWorldIsLimiting[i] =
false;
335 fParallelWorldIsLimiting[i] =
true;
340 fParallelWorldSafety = fParallelWorldSafeties[i] < fParallelWorldSafety ? fParallelWorldSafeties[i] : fParallelWorldSafety ;
345 if ( eLimitedForSmallestStep ==
kDoNot )
347 returnedStep = currentMinimumStep;
350 if ( eLimitedForSmallestStep ==
kUnique ||
354 returnedStep = smallestReturnedStep;
358 returnedStep = smallestReturnedStep* (1.0 + 1.0e-9);
362 proposedSafety = fParallelWorldSafety ;
375 return &fDummyParticleChange;
384 if ( G4BiasingProcessSharedData::fSharedDataMap.Find(mgr) == G4BiasingProcessSharedData::fSharedDataMap.End() )
387 G4BiasingProcessSharedData::fSharedDataMap[mgr] = sharedData;
389 else sharedData = G4BiasingProcessSharedData::fSharedDataMap[mgr] ;
392 if ( sharedData->fParallelGeometriesLimiterProcess ==
nullptr ) sharedData->fParallelGeometriesLimiterProcess =
this;
396 ed <<
" Trying to add more than one G4ParallelGeometriesLimiterProcess process to the process manager " << mgr
398 G4Exception(
" G4ParallelGeometriesLimiterProcess::SetProcessManager(...)",
410 for (
auto world : fParallelWorlds )
412 if ( world == parallelWorld )
G4double condition(const G4ErrorSymMatrix &m)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
@ NotCandidateForSelection
static void Update(G4FieldTrack *, const G4Track *)
G4ThreeVector GetPosition() const
G4VPhysicalVolume * GetWorldVolume() const
G4ParallelGeometriesLimiterProcess(const G4String &processName="biasLimiter")
void AddParallelWorld(const G4String ¶llelWorldName)
G4int GetParallelWorldIndex(const G4VPhysicalVolume *parallelWorld) const
G4double PostStepGetPhysicalInteractionLength(const G4Track &, G4double, G4ForceCondition *)
const G4Navigator * GetNavigator(G4int worldIndex) const
void RemoveParallelWorld(const G4String ¶llelWorldName)
G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
virtual void SetProcessManager(const G4ProcessManager *)
void StartTracking(G4Track *)
G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &step)
virtual void Initialize(const G4Track &track)
const G4String & GetParticleName() const
G4VPhysicalVolume * GetLocatedVolume(G4int navId) const
G4double ComputeStep(const G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4int navigatorId, G4int stepNo, G4double &pNewSafety, ELimited &limitedStep, G4FieldTrack &EndState, G4VPhysicalVolume *currentVolume)
void PrepareNewTrack(const G4ThreeVector &position, const G4ThreeVector &direction, G4VPhysicalVolume *massStartVol=nullptr)
static G4PathFinder * GetInstance()
G4ParticleDefinition * GetParticleType() const
G4VPhysicalVolume * GetVolume() const
const G4ThreeVector & GetPosition() const
G4int GetCurrentStepNumber() const
const G4ThreeVector & GetMomentumDirection() const
static G4TransportationManager * GetTransportationManager()
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
G4Navigator * GetNavigatorForTracking() const
G4int ActivateNavigator(G4Navigator *aNavigator)
void DeActivateNavigator(G4Navigator *aNavigator)
const G4String & GetProcessName() const