43 fParallelWorldSafety( 0.0 ),
44 fIsTrackingTime ( false ),
65 <<
"': adding a parallel world volume at tracking time is not allowed." <<
G4endl;
66 G4Exception(
"G4ParallelGeometriesLimiterProcess::AddParallelWorld(const G4String& parallelWorldName)",
82 tellWhatIsWrong <<
"Volume `" << parallelWorldName
83 <<
"' is not a parallel world nor the mass world volume."
85 G4Exception(
"G4ParallelGeometriesLimiterProcess::SetWorldVolume(const G4String)",
96 <<
"': trying to add the world volume for tracking as a parallel world." <<
G4endl;
97 G4Exception(
"G4ParallelGeometriesLimiterProcess::AddParallelWorld(const G4String& parallelWorldName)",
106 for (
auto knownWorld : fParallelWorlds )
108 if ( knownWorld == newWorld ) isNew =
false;
110 if ( isNew ) fParallelWorlds.push_back( newWorld );
115 <<
"': trying to re-add the parallel world volume `" << parallelWorldName <<
"'." <<
G4endl;
116 G4Exception(
"G4ParallelGeometriesLimiterProcess::AddParallelWorld(const G4String& parallelWorldName)",
135 <<
"': removing a parallel world volume at tracking time is not allowed." <<
G4endl;
136 G4Exception(
"G4ParallelGeometriesLimiterProcess::RemoveParallelWorld(const G4String& parallelWorldName)",
153 <<
"': trying to remove an inexisting parallel world '" << parallelWorldName <<
"'." <<
G4endl;
154 G4Exception(
"G4ParallelGeometriesLimiterProcess::RemoveParallelWorld(const G4String& parallelWorldName)",
163 for (
auto knownWorld : fParallelWorlds )
165 if ( knownWorld == newWorld )
break;
169 if ( iWorld == fParallelWorlds.size() )
173 <<
"': trying to remove an non-registerered parallel world '" << parallelWorldName <<
"'." <<
G4endl;
174 G4Exception(
"G4ParallelGeometriesLimiterProcess::RemoveParallelWorld(const G4String& parallelWorldName)",
182 fParallelWorlds.erase( fParallelWorlds.begin() + iWorld );
196 fIsTrackingTime =
true;
199 fParallelWorldNavigators .clear();
200 fParallelWorldNavigatorIndeces.clear();
201 fParallelWorldSafeties .clear();
202 fParallelWorldIsLimiting .clear();
203 fParallelWorldWasLimiting .clear();
204 fCurrentVolumes .clear();
205 fPreviousVolumes .clear();
206 for (
auto parallelWorld : fParallelWorlds )
208 fParallelWorldNavigators .push_back( fTransportationManager->
GetNavigator( parallelWorld ) );
209 fParallelWorldNavigatorIndeces.push_back( fTransportationManager->
ActivateNavigator( fParallelWorldNavigators.back() ) );
210 fParallelWorldSafeties .push_back( 0.0 );
211 fParallelWorldIsLimiting .push_back(
false );
212 fParallelWorldWasLimiting .push_back(
false );
217 for (
auto navigatorIndex : fParallelWorldNavigatorIndeces )
219 fPreviousVolumes.push_back(
nullptr );
220 fCurrentVolumes .push_back( fPathFinder->
GetLocatedVolume( navigatorIndex ) );
224 fParallelWorldSafety = 0.0;
225 for (
size_t i = 0 ; i < fParallelWorldNavigatorIndeces.size() ; i++ ) fParallelWorldSafeties[i] = 0.0;
231 fIsTrackingTime =
false;
232 for (
auto parallelWorldNavigator : fParallelWorldNavigators )
242 fParallelWorldWasLimiting = fParallelWorldIsLimiting;
243 fPreviousVolumes = fCurrentVolumes;
247 for (
auto navigatorIndex : fParallelWorldNavigatorIndeces ) fCurrentVolumes[i++] = fPathFinder->
GetLocatedVolume( navigatorIndex );
270 if (!endTrack_G4MT_TLS_) endTrack_G4MT_TLS_ =
new G4FieldTrack (
'0') ;
274 if (!eLimited_G4MT_TLS_) eLimited_G4MT_TLS_ =
new ELimited ;
275 ELimited &eLimited = *eLimited_G4MT_TLS_;
281 if ( previousStepSize > 0.0 )
283 for (
auto& parallelWorldSafety : fParallelWorldSafeties )
285 parallelWorldSafety -= previousStepSize;
286 if ( parallelWorldSafety < 0. ) parallelWorldSafety = 0.0;
287 fParallelWorldSafety = parallelWorldSafety < fParallelWorldSafety ? parallelWorldSafety : fParallelWorldSafety ;
295 if ( ( currentMinimumStep <= fParallelWorldSafety ) && ( currentMinimumStep > 0. ) )
299 returnedStep = currentMinimumStep;
300 proposedSafety = fParallelWorldSafety - currentMinimumStep;
305 G4double smallestReturnedStep = -1.0;
307 for (
size_t i = 0 ; i < fParallelWorldNavigatorIndeces.size() ; i++ )
310 if ( currentMinimumStep >= fParallelWorldSafeties[i] )
315 fParallelWorldNavigatorIndeces[i],
317 fParallelWorldSafeties[i],
322 if ( ( smallestReturnedStep < 0.0 ) || ( tmpReturnedStep <= smallestReturnedStep ) )
324 smallestReturnedStep = tmpReturnedStep;
325 eLimitedForSmallestStep = eLimited;
331 fParallelWorldSafeties[i] = fParallelWorldNavigators[i]->ComputeSafety(endTrack.GetPosition());
332 fParallelWorldIsLimiting[i] =
false;
336 fParallelWorldIsLimiting[i] =
true;
341 fParallelWorldSafety = fParallelWorldSafeties[i] < fParallelWorldSafety ? fParallelWorldSafeties[i] : fParallelWorldSafety ;
346 if ( eLimitedForSmallestStep ==
kDoNot )
348 returnedStep = currentMinimumStep;
351 if ( eLimitedForSmallestStep ==
kUnique ||
355 returnedStep = smallestReturnedStep;
359 returnedStep = smallestReturnedStep* (1.0 + 1.0e-9);
363 proposedSafety = fParallelWorldSafety ;
376 return &fDummyParticleChange;
385 if ( G4BiasingProcessSharedData::fSharedDataMap.Find(mgr) == G4BiasingProcessSharedData::fSharedDataMap.End() )
388 G4BiasingProcessSharedData::fSharedDataMap[mgr] = sharedData;
390 else sharedData = G4BiasingProcessSharedData::fSharedDataMap[mgr] ;
393 if ( sharedData->fParallelGeometriesLimiterProcess ==
nullptr ) sharedData->fParallelGeometriesLimiterProcess =
this;
397 ed <<
" Trying to add more than one G4ParallelGeometriesLimiterProcess process to the process manager " << mgr
399 G4Exception(
" G4ParallelGeometriesLimiterProcess::SetProcessManager(...)",
411 for (
auto world : fParallelWorlds )
413 if ( world == parallelWorld )
void PrepareNewTrack(const G4ThreeVector &position, const G4ThreeVector &direction, G4VPhysicalVolume *massStartVol=0)
virtual void Initialize(const G4Track &track)
static G4PathFinder * GetInstance()
G4double condition(const G4ErrorSymMatrix &m)
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
std::ostringstream G4ExceptionDescription
G4ParallelGeometriesLimiterProcess(const G4String &processName="biasLimiter")
const G4ThreeVector & GetPosition() const
const G4Navigator * GetNavigator(G4int worldIndex) const
G4Navigator * GetNavigatorForTracking() const
virtual void SetProcessManager(const G4ProcessManager *)
G4int GetParallelWorldIndex(const G4VPhysicalVolume *parallelWorld) const
const G4String & GetParticleName() const
void AddParallelWorld(const G4String ¶llelWorldName)
void StartTracking(G4Track *)
G4int GetCurrentStepNumber() const
G4VPhysicalVolume * GetLocatedVolume(G4int navId) const
void DeActivateNavigator(G4Navigator *aNavigator)
G4double ComputeStep(const G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4int navigatorId, G4int stepNo, G4double &pNewSafety, ELimited &limitedStep, G4FieldTrack &EndState, G4VPhysicalVolume *currentVolume)
G4ParticleDefinition * GetParticleType() const
const G4String & GetProcessName() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4TransportationManager * GetTransportationManager()
G4int ActivateNavigator(G4Navigator *aNavigator)
const G4ThreeVector & GetMomentumDirection() const
G4VPhysicalVolume * GetVolume() const
G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
void RemoveParallelWorld(const G4String ¶llelWorldName)
G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &step)
G4double PostStepGetPhysicalInteractionLength(const G4Track &, G4double, G4ForceCondition *)
G4VPhysicalVolume * GetWorldVolume() const
static void Update(G4FieldTrack *, const G4Track *)