59 if ( fParticleToBias ==
nullptr )
62 ed <<
" Particle `" << particleName <<
"' not found !" <<
G4endl;
63 G4Exception(
" G4BOptrForceCollision::G4BOptrForceCollision(...)",
76 fParticleToBias = particle;
81 for (
auto it = fFreeFlightOperations.cbegin();
82 it != fFreeFlightOperations.cend(); ++it )
86 delete fSharedForceInteractionOperation;
87 delete fCloningOperation;
102 const G4ProcessManager* processManager = fParticleToBias->GetProcessManager();
104 if ( interfaceProcessSharedData )
124G4BOptrForceCollision::ProposeOccurenceBiasingOperation(
const G4Track* track,
128 if ( track->
GetDefinition() != fParticleToBias )
return nullptr;
131 if ( fCurrentTrackData ==
nullptr )
135 if ( fCurrentTrackData ==
nullptr )
return nullptr;
150 G4BOptnForceFreeFlight* operation = fFreeFlightOperations[callingProcess];
172 G4bool isFirstPhysGPIL = callingProcess-> GetIsFirstPostStepGPILInterface();
175 if ( isFirstPhysGPIL )
180 fSharedForceInteractionOperation->Initialize( track );
184 if ( fSharedForceInteractionOperation->GetInitialMomentum() != track->
GetMomentum() )
189 fSharedForceInteractionOperation->Initialize( track );
197 fSharedForceInteractionOperation->UpdateForStep( track->
GetStep() );
205 if ( fSharedForceInteractionOperation->GetMaximumDistance() <
DBL_MIN )
207 fCurrentTrackData->Reset();
213 if ( isFirstPhysGPIL )
218 const G4BiasingProcessSharedData* sharedData = callingProcess->
GetSharedData();
225 if ( interactionLength <
DBL_MAX/10. )
226 fSharedForceInteractionOperation->AddCrossSection( wrapperProcess->
GetWrappedProcess(), 1.0/interactionLength );
229 if ( fSharedForceInteractionOperation->GetNumberOfSharing() > 0 )
230 fSharedForceInteractionOperation->Sample();
234 G4VBiasingOperation* operationToReturn =
nullptr;
236 operationToReturn = fSharedForceInteractionOperation;
237 return operationToReturn;
248ProposeNonPhysicsBiasingOperation(
const G4Track* track,
251 if ( track->
GetDefinition() != fParticleToBias )
return nullptr;
263 if ( fCurrentTrackData !=
nullptr )
265 if ( fCurrentTrackData->IsFreeFromBiasing() )
268 fCurrentTrackData->fForceCollisionOperator = this ;
278 fCurrentTrackData =
new G4BOptrForceCollisionTrackData(
this );
282 fInitialTrackWeight = track->
GetWeight();
283 fCloningOperation->SetCloneWeights(0.0, fInitialTrackWeight);
285 return fCloningOperation;
292ProposeFinalStateBiasingOperation(
const G4Track*,
303 fCurrentTrack = track;
304 fCurrentTrackData =
nullptr;
310 if ( fCurrentTrackData !=
nullptr )
312 if ( !fCurrentTrackData->IsFreeFromBiasing() )
318 ed <<
"Current track deleted while under biasing by "
319 <<
GetName() <<
". Will result in inconsistencies.";
320 G4Exception(
" G4BOptrForceCollision::EndTracking()",
333 if ( fCurrentTrackData ==
nullptr )
338 ed <<
" Internal inconsistency : please submit bug report. " <<
G4endl;
339 G4Exception(
" G4BOptrForceCollision::OperationApplied(...)",
350 fCloningOperation->GetCloneTrack()->SetAuxiliaryTrackInformation(fForceCollisionModelID, cloneData);
354 if ( fFreeFlightOperations[callingProcess]->OperationComplete() )
355 fCurrentTrackData->Reset();
359 if ( operationApplied != fSharedForceInteractionOperation )
362 ed <<
" Internal inconsistency : please submit bug report. " <<
G4endl;
363 G4Exception(
" G4BOptrForceCollision::OperationApplied(...)",
366 if ( fSharedForceInteractionOperation->GetInteractionOccured() )
368 if ( operationApplied != fSharedForceInteractionOperation )
371 ed <<
" Internal inconsistency : please submit bug report. " <<
G4endl;
372 G4Exception(
" G4BOptrForceCollision::OperationApplied(...)",
382 ed <<
" Internal inconsistency : please submit bug report. " <<
G4endl;
383 G4Exception(
" G4BOptrForceCollision::OperationApplied(...)",
399 if ( finalStateOperationApplied != fSharedForceInteractionOperation )
402 ed <<
" Internal inconsistency : please submit bug report. " <<
G4endl;
403 G4Exception(
" G4BOptrForceCollision::OperationApplied(...)",
406 if ( fSharedForceInteractionOperation->GetInteractionOccured() )
407 fCurrentTrackData->Reset();
412 ed <<
" Internal inconsistency : please submit bug report. " <<
G4endl;
413 G4Exception(
" G4BOptrForceCollision::OperationApplied(...)",
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
@ fKillTrackAndSecondaries
void ResetInitialTrackWeight(G4double w)
virtual void StartTracking(const G4Track *track) final
G4BOptrForceCollision(const G4String &particleToForce, const G4String &name="ForceCollision")
virtual void EndTracking() final
virtual void ConfigureForWorker() final
void OperationApplied(const G4BiasingProcessInterface *callingProcess, G4BiasingAppliedCase biasingCase, G4VBiasingOperation *operationApplied, const G4VParticleChange *particleChangeProduced) final
virtual void StartRun() final
virtual void Configure() final
const G4BiasingProcessSharedData * GetSharedData() const
G4VBiasingOperation * GetCurrentOccurenceBiasingOperation() const
G4VProcess * GetWrappedProcess() const
const std::vector< const G4BiasingProcessInterface * > & GetPhysicsBiasingProcessInterfaces() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
G4StepStatus GetStepStatus() const
G4StepPoint * GetPreStepPoint() const
void SetAuxiliaryTrackInformation(G4int id, G4VAuxiliaryTrackInformation *info) const
G4double GetWeight() const
G4int GetCurrentStepNumber() const
G4ThreeVector GetMomentum() const
G4VAuxiliaryTrackInformation * GetAuxiliaryTrackInformation(G4int id) const
G4ParticleDefinition * GetDefinition() const
const G4Step * GetStep() const
const G4String & GetName() const
G4VBiasingOperator(const G4String &name)
G4double GetCurrentInteractionLength() const
const G4String & GetProcessName() const