44 fCurrentTrack ( nullptr ),
45 fPreviousStepSize (-1.0), fCurrentMinimumStep( -1.0 ), fProposedSafety ( -1.0),
46 fOccurenceBiasingOperation( nullptr ), fFinalStateBiasingOperation( nullptr ), fNonPhysicsBiasingOperation( nullptr ),
47 fPreviousOccurenceBiasingOperation( nullptr ), fPreviousFinalStateBiasingOperation( nullptr ), fPreviousNonPhysicsBiasingOperation( nullptr ),
48 fResetWrappedProcessInteractionLength( true ),
49 fWrappedProcess ( nullptr ),
50 fIsPhysicsBasedBiasing ( false ),
51 fWrappedProcessIsAtRest ( false ),
52 fWrappedProcessIsAlong ( false ),
53 fWrappedProcessIsPost ( false ),
54 fWrappedProcessPostStepGPIL ( -1.0 ),
55 fBiasingPostStepGPIL ( -1.0 ),
56 fWrappedProcessInteractionLength ( -1.0 ),
57 fWrappedProcessForceCondition (
NotForced ),
59 fWrappedProcessAlongStepGPIL ( -1.0 ),
60 fBiasingAlongStepGPIL ( -1.0 ),
63 fBiasingInteractionLaw ( nullptr ),
64 fPreviousBiasingInteractionLaw ( nullptr ),
65 fPhysicalInteractionLaw ( nullptr ),
66 fOccurenceBiasingParticleChange ( nullptr ),
67 fDummyParticleChange ( nullptr ),
68 fIamFirstGPIL ( false ),
69 fProcessManager ( nullptr ),
70 fSharedData ( nullptr )
83 :
G4VProcess( useThisName !=
"" ? useThisName :
"biasWrapper("+wrappedProcess->GetProcessName()+
")",
84 wrappedProcess->GetProcessType()),
85 fCurrentTrack ( nullptr ),
86 fPreviousStepSize (-1.0), fCurrentMinimumStep( -1.0 ), fProposedSafety ( -1.0),
87 fOccurenceBiasingOperation( nullptr ), fFinalStateBiasingOperation( nullptr ), fNonPhysicsBiasingOperation( nullptr ),
88 fPreviousOccurenceBiasingOperation( nullptr ), fPreviousFinalStateBiasingOperation( nullptr ), fPreviousNonPhysicsBiasingOperation( nullptr ),
89 fResetWrappedProcessInteractionLength ( false ),
90 fWrappedProcess ( wrappedProcess ),
91 fIsPhysicsBasedBiasing ( true ),
92 fWrappedProcessIsAtRest ( wrappedIsAtRest ),
93 fWrappedProcessIsAlong ( wrappedIsAlongStep ),
94 fWrappedProcessIsPost ( wrappedIsPostStep ),
95 fWrappedProcessPostStepGPIL ( -1.0 ),
96 fBiasingPostStepGPIL ( -1.0 ),
97 fWrappedProcessInteractionLength ( -1.0 ),
98 fWrappedProcessForceCondition (
NotForced ),
100 fWrappedProcessAlongStepGPIL ( -1.0 ),
101 fBiasingAlongStepGPIL ( -1.0 ),
104 fBiasingInteractionLaw ( nullptr ),
105 fPreviousBiasingInteractionLaw ( nullptr ),
106 fPhysicalInteractionLaw ( nullptr ),
107 fOccurenceBiasingParticleChange ( nullptr ),
108 fIamFirstGPIL ( false ),
109 fProcessManager ( nullptr ),
110 fSharedData ( nullptr )
144 return (*itr).second;
228 G4bool firstStepInParallelVolume =
false;
233 size_t iParallel = 0;
236 if ( firstStep || wasLimiting )
238 firstStepInParallelVolume =
true;
241 ->GetLogicalVolume() );
242 if ( newParallelOperator )
244 if ( tmpParallelOperator )
247 ed <<
" Several biasing operators are defined at the same place in parallel geometries ! Found:\n";
248 ed <<
" - `" << newParallelOperator->
GetName() <<
"' and \n";
249 ed <<
" - `" << tmpParallelOperator->GetName() <<
"'.\n";
250 ed <<
" Keeping `" << newParallelOperator->
GetName() <<
"'. Behavior not guaranteed ! Please consider having only one operator at a place. " <<
G4endl;
251 G4Exception(
" G4BiasingProcessInterface::PostStepGetPhysicalInteractionLength(...)",
257 else newParallelOperator = tmpParallelOperator;
269 if ( firstStepInVolume )
276 ed <<
" Biasing operators are defined at the same place in mass and parallel geometries ! Found:\n";
278 ed <<
" - `" << newOperator->
GetName() <<
"' in mass geometry.\n";
280 G4Exception(
" G4BiasingProcessInterface::PostStepGetPhysicalInteractionLength(...)",
288 if ( firstStepInVolume || firstStepInParallelVolume )
351 G4double usedPreviousStepSize = previousStepSize;
371 usedPreviousStepSize = 0.0;
465 return particleChange;
488 G4bool forceBiasedFinalState =
false;
504 return finalStateParticleChange;
508 if ( forceBiasedFinalState )
511 return finalStateParticleChange;
516 G4double weightForInteraction = 1.0;
526 ed <<
"Internal inconsistency in cross-section handling. Please report !" <<
G4endl;
527 G4Exception(
" G4BiasingProcessInterface::PostStepDoIt(...)",
537 if ( weightForInteraction <= 0. )
540 ed <<
" Negative interaction weight : w_I = "
541 << weightForInteraction <<
547 G4Exception(
" G4BiasingProcessInterface::PostStepDoIt(...)",
677 G4double weightForNonInteraction (1.0);
680 weightForNonInteraction =
686 if ( weightForNonInteraction <= 0. )
689 ed <<
" Negative non interaction weight : w_NI = " << weightForNonInteraction <<
694 G4Exception(
" G4BiasingProcessInterface::AlongStepDoIt(...)",
817 fSharedData-> fBiasingProcessInterfaces.push_back(
this );
818 fSharedData-> fPublicBiasingProcessInterfaces.push_back(
this );
821 fSharedData-> fPhysicsBiasingProcessInterfaces.push_back(
this );
822 fSharedData-> fPublicPhysicsBiasingProcessInterfaces.push_back(
this );
826 fSharedData-> fNonPhysicsBiasingProcessInterfaces.push_back(
this );
827 fSharedData-> fPublicNonPhysicsBiasingProcessInterfaces.push_back(
this );
893 G4int iPhys = ( physOnly ) ? 1 : 0;
900 G4int iPhys = ( physOnly ) ? 1 : 0;
907 G4int iPhys = ( physOnly ) ? 1 : 0;
914 G4int iPhys = ( physOnly ) ? 1 : 0;
924 for (
G4int i = 0; i < pv->
size(); i++ )
if ( (*pv)(i) ==
this ) { thisIdx = i;
break; }
931 if ( thisIdx > thatIdx )
947 for (
G4int i = 0; i < pv->
size(); i++ )
if ( (*pv)(i) ==
this ) { thisIdx = i;
break; }
954 if ( thisIdx < thatIdx )
970 for (
G4int i = 0; i < pv->
size(); i++ )
if ( (*pv)(i) ==
this ) { thisIdx = i;
break; }
977 if ( thisIdx > thatIdx )
993 for (
G4int i = 0; i < pv->
size(); i++ )
if ( (*pv)(i) ==
this ) { thisIdx = i;
break; }
1000 if ( thisIdx < thatIdx )
1013 for (
G4int iPhys = 0; iPhys < 2; iPhys++ )
1015 G4bool physOnly = ( iPhys == 1 );
1040 G4double usedPreviousStepSize = previousStepSize;
1052 usedPreviousStepSize = 0.0;
1066 (
fSharedData -> fBiasingProcessInterfaces ) . clear();
1067 (
fSharedData -> fPhysicsBiasingProcessInterfaces ) . clear();
1068 (
fSharedData -> fNonPhysicsBiasingProcessInterfaces ) . clear();
1069 (
fSharedData -> fPublicBiasingProcessInterfaces ) . clear();
1070 (
fSharedData -> fPublicPhysicsBiasingProcessInterfaces ) . clear();
1071 (
fSharedData -> fPublicNonPhysicsBiasingProcessInterfaces ) . clear();
1076 for (
size_t j = 0; j < tmpProcess.size(); j++ )
1078 if ( (*pv)(i) == tmpProcess[j] )
1080 (
fSharedData -> fBiasingProcessInterfaces ) . push_back( tmpProcess[j] );
1081 (
fSharedData -> fPublicBiasingProcessInterfaces ) . push_back( tmpProcess[j] );
1084 (
fSharedData -> fPhysicsBiasingProcessInterfaces ) . push_back( tmpProcess[j] );
1085 (
fSharedData -> fPublicPhysicsBiasingProcessInterfaces ) . push_back( tmpProcess[j] );
1089 (
fSharedData -> fNonPhysicsBiasingProcessInterfaces ) . push_back( tmpProcess[j] );
1090 (
fSharedData -> fPublicNonPhysicsBiasingProcessInterfaces ) . push_back( tmpProcess[j] );
virtual void SetMasterProcess(G4VProcess *masterP)
virtual void Initialize(const G4Track &track)
G4double condition(const G4ErrorSymMatrix &m)
const G4VProcess * GetMasterProcess() const
virtual void BuildWorkerPhysicsTable(const G4ParticleDefinition &pd)
G4VBiasingOperation * fPreviousFinalStateBiasingOperation
G4bool IsLastPostStepGPILInterface(G4bool physOnly=true) const
G4bool fResetWrappedProcessInteractionLength
virtual void PreparePhysicsTable(const G4ParticleDefinition &pd)
G4VBiasingOperator * fMassGeometryOperator
virtual G4VParticleChange * AtRestDoIt(const G4Track &, const G4Step &)
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const
virtual G4double AtRestGetPhysicalInteractionLength(const G4Track &track, G4ForceCondition *condition)=0
virtual void SetProcessManager(const G4ProcessManager *)
G4VBiasingOperation * fFinalStateBiasingOperation
void SetWrappedParticleChange(G4VParticleChange *wpc)
static G4Cache< G4bool > fCommonEnd
G4VBiasingOperation * fNonPhysicsBiasingOperation
G4double fBiasingAlongStepGPIL
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)=0
virtual G4bool StorePhysicsTable(const G4ParticleDefinition *pd, const G4String &s, G4bool f)
G4GPILSelection fWrappedProcessGPILSelection
std::ostringstream G4ExceptionDescription
static constexpr double s
static G4Cache< G4bool > fResetInteractionLaws
G4double GetStepLength() const
virtual void BuildPhysicsTable(const G4ParticleDefinition &pd)
virtual G4VParticleChange * ApplyFinalStateBiasing(const G4BiasingProcessInterface *, const G4Track *, const G4Step *, G4bool &)=0
G4double fBiasingPostStepGPIL
virtual void PrepareWorkerPhysicsTable(const G4ParticleDefinition &pd)
static G4Cache< G4bool > fDoCommonConfigure
G4VBiasingOperator * fParallelGeometryOperator
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &step)
G4StepStatus GetStepStatus() const
G4ParticleChangeForNothing * fDummyParticleChange
const std::vector< const G4VPhysicalVolume * > & GetCurrentVolumes() const
void InvokeWrappedProcessPostStepGPIL(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
G4TrackStatus GetTrackStatus() const
void ResetForUnbiasedTracking()
std::vector< G4BiasingProcessInterface * > fBiasingProcessInterfaces
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &step)
G4double fWrappedProcessPostStepGPIL
const G4bool fIsPhysicsBasedBiasing
G4double fPreviousStepSize
const char * name(G4int ptype)
virtual void SetProcessManager(const G4ProcessManager *)
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const =0
virtual void ResetNumberOfInteractionLengthLeft()
G4ForceCondition fBiasingForceCondition
G4VBiasingOperation * fPreviousOccurenceBiasingOperation
const G4ProcessManager * fProcessManager
void SetOccurenceWeightForNonInteraction(G4double w)
const G4Step * GetStep() const
const G4VBiasingInteractionLaw * fPreviousBiasingInteractionLaw
virtual G4double ProposeAlongStepLimit(const G4BiasingProcessInterface *)
G4VProcess * GetWrappedProcess() const
void SetUpFirstLastFlags()
virtual void BuildWorkerPhysicsTable(const G4ParticleDefinition &part)
G4bool GetIsFirstPostStepGPILInterface(G4bool physOnly=true) const
G4StepPoint * GetPreStepPoint() const
virtual void StartTracking(G4Track *)
void SetSecondaryWeightByProcess(G4bool)
static G4Cache< G4bool > fCommonStart
std::vector< G4BiasingProcessInterface * > fPhysicsBiasingProcessInterfaces
G4int GetCurrentStepNumber() const
G4bool GetIsLastPostStepDoItInterface(G4bool physOnly=true) const
const G4VBiasingInteractionLaw * fBiasingInteractionLaw
G4bool GetIsLastPostStepGPILInterface(G4bool physOnly=true) const
virtual void PreparePhysicsTable(const G4ParticleDefinition &)
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const
G4bool GetIsFirstPostStepDoItInterface(G4bool physOnly=true) const
G4VBiasingOperation * fPreviousNonPhysicsBiasingOperation
G4double GetCurrentInteractionLength() const
void SetProcessSubType(G4int)
void SetPhysicalCrossSection(G4double crossSection)
void SetOccurenceWeightForInteraction(G4double w)
G4VProcess * fWrappedProcess
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
const G4String & GetProcessName() const
G4ForceCondition fWrappedProcessForceCondition
const G4bool fWrappedProcessIsAlong
const std::vector< G4bool > & GetWasLimiting() const
virtual G4VParticleChange * GenerateBiasingFinalState(const G4Track *, const G4Step *)=0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4MapCache< const G4ProcessManager *, G4BiasingProcessSharedData * > fSharedDataMap
virtual G4bool IsApplicable(const G4ParticleDefinition &pd)
virtual const G4ProcessManager * GetProcessManager()
G4bool fLeavingPreviousOperator
static G4VBiasingOperator * GetBiasingOperator(const G4LogicalVolume *)
virtual G4bool IsSingular() const
virtual const G4ProcessManager * GetProcessManager()
iterator Find(const key_type &k)
G4LogicalVolume * GetLogicalVolume() const
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
G4VBiasingOperation * fOccurenceBiasingOperation
G4ParallelGeometriesLimiterProcess * fParallelGeometriesLimiterProcess
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &stepData)=0
G4ParticleChangeForOccurenceBiasing * fOccurenceBiasingParticleChange
G4bool IsFirstPostStepGPILInterface(G4bool physOnly=true) const
G4bool fFirstLastFlags[8]
virtual void SetMasterProcess(G4VProcess *masterP)
G4BiasingProcessInterface(G4String name="biasWrapper(0)")
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition *pd, const G4String &s, G4bool f)
virtual G4GPILSelection ProposeGPILSelection(const G4GPILSelection wrappedProcessSelection)
G4VPhysicalVolume * GetVolume() const
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)=0
G4double GetSampledInteractionLength() const
static const std::vector< G4VBiasingOperator * > & GetBiasingOperators()
G4double fWrappedProcessInteractionLength
const G4String & GetName() const
virtual G4bool StorePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
virtual G4bool IsEffectiveCrossSectionInfinite() const
G4TrackStatus GetTrackStatus() const
G4bool IsFirstPostStepDoItInterface(G4bool physOnly=true) const
virtual const G4VBiasingInteractionLaw * ProvideOccurenceBiasingInteractionLaw(const G4BiasingProcessInterface *, G4ForceCondition &)=0
virtual void AlongMoveBy(const G4BiasingProcessInterface *, const G4Step *, G4double)
G4InteractionLawPhysical * fPhysicalInteractionLaw
virtual void ResetNumberOfInteractionLengthLeft()
G4BiasingProcessSharedData * fSharedData
virtual void PrepareWorkerPhysicsTable(const G4ParticleDefinition &)
void ProposeTrackStatus(G4TrackStatus status)
virtual void EndTracking()
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &stepData)=0
G4double fWrappedProcessAlongStepGPIL
G4double fCurrentMinimumStep
G4bool IsLastPostStepDoItInterface(G4bool physOnly=true) const
G4int IdxFirstLast(G4int firstLast, G4int GPILDoIt, G4int physAll) const
void ReorderBiasingVectorAsGPIL()
G4VBiasingOperator * fPreviousBiasingOperator
void Put(const value_type &val) const
G4int GetProcessSubType() const
G4GPILSelection fBiasingGPILSelection
void StartTracking(G4Track *track)
virtual G4double DistanceToApplyOperation(const G4Track *, G4double, G4ForceCondition *)=0
virtual G4bool IsApplicable(const G4ParticleDefinition &)
G4VBiasingOperator * fCurrentBiasingOperator
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
virtual G4double AtRestGetPhysicalInteractionLength(const G4Track &, G4ForceCondition *)
const G4String GetName() const
~G4BiasingProcessInterface()
virtual G4VParticleChange * AtRestDoIt(const G4Track &track, const G4Step &stepData)=0
G4ProcessVector * GetPostStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
const G4BiasingProcessSharedData * GetSharedData() const