Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4BiasingProcessInterface Class Reference

#include <G4BiasingProcessInterface.hh>

Inheritance diagram for G4BiasingProcessInterface:
Collaboration diagram for G4BiasingProcessInterface:

Public Member Functions

 G4BiasingProcessInterface (G4String name="biasWrapper(0)")
 
 G4BiasingProcessInterface (G4VProcess *wrappedProcess, G4bool wrappedIsAtRest, G4bool wrappedIsAlongStep, G4bool wrappedIsPostStep, G4String useThisName="")
 
 ~G4BiasingProcessInterface ()
 
G4VProcessGetWrappedProcess () const
 
G4VBiasingOperatorGetCurrentBiasingOperator () const
 
G4VBiasingOperatorGetPreviousBiasingOperator () const
 
G4VBiasingOperationGetCurrentNonPhysicsBiasingOperation () const
 
G4VBiasingOperationGetPreviousNonPhysicsBiasingOperation () const
 
G4VBiasingOperationGetCurrentOccurenceBiasingOperation () const
 
G4VBiasingOperationGetPreviousOccurenceBiasingOperation () const
 
G4VBiasingOperationGetCurrentFinalStateBiasingOperation () const
 
G4VBiasingOperationGetPreviousFinalStateBiasingOperation () const
 
const std::vector< const
G4BiasingProcessInterface * > & 
GetBiasingProcessInterfaces () const
 
const std::vector< const
G4BiasingProcessInterface * > & 
GetPhysicsBiasingProcessInterfaces () const
 
const std::vector< const
G4BiasingProcessInterface * > & 
GetNonPhysicsBiasingProcessInterfaces () const
 
const G4BiasingProcessSharedDataGetSharedData () const
 
G4bool GetIsFirstPostStepGPILInterface (G4bool physOnly=true) const
 
G4bool GetIsLastPostStepGPILInterface (G4bool physOnly=true) const
 
G4bool GetIsFirstPostStepDoItInterface (G4bool physOnly=true) const
 
G4bool GetIsLastPostStepDoItInterface (G4bool physOnly=true) const
 
G4bool IsFirstPostStepGPILInterface (G4bool physOnly=true) const
 
G4bool IsLastPostStepGPILInterface (G4bool physOnly=true) const
 
G4bool IsFirstPostStepDoItInterface (G4bool physOnly=true) const
 
G4bool IsLastPostStepDoItInterface (G4bool physOnly=true) const
 
G4bool GetWrappedProcessIsAtRest () const
 
G4bool GetWrappedProcessIsAlong () const
 
G4bool GetWrappedProcessIsPost () const
 
G4double GetPreviousStepSize () const
 
G4double GetCurrentMinimumStep () const
 
G4double GetProposedSafety () const
 
void SetProposedSafety (G4double sft)
 
G4double GetPostStepGPIL () const
 
G4double GetAlongStepGPIL () const
 
void StartTracking (G4Track *track)
 
void EndTracking ()
 
virtual G4double PostStepGetPhysicalInteractionLength (const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
 
virtual G4VParticleChangePostStepDoIt (const G4Track &track, const G4Step &step)
 
virtual G4double AlongStepGetPhysicalInteractionLength (const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
 
virtual G4VParticleChangeAlongStepDoIt (const G4Track &track, const G4Step &step)
 
virtual G4double AtRestGetPhysicalInteractionLength (const G4Track &, G4ForceCondition *)
 
virtual G4VParticleChangeAtRestDoIt (const G4Track &, const G4Step &)
 
virtual G4bool IsApplicable (const G4ParticleDefinition &pd)
 
virtual void BuildPhysicsTable (const G4ParticleDefinition &pd)
 
virtual void PreparePhysicsTable (const G4ParticleDefinition &pd)
 
virtual G4bool StorePhysicsTable (const G4ParticleDefinition *pd, const G4String &s, G4bool f)
 
virtual G4bool RetrievePhysicsTable (const G4ParticleDefinition *pd, const G4String &s, G4bool f)
 
virtual void SetProcessManager (const G4ProcessManager *)
 
virtual const G4ProcessManagerGetProcessManager ()
 
virtual void ResetNumberOfInteractionLengthLeft ()
 
virtual void SetMasterProcess (G4VProcess *masterP)
 
virtual void BuildWorkerPhysicsTable (const G4ParticleDefinition &pd)
 
virtual void PrepareWorkerPhysicsTable (const G4ParticleDefinition &pd)
 
- Public Member Functions inherited from G4VProcess
 G4VProcess (const G4String &aName="NoName", G4ProcessType aType=fNotDefined)
 
 G4VProcess (const G4VProcess &right)
 
virtual ~G4VProcess ()
 
G4int operator== (const G4VProcess &right) const
 
G4int operator!= (const G4VProcess &right) const
 
G4double GetCurrentInteractionLength () const
 
void SetPILfactor (G4double value)
 
G4double GetPILfactor () const
 
G4double AlongStepGPIL (const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
 
G4double AtRestGPIL (const G4Track &track, G4ForceCondition *condition)
 
G4double PostStepGPIL (const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
 
const G4StringGetPhysicsTableFileName (const G4ParticleDefinition *, const G4String &directory, const G4String &tableName, G4bool ascii=false)
 
const G4StringGetProcessName () const
 
G4ProcessType GetProcessType () const
 
void SetProcessType (G4ProcessType)
 
G4int GetProcessSubType () const
 
void SetProcessSubType (G4int)
 
G4double GetNumberOfInteractionLengthLeft () const
 
G4double GetTotalNumberOfInteractionLengthTraversed () const
 
G4bool isAtRestDoItIsEnabled () const
 
G4bool isAlongStepDoItIsEnabled () const
 
G4bool isPostStepDoItIsEnabled () const
 
virtual void DumpInfo () const
 
void SetVerboseLevel (G4int value)
 
G4int GetVerboseLevel () const
 
const G4VProcessGetMasterProcess () const
 

Static Public Member Functions

static const
G4BiasingProcessSharedData
GetSharedData (const G4ProcessManager *)
 
- Static Public Member Functions inherited from G4VProcess
static const G4StringGetProcessTypeName (G4ProcessType)
 

Additional Inherited Members

- Protected Member Functions inherited from G4VProcess
void SubtractNumberOfInteractionLengthLeft (G4double previousStepSize)
 
void ClearNumberOfInteractionLengthLeft ()
 
- Protected Attributes inherited from G4VProcess
const G4ProcessManageraProcessManager
 
G4VParticleChangepParticleChange
 
G4ParticleChange aParticleChange
 
G4double theNumberOfInteractionLengthLeft
 
G4double currentInteractionLength
 
G4double theInitialNumberOfInteractionLength
 
G4String theProcessName
 
G4String thePhysicsTableFileName
 
G4ProcessType theProcessType
 
G4int theProcessSubType
 
G4double thePILfactor
 
G4bool enableAtRestDoIt
 
G4bool enableAlongStepDoIt
 
G4bool enablePostStepDoIt
 
G4int verboseLevel
 

Detailed Description

Definition at line 70 of file G4BiasingProcessInterface.hh.

Constructor & Destructor Documentation

G4BiasingProcessInterface::G4BiasingProcessInterface ( G4String  name = "biasWrapper(0)")

Definition at line 42 of file G4BiasingProcessInterface.cc.

43  : G4VProcess ( name ),
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 ),
58  fBiasingForceCondition ( NotForced ),
59  fWrappedProcessAlongStepGPIL ( -1.0 ),
60  fBiasingAlongStepGPIL ( -1.0 ),
61  fWrappedProcessGPILSelection ( NotCandidateForSelection ),
62  fBiasingGPILSelection ( NotCandidateForSelection ),
63  fBiasingInteractionLaw ( nullptr ),
64  fPreviousBiasingInteractionLaw ( nullptr ),
65  fPhysicalInteractionLaw ( nullptr ),
66  fOccurenceBiasingParticleChange ( nullptr ),
67  fDummyParticleChange ( nullptr ),
68  fIamFirstGPIL ( false ),
69  fProcessManager ( nullptr ),
70  fSharedData ( nullptr )
71 {
72  for (G4int i = 0 ; i < 8 ; i++) fFirstLastFlags[i] = false;
73  fResetInteractionLaws.Put( true );
74  fCommonStart.Put(true);
75  fCommonEnd.Put(true);
76  fDoCommonConfigure.Put(true);
77 }
G4VProcess(const G4String &aName="NoName", G4ProcessType aType=fNotDefined)
Definition: G4VProcess.cc:52
int G4int
Definition: G4Types.hh:78
void Put(const value_type &val) const
Definition: G4Cache.hh:286

Here is the call graph for this function:

G4BiasingProcessInterface::G4BiasingProcessInterface ( G4VProcess wrappedProcess,
G4bool  wrappedIsAtRest,
G4bool  wrappedIsAlongStep,
G4bool  wrappedIsPostStep,
G4String  useThisName = "" 
)

Definition at line 80 of file G4BiasingProcessInterface.cc.

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 ),
99  fBiasingForceCondition ( NotForced ),
100  fWrappedProcessAlongStepGPIL ( -1.0 ),
101  fBiasingAlongStepGPIL ( -1.0 ),
102  fWrappedProcessGPILSelection ( NotCandidateForSelection ),
103  fBiasingGPILSelection ( NotCandidateForSelection ),
104  fBiasingInteractionLaw ( nullptr ),
105  fPreviousBiasingInteractionLaw ( nullptr ),
106  fPhysicalInteractionLaw ( nullptr ),
107  fOccurenceBiasingParticleChange ( nullptr ),
108  fIamFirstGPIL ( false ),
109  fProcessManager ( nullptr ),
110  fSharedData ( nullptr )
111 {
112  for (G4int i = 0 ; i < 8 ; i++) fFirstLastFlags[i] = false;
113  fResetInteractionLaws.Put( true );
114  fCommonStart.Put(true);
115  fCommonEnd.Put(true);
116  fDoCommonConfigure.Put(true);
117 
118  SetProcessSubType(fWrappedProcess->GetProcessSubType());
119 
120  // -- create physical interaction law:
121  fPhysicalInteractionLaw = new G4InteractionLawPhysical("PhysicalInteractionLawFor("+GetProcessName()+")");
122  // -- instantiate particle change wrapper for occurence biaising:
123  fOccurenceBiasingParticleChange = new G4ParticleChangeForOccurenceBiasing("biasingPCfor"+GetProcessName());
124  // -- instantiate a "do nothing" particle change:
125  fDummyParticleChange = new G4ParticleChangeForNothing();
126 }
G4VProcess(const G4String &aName="NoName", G4ProcessType aType=fNotDefined)
Definition: G4VProcess.cc:52
G4ProcessType GetProcessType() const
Definition: G4VProcess.hh:414
int G4int
Definition: G4Types.hh:78
void SetProcessSubType(G4int)
Definition: G4VProcess.hh:432
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
void Put(const value_type &val) const
Definition: G4Cache.hh:286
G4int GetProcessSubType() const
Definition: G4VProcess.hh:426

Here is the call graph for this function:

G4BiasingProcessInterface::~G4BiasingProcessInterface ( )

Definition at line 130 of file G4BiasingProcessInterface.cc.

131 {
132  if ( fPhysicalInteractionLaw != 0 ) delete fPhysicalInteractionLaw;
133  if ( fOccurenceBiasingParticleChange ) delete fOccurenceBiasingParticleChange;
134  if ( fDummyParticleChange ) delete fDummyParticleChange;
135 }

Member Function Documentation

G4VParticleChange * G4BiasingProcessInterface::AlongStepDoIt ( const G4Track track,
const G4Step step 
)
virtual

Implements G4VProcess.

Definition at line 651 of file G4BiasingProcessInterface.cc.

653 {
654 
655  // ---------------------------------------
656  // -- case outside of volume with biasing:
657  // ---------------------------------------
658  if ( fSharedData->fCurrentBiasingOperator == 0 )
659  {
660  if ( fWrappedProcessIsAlong ) return fWrappedProcess->AlongStepDoIt(track, step);
661  else
662  {
663  fDummyParticleChange->Initialize( track );
664  return fDummyParticleChange;
665  }
666  }
667 
668  // -----------------------------------
669  // -- case inside volume with biasing:
670  // -----------------------------------
671  if ( fWrappedProcessIsAlong ) fOccurenceBiasingParticleChange->SetWrappedParticleChange( fWrappedProcess->AlongStepDoIt(track, step) );
672  else
673  {
674  fOccurenceBiasingParticleChange->SetWrappedParticleChange ( 0 );
675  fOccurenceBiasingParticleChange->ProposeTrackStatus( track.GetTrackStatus() );
676  }
677  G4double weightForNonInteraction (1.0);
678  if ( fBiasingInteractionLaw != 0 )
679  {
680  weightForNonInteraction =
681  fPhysicalInteractionLaw->ComputeNonInteractionProbabilityAt(step.GetStepLength()) /
682  fBiasingInteractionLaw ->ComputeNonInteractionProbabilityAt(step.GetStepLength());
683 
684  fOccurenceBiasingOperation->AlongMoveBy( this, &step, weightForNonInteraction );
685 
686  if ( weightForNonInteraction <= 0. )
687  {
689  ed << " Negative non interaction weight : w_NI = " << weightForNonInteraction <<
690  " p_NI(phys) = " << fPhysicalInteractionLaw->ComputeNonInteractionProbabilityAt(step.GetStepLength()) <<
691  " p_NI(bias) = " << fBiasingInteractionLaw ->ComputeNonInteractionProbabilityAt(step.GetStepLength()) <<
692  " step length = " << step.GetStepLength() <<
693  " biasing interaction law = `" << fBiasingInteractionLaw->GetName() << "'" << G4endl;
694  G4Exception(" G4BiasingProcessInterface::AlongStepDoIt(...)",
695  "BIAS.GEN.04",
696  JustWarning,
697  ed);
698  }
699 
700  }
701 
702  fOccurenceBiasingParticleChange->SetOccurenceWeightForNonInteraction( weightForNonInteraction );
703 
704  return fOccurenceBiasingParticleChange;
705 
706 }
virtual void Initialize(const G4Track &track)
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double GetStepLength() const
G4TrackStatus GetTrackStatus() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &stepData)=0
#define G4endl
Definition: G4ios.hh:61
const G4String & GetName() const
virtual void AlongMoveBy(const G4BiasingProcessInterface *, const G4Step *, G4double)
double G4double
Definition: G4Types.hh:76
void ProposeTrackStatus(G4TrackStatus status)

Here is the call graph for this function:

G4double G4BiasingProcessInterface::AlongStepGetPhysicalInteractionLength ( const G4Track track,
G4double  previousStepSize,
G4double  currentMinimumStep,
G4double proposedSafety,
G4GPILSelection selection 
)
virtual

Implements G4VProcess.

Definition at line 572 of file G4BiasingProcessInterface.cc.

577 {
578 
579  // -- for helper methods:
580  fCurrentMinimumStep = currentMinimumStep;
581  fProposedSafety = proposedSafety;
582 
583 
584  // -- initialization default case:
585  fWrappedProcessAlongStepGPIL = DBL_MAX;
586  *selection = NotCandidateForSelection;
587  // ---------------------------------------
588  // -- case outside of volume with biasing:
589  // ---------------------------------------
590  if ( fSharedData->fCurrentBiasingOperator == 0 )
591  {
592  if ( fWrappedProcessIsAlong ) fWrappedProcessAlongStepGPIL =
593  fWrappedProcess->AlongStepGetPhysicalInteractionLength(track,
594  previousStepSize,
595  currentMinimumStep,
596  proposedSafety,
597  selection);
598  return fWrappedProcessAlongStepGPIL;
599  }
600 
601  // --------------------------------------------------------------------
602  // -- non-physics based biasing: no along operation expected (for now):
603  // --------------------------------------------------------------------
604  if ( !fIsPhysicsBasedBiasing ) return fWrappedProcessAlongStepGPIL;
605 
606  // ----------------------
607  // -- physics-based case:
608  // ----------------------
609  if ( fOccurenceBiasingOperation == 0 )
610  {
611  if ( fWrappedProcessIsAlong ) fWrappedProcessAlongStepGPIL =
612  fWrappedProcess->AlongStepGetPhysicalInteractionLength(track,
613  previousStepSize,
614  currentMinimumStep,
615  proposedSafety,
616  selection);
617  return fWrappedProcessAlongStepGPIL;
618  }
619 
620 
621  // ----------------------------------------------------------
622  // -- From here we have an valid occurence biasing operation:
623  // ----------------------------------------------------------
624  // -- Give operation opportunity to shorten step proposed by physics process:
625  fBiasingAlongStepGPIL = fOccurenceBiasingOperation->ProposeAlongStepLimit( this );
626  G4double minimumStep = fBiasingAlongStepGPIL < currentMinimumStep ? fBiasingAlongStepGPIL : currentMinimumStep ;
627  // -- wrapped process is called with minimum step ( <= currentMinimumStep passed ) : an along process can not
628  // -- have its operation stretched over what it expects:
629  if ( fWrappedProcessIsAlong )
630  {
631  fWrappedProcessAlongStepGPIL = fWrappedProcess->AlongStepGetPhysicalInteractionLength(track,
632  previousStepSize,
633  minimumStep,
634  proposedSafety,
635  selection);
636  fWrappedProcessGPILSelection = *selection;
637  fBiasingGPILSelection = fOccurenceBiasingOperation->ProposeGPILSelection( fWrappedProcessGPILSelection );
638  }
639  else
640  {
641  fBiasingGPILSelection = fOccurenceBiasingOperation->ProposeGPILSelection( NotCandidateForSelection );
642  fWrappedProcessAlongStepGPIL = fBiasingAlongStepGPIL;
643  }
644 
645  *selection = fBiasingGPILSelection;
646 
647  return fWrappedProcessAlongStepGPIL;
648 
649 }
virtual G4double ProposeAlongStepLimit(const G4BiasingProcessInterface *)
virtual G4GPILSelection ProposeGPILSelection(const G4GPILSelection wrappedProcessSelection)
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)=0
double G4double
Definition: G4Types.hh:76
#define DBL_MAX
Definition: templates.hh:83

Here is the call graph for this function:

G4VParticleChange * G4BiasingProcessInterface::AtRestDoIt ( const G4Track track,
const G4Step step 
)
virtual

Implements G4VProcess.

Definition at line 714 of file G4BiasingProcessInterface.cc.

716 {
717  return fWrappedProcess->AtRestDoIt(track, step);
718 }
virtual G4VParticleChange * AtRestDoIt(const G4Track &track, const G4Step &stepData)=0

Here is the call graph for this function:

G4double G4BiasingProcessInterface::AtRestGetPhysicalInteractionLength ( const G4Track track,
G4ForceCondition condition 
)
virtual

Implements G4VProcess.

Definition at line 709 of file G4BiasingProcessInterface.cc.

711 {
712  return fWrappedProcess->AtRestGetPhysicalInteractionLength(track, condition);
713 }
G4double condition(const G4ErrorSymMatrix &m)
virtual G4double AtRestGetPhysicalInteractionLength(const G4Track &track, G4ForceCondition *condition)=0

Here is the call graph for this function:

void G4BiasingProcessInterface::BuildPhysicsTable ( const G4ParticleDefinition pd)
virtual

Reimplemented from G4VProcess.

Definition at line 744 of file G4BiasingProcessInterface.cc.

745 {
746  // -- Sequential mode : called second (after PreparePhysicsTable(..))
747  // -- MT mode : called second (after PreparePhysicsTable(..)) by master thread.
748  // -- Corresponding process instance not used then by tracking.
749  // -- PreparePhysicsTable(...) has been called first for all processes,
750  // -- so the first/last flags and G4BiasingProcessInterface vector of processes have
751  // -- been properly setup, fIamFirstGPIL is valid.
752  if ( fWrappedProcess != 0 )
753  {
754  fWrappedProcess->BuildPhysicsTable(pd);
755  }
756 
757  if ( fIamFirstGPIL )
758  {
759  // -- Re-order vector of processes to match that of the GPIL
760  // -- (made for fIamFirstGPIL, but important is to have it made once):
761  ReorderBiasingVectorAsGPIL();
762  // -- Let operators to configure themselves for the master thread or for sequential mode.
763  // -- Intended here is in particular the registration to physics model catalog.
764  // -- The fDoCommonConfigure is to ensure that this Configure is made by only one process (othewise each first process makes the call):
765  if ( fDoCommonConfigure.Get() )
766  {
767  for ( size_t optr = 0 ; optr < ( G4VBiasingOperator::GetBiasingOperators() ).size() ; optr ++)
769  fDoCommonConfigure.Put(false);
770  }
771 
772  }
773 }
value_type & Get() const
Definition: G4Cache.hh:282
def Configure
Definition: demo.py:20
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:210
static const std::vector< G4VBiasingOperator * > & GetBiasingOperators()
void Put(const value_type &val) const
Definition: G4Cache.hh:286

Here is the call graph for this function:

void G4BiasingProcessInterface::BuildWorkerPhysicsTable ( const G4ParticleDefinition pd)
virtual

Reimplemented from G4VProcess.

Definition at line 841 of file G4BiasingProcessInterface.cc.

842 {
843  // -- Sequential mode : not called
844  // -- MT mode : called after PrepareWorkerPhysicsTable(..)
845  // -- PrepareWorkerPhysicsTable(...) has been called first for all processes,
846  // -- so the first/last flags and G4BiasingProcessInterface vector of processes have
847  // -- been properly setup, fIamFirstGPIL is valid.
848  if ( fWrappedProcess != 0 )
849  {
850  fWrappedProcess->BuildWorkerPhysicsTable(pd);
851  }
852 
853  if ( fIamFirstGPIL )
854  {
855  // -- Re-order vector of processes to match that of the GPIL
856  // -- (made for fIamFirstGPIL, but important is to have it made once):
857  ReorderBiasingVectorAsGPIL();
858  // -- Let operators to configure themselves for the worker thread, if needed.
859  // -- Registration to physics model catalog **IS NOT** to be made here, but in Configure().
860  // -- The fDoCommonConfigure is to ensure that this Configure is made by only one process (othewise each first process makes the call):
861  if ( fDoCommonConfigure.Get() )
862  {
863  for ( size_t optr = 0 ; optr < ( G4VBiasingOperator::GetBiasingOperators() ).size() ; optr ++)
864  ( G4VBiasingOperator::GetBiasingOperators() )[optr]->ConfigureForWorker( );
865  fDoCommonConfigure.Put(false);
866  }
867  }
868 }
value_type & Get() const
Definition: G4Cache.hh:282
virtual void BuildWorkerPhysicsTable(const G4ParticleDefinition &part)
Definition: G4VProcess.cc:202
static const std::vector< G4VBiasingOperator * > & GetBiasingOperators()
void Put(const value_type &val) const
Definition: G4Cache.hh:286

Here is the call graph for this function:

void G4BiasingProcessInterface::EndTracking ( )
virtual

Reimplemented from G4VProcess.

Definition at line 184 of file G4BiasingProcessInterface.cc.

185 {
186  if ( fIsPhysicsBasedBiasing ) fWrappedProcess->EndTracking();
187  if ( fSharedData->fCurrentBiasingOperator) (fSharedData->fCurrentBiasingOperator)->ExitingBiasing( fCurrentTrack, this );
188  fBiasingInteractionLaw = 0;
189 
190  // -- Inform operators of end of tracking:
191  if ( fCommonEnd.Get() )
192  {
193  fCommonEnd.Put( false );// = false;
194  fCommonStart.Put( true );// = true;
195 
196  for ( size_t optr = 0 ; optr < ( G4VBiasingOperator::GetBiasingOperators() ).size() ; optr ++)
198 
199  // -- §§ for above loop, do as in StartTracking.
200  }
201 }
value_type & Get() const
Definition: G4Cache.hh:282
static const std::vector< G4VBiasingOperator * > & GetBiasingOperators()
virtual void EndTracking()
Definition: G4VProcess.cc:113
void Put(const value_type &val) const
Definition: G4Cache.hh:286

Here is the call graph for this function:

G4double G4BiasingProcessInterface::GetAlongStepGPIL ( ) const
inline

Definition at line 154 of file G4BiasingProcessInterface.hh.

154 { return fWrappedProcessAlongStepGPIL; }

Here is the caller graph for this function:

const std::vector< const G4BiasingProcessInterface* >& G4BiasingProcessInterface::GetBiasingProcessInterfaces ( ) const
inline

Definition at line 107 of file G4BiasingProcessInterface.hh.

108  {return fSharedData-> fPublicBiasingProcessInterfaces;}
G4VBiasingOperator* G4BiasingProcessInterface::GetCurrentBiasingOperator ( ) const
inline

Definition at line 93 of file G4BiasingProcessInterface.hh.

93 {return fSharedData-> fCurrentBiasingOperator; }
G4VBiasingOperation* G4BiasingProcessInterface::GetCurrentFinalStateBiasingOperation ( ) const
inline

Definition at line 100 of file G4BiasingProcessInterface.hh.

100 { return fFinalStateBiasingOperation; }
G4double G4BiasingProcessInterface::GetCurrentMinimumStep ( ) const
inline

Definition at line 149 of file G4BiasingProcessInterface.hh.

149 { return fCurrentMinimumStep;}
G4VBiasingOperation* G4BiasingProcessInterface::GetCurrentNonPhysicsBiasingOperation ( ) const
inline

Definition at line 96 of file G4BiasingProcessInterface.hh.

96 { return fNonPhysicsBiasingOperation; }
G4VBiasingOperation* G4BiasingProcessInterface::GetCurrentOccurenceBiasingOperation ( ) const
inline

Definition at line 98 of file G4BiasingProcessInterface.hh.

98 { return fOccurenceBiasingOperation; }
G4bool G4BiasingProcessInterface::GetIsFirstPostStepDoItInterface ( G4bool  physOnly = true) const

Definition at line 905 of file G4BiasingProcessInterface.cc.

906 {
907  G4int iPhys = ( physOnly ) ? 1 : 0;
908  return fFirstLastFlags[IdxFirstLast( 1, 0, iPhys)];
909 }
int G4int
Definition: G4Types.hh:78

Here is the caller graph for this function:

G4bool G4BiasingProcessInterface::GetIsFirstPostStepGPILInterface ( G4bool  physOnly = true) const

Definition at line 891 of file G4BiasingProcessInterface.cc.

892 {
893  G4int iPhys = ( physOnly ) ? 1 : 0;
894  return fFirstLastFlags[IdxFirstLast( 1, 1, iPhys)];
895 }
int G4int
Definition: G4Types.hh:78
G4bool G4BiasingProcessInterface::GetIsLastPostStepDoItInterface ( G4bool  physOnly = true) const

Definition at line 912 of file G4BiasingProcessInterface.cc.

913 {
914  G4int iPhys = ( physOnly ) ? 1 : 0;
915  return fFirstLastFlags[IdxFirstLast( 0, 0, iPhys)];
916 }
int G4int
Definition: G4Types.hh:78
G4bool G4BiasingProcessInterface::GetIsLastPostStepGPILInterface ( G4bool  physOnly = true) const

Definition at line 898 of file G4BiasingProcessInterface.cc.

899 {
900  G4int iPhys = ( physOnly ) ? 1 : 0;
901  return fFirstLastFlags[IdxFirstLast( 0, 1, iPhys)];
902 }
int G4int
Definition: G4Types.hh:78
const std::vector< const G4BiasingProcessInterface* >& G4BiasingProcessInterface::GetNonPhysicsBiasingProcessInterfaces ( ) const
inline

Definition at line 111 of file G4BiasingProcessInterface.hh.

112  {return fSharedData->fPublicNonPhysicsBiasingProcessInterfaces;}
const std::vector< const G4BiasingProcessInterface* >& G4BiasingProcessInterface::GetPhysicsBiasingProcessInterfaces ( ) const
inline

Definition at line 109 of file G4BiasingProcessInterface.hh.

110  {return fSharedData-> fPublicPhysicsBiasingProcessInterfaces;}
G4double G4BiasingProcessInterface::GetPostStepGPIL ( ) const
inline

Definition at line 153 of file G4BiasingProcessInterface.hh.

153 { return fBiasingPostStepGPIL; }

Here is the caller graph for this function:

G4VBiasingOperator* G4BiasingProcessInterface::GetPreviousBiasingOperator ( ) const
inline

Definition at line 94 of file G4BiasingProcessInterface.hh.

94 {return fSharedData->fPreviousBiasingOperator; }
G4VBiasingOperation* G4BiasingProcessInterface::GetPreviousFinalStateBiasingOperation ( ) const
inline

Definition at line 101 of file G4BiasingProcessInterface.hh.

101 { return fPreviousFinalStateBiasingOperation; }
G4VBiasingOperation* G4BiasingProcessInterface::GetPreviousNonPhysicsBiasingOperation ( ) const
inline

Definition at line 97 of file G4BiasingProcessInterface.hh.

97 { return fPreviousNonPhysicsBiasingOperation; }
G4VBiasingOperation* G4BiasingProcessInterface::GetPreviousOccurenceBiasingOperation ( ) const
inline

Definition at line 99 of file G4BiasingProcessInterface.hh.

99 { return fPreviousOccurenceBiasingOperation; }
G4double G4BiasingProcessInterface::GetPreviousStepSize ( ) const
inline

Definition at line 148 of file G4BiasingProcessInterface.hh.

148 { return fPreviousStepSize;}
const G4ProcessManager * G4BiasingProcessInterface::GetProcessManager ( )
virtual

Reimplemented from G4VProcess.

Definition at line 834 of file G4BiasingProcessInterface.cc.

835 {
836  if ( fWrappedProcess != 0 ) return fWrappedProcess->GetProcessManager();
837  else return G4VProcess::GetProcessManager();
838 }
virtual const G4ProcessManager * GetProcessManager()
Definition: G4VProcess.hh:514

Here is the call graph for this function:

G4double G4BiasingProcessInterface::GetProposedSafety ( ) const
inline

Definition at line 150 of file G4BiasingProcessInterface.hh.

150 { return fProposedSafety;}
const G4BiasingProcessSharedData* G4BiasingProcessInterface::GetSharedData ( ) const
inline

Definition at line 115 of file G4BiasingProcessInterface.hh.

115 { return fSharedData; }

Here is the caller graph for this function:

const G4BiasingProcessSharedData * G4BiasingProcessInterface::GetSharedData ( const G4ProcessManager mgr)
static

Definition at line 138 of file G4BiasingProcessInterface.cc.

139 {
140  G4MapCache< const G4ProcessManager*,
141  G4BiasingProcessSharedData* >::const_iterator itr = G4BiasingProcessSharedData::fSharedDataMap.Find( mgr );
142  if ( itr != G4BiasingProcessSharedData::fSharedDataMap.End( ) )
143  {
144  return (*itr).second;
145  }
146  else return 0;
147 }
iterator Find(const key_type &k)
Definition: G4Cache.hh:417

Here is the call graph for this function:

G4VProcess* G4BiasingProcessInterface::GetWrappedProcess ( ) const
inline

Definition at line 85 of file G4BiasingProcessInterface.hh.

85 {return fWrappedProcess;}

Here is the caller graph for this function:

G4bool G4BiasingProcessInterface::GetWrappedProcessIsAlong ( ) const
inline

Definition at line 143 of file G4BiasingProcessInterface.hh.

143 { return fWrappedProcessIsAlong; }
G4bool G4BiasingProcessInterface::GetWrappedProcessIsAtRest ( ) const
inline

Definition at line 142 of file G4BiasingProcessInterface.hh.

142 { return fWrappedProcessIsAtRest; }
G4bool G4BiasingProcessInterface::GetWrappedProcessIsPost ( ) const
inline

Definition at line 144 of file G4BiasingProcessInterface.hh.

144 { return fWrappedProcessIsPost; }
G4bool G4BiasingProcessInterface::IsApplicable ( const G4ParticleDefinition pd)
virtual

Reimplemented from G4VProcess.

Definition at line 721 of file G4BiasingProcessInterface.cc.

722 {
723  if ( fWrappedProcess != 0 ) return fWrappedProcess->IsApplicable(pd);
724  else return true;
725 }
virtual G4bool IsApplicable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:205

Here is the call graph for this function:

G4bool G4BiasingProcessInterface::IsFirstPostStepDoItInterface ( G4bool  physOnly = true) const

Definition at line 965 of file G4BiasingProcessInterface.cc.

966 {
967  G4bool isFirst = true;
968  const G4ProcessVector* pv = fProcessManager->GetPostStepProcessVector(typeDoIt);
969  G4int thisIdx(-1);
970  for (G4int i = 0; i < pv->size(); i++ ) if ( (*pv)(i) == this ) { thisIdx = i; break; }
971  for ( size_t i = 0; i < (fSharedData->fBiasingProcessInterfaces).size(); i++ )
972  {
973  if ( (fSharedData->fBiasingProcessInterfaces)[i]->fIsPhysicsBasedBiasing || !physOnly )
974  {
975  G4int thatIdx(-1);
976  for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (fSharedData->fBiasingProcessInterfaces)[i] ) { thatIdx = j; break; }
977  if ( thisIdx > thatIdx )
978  {
979  isFirst = false;
980  break;
981  }
982  }
983  }
984  return isFirst;
985 }
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4int size() const
G4ProcessVector * GetPostStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const

Here is the call graph for this function:

G4bool G4BiasingProcessInterface::IsFirstPostStepGPILInterface ( G4bool  physOnly = true) const

Definition at line 919 of file G4BiasingProcessInterface.cc.

920 {
921  G4bool isFirst = true;
922  const G4ProcessVector* pv = fProcessManager->GetPostStepProcessVector(typeGPIL);
923  G4int thisIdx(-1);
924  for (G4int i = 0; i < pv->size(); i++ ) if ( (*pv)(i) == this ) { thisIdx = i; break; }
925  for ( size_t i = 0; i < (fSharedData->fBiasingProcessInterfaces).size(); i++ )
926  {
927  if ( (fSharedData->fBiasingProcessInterfaces)[i]->fIsPhysicsBasedBiasing || !physOnly )
928  {
929  G4int thatIdx(-1);
930  for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (fSharedData->fBiasingProcessInterfaces)[i] ) { thatIdx = j; break; }
931  if ( thisIdx > thatIdx )
932  {
933  isFirst = false;
934  break;
935  }
936  }
937  }
938  return isFirst;
939 }
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4int size() const
G4ProcessVector * GetPostStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const

Here is the call graph for this function:

G4bool G4BiasingProcessInterface::IsLastPostStepDoItInterface ( G4bool  physOnly = true) const

Definition at line 988 of file G4BiasingProcessInterface.cc.

989 {
990  G4bool isLast = true;
991  const G4ProcessVector* pv = fProcessManager->GetPostStepProcessVector(typeDoIt);
992  G4int thisIdx(-1);
993  for (G4int i = 0; i < pv->size(); i++ ) if ( (*pv)(i) == this ) { thisIdx = i; break; }
994  for ( size_t i = 0; i < (fSharedData->fBiasingProcessInterfaces).size(); i++ )
995  {
996  if ( (fSharedData->fBiasingProcessInterfaces)[i]->fIsPhysicsBasedBiasing || !physOnly )
997  {
998  G4int thatIdx(-1);
999  for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (fSharedData->fBiasingProcessInterfaces)[i] ) { thatIdx = j; break; }
1000  if ( thisIdx < thatIdx )
1001  {
1002  isLast = false;
1003  break;
1004  }
1005  }
1006  }
1007  return isLast;
1008 }
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4int size() const
G4ProcessVector * GetPostStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const

Here is the call graph for this function:

G4bool G4BiasingProcessInterface::IsLastPostStepGPILInterface ( G4bool  physOnly = true) const

Definition at line 942 of file G4BiasingProcessInterface.cc.

943 {
944  G4bool isLast = true;
945  const G4ProcessVector* pv = fProcessManager->GetPostStepProcessVector(typeGPIL);
946  G4int thisIdx(-1);
947  for (G4int i = 0; i < pv->size(); i++ ) if ( (*pv)(i) == this ) { thisIdx = i; break; }
948  for ( size_t i = 0; i < (fSharedData->fBiasingProcessInterfaces).size(); i++ )
949  {
950  if ( (fSharedData->fBiasingProcessInterfaces)[i]->fIsPhysicsBasedBiasing || !physOnly )
951  {
952  G4int thatIdx(-1);
953  for (G4int j = 0; j < pv->size(); j++ ) if ( (*pv)(j) == (fSharedData->fBiasingProcessInterfaces)[i] ) { thatIdx = j; break; }
954  if ( thisIdx < thatIdx )
955  {
956  isLast = false;
957  break;
958  }
959  }
960  }
961  return isLast;
962 }
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4int size() const
G4ProcessVector * GetPostStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const

Here is the call graph for this function:

G4VParticleChange * G4BiasingProcessInterface::PostStepDoIt ( const G4Track track,
const G4Step step 
)
virtual

Implements G4VProcess.

Definition at line 449 of file G4BiasingProcessInterface.cc.

451 {
452 
453  // ---------------------------------------
454  // -- case outside of volume with biasing:
455  // ---------------------------------------
456  if ( fSharedData->fCurrentBiasingOperator == 0 ) return fWrappedProcess->PostStepDoIt(track, step);
457 
458  // ----------------------------
459  // -- non-physics biasing case:
460  // ----------------------------
461  if ( !fIsPhysicsBasedBiasing )
462  {
463  G4VParticleChange* particleChange = fNonPhysicsBiasingOperation->GenerateBiasingFinalState( &track, &step );
464  (fSharedData->fCurrentBiasingOperator)->ReportOperationApplied( this, BAC_NonPhysics, fNonPhysicsBiasingOperation, particleChange );
465  return particleChange;
466  }
467 
468  // -- physics biasing case:
469  // ------------------------
470  // -- It proceeds with the following logic:
471  // -- 1) Obtain the final state
472  // -- This final state may be analog or biased.
473  // -- The biased final state is obtained through a biasing operator
474  // -- returned by the operator.
475  // -- 2) The biased final state may be asked to be "force as it is"
476  // -- in what case the particle change is returned as is to the
477  // -- stepping.
478  // -- In all other cases (analog final state or biased final but
479  // -- not forced) the final state weight may be modified by the
480  // -- occurence biasing, if such an occurence biasing is at play.
481 
482  // -- Get final state, biased or analog:
483  G4VParticleChange* finalStateParticleChange;
485  fFinalStateBiasingOperation = (fSharedData->fCurrentBiasingOperator)->GetProposedFinalStateBiasingOperation( &track, this );
486  // -- Flag below is to force the biased generated particle change to be retruned "as is" to the stepping, disregarding there
487  // -- was or not a occurence biasing that would apply. Weight relevance under full responsibility of the biasing operation.
488  G4bool forceBiasedFinalState = false;
489  if ( fFinalStateBiasingOperation != 0 )
490  {
491  finalStateParticleChange = fFinalStateBiasingOperation->ApplyFinalStateBiasing( this, &track, &step, forceBiasedFinalState );
492  BAC = BAC_FinalState;
493  }
494  else
495  {
496  finalStateParticleChange = fWrappedProcess->PostStepDoIt(track, step);
497  BAC = BAC_None ;
498  }
499 
500  // -- if no occurence biasing operation, we're done:
501  if ( fOccurenceBiasingOperation == 0 )
502  {
503  (fSharedData->fCurrentBiasingOperator)->ReportOperationApplied( this, BAC, fFinalStateBiasingOperation, finalStateParticleChange );
504  return finalStateParticleChange;
505  }
506 
507  // -- if biased final state has been asked to be forced, we're done:
508  if ( forceBiasedFinalState )
509  {
510  (fSharedData->fCurrentBiasingOperator)->ReportOperationApplied( this, BAC, fFinalStateBiasingOperation, finalStateParticleChange );
511  return finalStateParticleChange;
512  }
513 
514 
515  // -- If occurence biasing, applies the occurence biasing weight correction on top of final state (biased or not):
516  G4double weightForInteraction = 1.0;
517  if ( !fBiasingInteractionLaw->IsSingular() ) weightForInteraction =
518  fPhysicalInteractionLaw->ComputeEffectiveCrossSectionAt(step.GetStepLength()) /
519  fBiasingInteractionLaw ->ComputeEffectiveCrossSectionAt(step.GetStepLength());
520  else
521  {
522  // -- at this point effective XS can only be infinite, if not, there is a logic problem
523  if ( !fBiasingInteractionLaw->IsEffectiveCrossSectionInfinite() )
524  {
526  ed << "Internal inconsistency in cross-section handling. Please report !" << G4endl;
527  G4Exception(" G4BiasingProcessInterface::PostStepDoIt(...)",
528  "BIAS.GEN.02",
529  JustWarning,
530  ed);
531  // -- if XS is infinite, weight is zero (and will stay zero), but we'll do differently.
532  // -- Should foresee in addition something to remember that in case of singular
533  // -- distribution, weight can only be partly calculated
534  }
535  }
536 
537  if ( weightForInteraction <= 0. )
538  {
540  ed << " Negative interaction weight : w_I = "
541  << weightForInteraction <<
542  " XS_I(phys) = " << fBiasingInteractionLaw ->ComputeEffectiveCrossSectionAt(step.GetStepLength()) <<
543  " XS_I(bias) = " << fPhysicalInteractionLaw->ComputeEffectiveCrossSectionAt(step.GetStepLength()) <<
544  " step length = " << step.GetStepLength() <<
545  " Interaction law = `" << fBiasingInteractionLaw << "'" <<
546  G4endl;
547  G4Exception(" G4BiasingProcessInterface::PostStepDoIt(...)",
548  "BIAS.GEN.03",
549  JustWarning,
550  ed);
551 
552  }
553 
554  (fSharedData->fCurrentBiasingOperator)->ReportOperationApplied( this, BAC,
555  fOccurenceBiasingOperation, weightForInteraction,
556  fFinalStateBiasingOperation, finalStateParticleChange );
557 
558 
559  fOccurenceBiasingParticleChange->SetOccurenceWeightForInteraction( weightForInteraction );
560  fOccurenceBiasingParticleChange->SetSecondaryWeightByProcess( true );
561  fOccurenceBiasingParticleChange->SetWrappedParticleChange( finalStateParticleChange );
562  fOccurenceBiasingParticleChange->ProposeTrackStatus( finalStateParticleChange->GetTrackStatus() );
563  fOccurenceBiasingParticleChange->StealSecondaries(); // -- this also makes weightForInteraction applied to secondaries stolen
564 
565  // -- finish:
566  return fOccurenceBiasingParticleChange;
567 
568 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double GetStepLength() const
virtual G4VParticleChange * ApplyFinalStateBiasing(const G4BiasingProcessInterface *, const G4Track *, const G4Step *, G4bool &)=0
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const =0
G4BiasingAppliedCase
void SetSecondaryWeightByProcess(G4bool)
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const
bool G4bool
Definition: G4Types.hh:79
virtual G4VParticleChange * GenerateBiasingFinalState(const G4Track *, const G4Step *)=0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4bool IsSingular() const
#define G4endl
Definition: G4ios.hh:61
virtual G4bool IsEffectiveCrossSectionInfinite() const
G4TrackStatus GetTrackStatus() const
double G4double
Definition: G4Types.hh:76
void ProposeTrackStatus(G4TrackStatus status)
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &stepData)=0

Here is the call graph for this function:

G4double G4BiasingProcessInterface::PostStepGetPhysicalInteractionLength ( const G4Track track,
G4double  previousStepSize,
G4ForceCondition condition 
)
virtual

Implements G4VProcess.

Definition at line 205 of file G4BiasingProcessInterface.cc.

208 {
209 
210  // ---------------------------------------------------------------------------------------------------
211  // -- The "biasing process master" takes care of updating the biasing operator, and for all biasing
212  // -- processes it invokes the PostStepGPIL of physical wrapped processes (anticipate stepping manager
213  // -- call ! ) to make all cross-sections updated with current step, and hence available before the
214  // -- first call to the biasing operator.
215  // ---------------------------------------------------------------------------------------------------
216  if ( fIamFirstGPIL )
217  {
218  // -- Update previous biasing operator, and assume the operator stays the same by
219  // -- default and that it is not left at the beginning of this step. These
220  // -- assumptions might be wrong if there is a volume change (in paralllel or
221  // -- mass geometries) in what case the flags will be updated.
222  fSharedData->fPreviousBiasingOperator = fSharedData->fCurrentBiasingOperator;
223  fSharedData->fIsNewOperator = false;
224  fSharedData->fLeavingPreviousOperator = false;
225  // -- If new volume, either in mass or parallel geometries, get possible new biasing operator:
226  // -------------------------------------------------------------------------------------------
227  // -- Get biasing operator in parallel geometries:
228  G4bool firstStepInParallelVolume = false;
229  if ( fSharedData->fParallelGeometriesLimiterProcess )
230  {
231  G4VBiasingOperator* newParallelOperator( nullptr );
232  G4bool firstStep = ( track.GetCurrentStepNumber() == 1 );
233  size_t iParallel = 0;
234  for ( auto wasLimiting : fSharedData->fParallelGeometriesLimiterProcess->GetWasLimiting() )
235  {
236  if ( firstStep || wasLimiting )
237  {
238  firstStepInParallelVolume = true;
239 
240  auto tmpParallelOperator = G4VBiasingOperator::GetBiasingOperator( (fSharedData->fParallelGeometriesLimiterProcess->GetCurrentVolumes()[iParallel])
241  ->GetLogicalVolume() );
242  if ( newParallelOperator )
243  {
244  if ( tmpParallelOperator )
245  {
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(...)",
252  "BIAS.GEN.30",
253  JustWarning,
254  ed);
255  }
256  }
257  else newParallelOperator = tmpParallelOperator;
258  }
259  iParallel++;
260  }
261  fSharedData->fParallelGeometryOperator = newParallelOperator;
262  } // -- end of " if ( fSharedData->fParallelGeometriesLimiterProcess )"
263 
264  // -- Get biasing operator in mass geometry:
265  // -- [§§ Note : bug with this first step ? Does not work if previous step was concurrently limited with geometry. Might make use of safety at last point ?]
266  G4bool firstStepInVolume = ( (track.GetStep()->GetPreStepPoint()->GetStepStatus() == fGeomBoundary) || (track.GetCurrentStepNumber() == 1) );
267  // fSharedData->fIsNewOperator = false;
268  // fSharedData->fLeavingPreviousOperator = false;
269  if ( firstStepInVolume )
270  {
272  fSharedData->fMassGeometryOperator = newOperator;
273  if ( ( newOperator != nullptr ) && ( fSharedData->fParallelGeometryOperator != nullptr ) )
274  {
276  ed << " Biasing operators are defined at the same place in mass and parallel geometries ! Found:\n";
277  ed << " - `" << fSharedData->fParallelGeometryOperator->GetName() << "' in parallel geometry and \n";
278  ed << " - `" << newOperator->GetName() << "' in mass geometry.\n";
279  ed << " Keeping `" << fSharedData->fParallelGeometryOperator->GetName() << "'. Behavior not guaranteed ! Please consider having only one operator at a place. " << G4endl;
280  G4Exception(" G4BiasingProcessInterface::PostStepGetPhysicalInteractionLength(...)",
281  "BIAS.GEN.31",
282  JustWarning,
283  ed);
284  }
285  }
286 
287  // -- conclude the operator selection, giving priority to parallel geometry (as told in exception message BIAS.GEN.30):
288  if ( firstStepInVolume || firstStepInParallelVolume )
289  {
290  G4VBiasingOperator* newOperator = fSharedData->fParallelGeometryOperator;
291  if ( newOperator == nullptr ) newOperator = fSharedData->fMassGeometryOperator;
292 
293  fSharedData->fCurrentBiasingOperator = newOperator ;
294 
295  if ( newOperator != fSharedData->fPreviousBiasingOperator )
296  {
297  fSharedData->fLeavingPreviousOperator = ( fSharedData->fPreviousBiasingOperator != nullptr ) ;
298  fSharedData->fIsNewOperator = ( newOperator != nullptr );
299  }
300  }
301 
302 
303  // -- calls to wrapped process PostStepGPIL's:
304  // -------------------------------------------
305  // -- Each physics wrapper process has its
306  // -- fWrappedProcessPostStepGPIL ,
307  // -- fWrappedProcessForceCondition ,
308  // -- fWrappedProcessInteractionLength
309  // -- updated.
310  if ( fSharedData->fCurrentBiasingOperator != nullptr )
311  {
312  for ( size_t i = 0 ; i < (fSharedData->fPhysicsBiasingProcessInterfaces).size(); i++ )
313  (fSharedData->fPhysicsBiasingProcessInterfaces)[i]->InvokeWrappedProcessPostStepGPIL( track, previousStepSize, condition );
314  }
315  } // -- end of "if ( fIamFirstGPIL )"
316 
317 
318 
319  // -- Remember previous operator and proposed operations, if any, and reset:
320  // -------------------------------------------------------------------------
321  // -- remember only in case some biasing might be called
322  if ( ( fSharedData->fPreviousBiasingOperator != 0 ) ||
323  ( fSharedData->fCurrentBiasingOperator != 0 ) )
324  {
325  fPreviousOccurenceBiasingOperation = fOccurenceBiasingOperation;
326  fPreviousFinalStateBiasingOperation = fFinalStateBiasingOperation;
327  fPreviousNonPhysicsBiasingOperation = fNonPhysicsBiasingOperation;
328  fPreviousBiasingInteractionLaw = fBiasingInteractionLaw;
329  // -- reset:
330  fOccurenceBiasingOperation = 0;
331  fFinalStateBiasingOperation = 0;
332  fNonPhysicsBiasingOperation = 0;
333  fBiasingInteractionLaw = 0;
334  // -- Physics PostStep and AlongStep GPIL
335  // fWrappedProcessPostStepGPIL : updated by InvokeWrappedProcessPostStepGPIL(...) above
336  fBiasingPostStepGPIL = DBL_MAX;
337  // fWrappedProcessInteractionLength : updated by InvokeWrappedProcessPostStepGPIL(...) above; inverse of analog cross-section.
338  // fWrappedProcessForceCondition : updated by InvokeWrappedProcessPostStepGPIL(...) above
339  fBiasingForceCondition = NotForced;
340  fWrappedProcessAlongStepGPIL = DBL_MAX;
341  fBiasingAlongStepGPIL = DBL_MAX;
342  fWrappedProcessGPILSelection = NotCandidateForSelection;
343  fBiasingGPILSelection = NotCandidateForSelection;
344  // -- for helper:
345  fPreviousStepSize = previousStepSize;
346  }
347 
348 
349  // -- previous step size value; it is switched to zero if resetting a wrapped process:
350  // -- (same trick used than in InvokedWrappedProcessPostStepGPIL )
351  G4double usedPreviousStepSize = previousStepSize;
352 
353  // ----------------------------------------------
354  // -- If leaving a biasing operator, let it know:
355  // ----------------------------------------------
356  if ( fSharedData->fLeavingPreviousOperator )
357  {
358  (fSharedData->fPreviousBiasingOperator)->ExitingBiasing( &track, this );
359  // -- if no further biasing operator, reset process behavior to standard tracking:
360  if ( fSharedData->fCurrentBiasingOperator == 0 )
361  {
362  ResetForUnbiasedTracking();
363  if ( fIsPhysicsBasedBiasing )
364  {
365  // -- if the physics process has been under occurence biasing, reset it:
366  if ( fResetWrappedProcessInteractionLength )
367  {
368  fResetWrappedProcessInteractionLength = false;
369  fWrappedProcess->ResetNumberOfInteractionLengthLeft();
370  // -- We set "previous step size" as 0.0, to let the process believe this is first step:
371  usedPreviousStepSize = 0.0;
372  }
373  }
374  }
375  }
376 
377 
378  // --------------------------------------------------------------
379  // -- no operator : analog tracking if physics-based, or nothing:
380  // --------------------------------------------------------------
381  if ( fSharedData->fCurrentBiasingOperator == 0 )
382  {
383  // -- take note of the "usedPreviousStepSize" value:
384  if ( fIsPhysicsBasedBiasing ) return fWrappedProcess->PostStepGetPhysicalInteractionLength(track, usedPreviousStepSize, condition);
385  else
386  {
387  *condition = NotForced;
388  return DBL_MAX;
389  }
390  }
391 
392 
393 
394  // --------------------------------------------------
395  // -- A biasing operator exists. Proceed with
396  // -- treating non-physics and physics biasing cases:
397  //---------------------------------------------------
398 
399  // -- non-physics-based biasing case:
400  // ----------------------------------
401  if ( !fIsPhysicsBasedBiasing )
402  {
403  fNonPhysicsBiasingOperation = (fSharedData->fCurrentBiasingOperator)->GetProposedNonPhysicsBiasingOperation( &track, this );
404  if ( fNonPhysicsBiasingOperation == 0 )
405  {
406  *condition = NotForced;
407  return DBL_MAX;
408  }
409  return fNonPhysicsBiasingOperation->DistanceToApplyOperation(&track, previousStepSize, condition);
410  }
411 
412 
413  // -- Physics based biasing case:
414  // ------------------------------
415  // -- Ask for possible GPIL biasing operation:
416  fOccurenceBiasingOperation = (fSharedData->fCurrentBiasingOperator)->GetProposedOccurenceBiasingOperation( &track, this );
417 
418 
419  // -- no operation for occurence biasing, analog GPIL returns the wrapped process GPIL and condition values
420  if ( fOccurenceBiasingOperation == 0 )
421  {
422  *condition = fWrappedProcessForceCondition;
423  return fWrappedProcessPostStepGPIL;
424  }
425 
426  // -- A valid GPIL biasing operation has been proposed:
427  // -- 0) remember wrapped process will need to be reset on biasing exit, if particle survives:
428  fResetWrappedProcessInteractionLength = true;
429  // -- 1) update process interaction length for reference analog interaction law ( fWrappedProcessInteractionLength updated/collected above):
430  fPhysicalInteractionLaw->SetPhysicalCrossSection( 1.0 / fWrappedProcessInteractionLength );
431  // -- 2) Collect biasing interaction law:
432  // -- The interaction law pointer is collected as a const pointer to the interaction law object.
433  // -- This interaction law will be kept under control of the biasing operation, which is the only
434  // -- entity that will change the state of the biasing interaction law.
435  // -- The force condition for biasing is asked at the same time, passing the analog one as default:
436  fBiasingForceCondition = fWrappedProcessForceCondition;
437  fBiasingInteractionLaw = fOccurenceBiasingOperation->ProvideOccurenceBiasingInteractionLaw( this, fBiasingForceCondition );
438  // -- 3) Ask operation to sample the biasing interaction law:
439  fBiasingPostStepGPIL = fBiasingInteractionLaw->GetSampledInteractionLength();
440 
441  // -- finish
442  *condition = fBiasingForceCondition;
443  return fBiasingPostStepGPIL;
444 
445 }
G4double condition(const G4ErrorSymMatrix &m)
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)=0
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4StepStatus GetStepStatus() const
const std::vector< const G4VPhysicalVolume * > & GetCurrentVolumes() const
virtual void ResetNumberOfInteractionLengthLeft()
Definition: G4VProcess.cc:95
const G4Step * GetStep() const
G4StepPoint * GetPreStepPoint() const
G4int GetCurrentStepNumber() const
bool G4bool
Definition: G4Types.hh:79
void SetPhysicalCrossSection(G4double crossSection)
const std::vector< G4bool > & GetWasLimiting() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4VBiasingOperator * GetBiasingOperator(const G4LogicalVolume *)
G4LogicalVolume * GetLogicalVolume() const
G4VPhysicalVolume * GetVolume() const
G4double GetSampledInteractionLength() const
#define G4endl
Definition: G4ios.hh:61
virtual const G4VBiasingInteractionLaw * ProvideOccurenceBiasingInteractionLaw(const G4BiasingProcessInterface *, G4ForceCondition &)=0
double G4double
Definition: G4Types.hh:76
#define DBL_MAX
Definition: templates.hh:83
virtual G4double DistanceToApplyOperation(const G4Track *, G4double, G4ForceCondition *)=0
const G4String GetName() const

Here is the call graph for this function:

void G4BiasingProcessInterface::PreparePhysicsTable ( const G4ParticleDefinition pd)
virtual

Reimplemented from G4VProcess.

Definition at line 776 of file G4BiasingProcessInterface.cc.

777 {
778  // -- Sequential mode : called first (before BuildPhysicsTable(..))
779  // -- MT mode : called first (before BuildPhysicsTable(..)) by master thread.
780  // -- Corresponding process instance not used then by tracking.
781  // -- Let process finding its first/last position in the process manager:
782  SetUpFirstLastFlags();
783  if ( fWrappedProcess != 0 )
784  {
785  fWrappedProcess->PreparePhysicsTable(pd);
786  }
787 }
virtual void PreparePhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:217

Here is the call graph for this function:

void G4BiasingProcessInterface::PrepareWorkerPhysicsTable ( const G4ParticleDefinition pd)
virtual

Reimplemented from G4VProcess.

Definition at line 871 of file G4BiasingProcessInterface.cc.

872 {
873  // -- Sequential mode : not called
874  // -- MT mode : called first, before BuildWorkerPhysicsTable(..)
875  // -- Let process finding its first/last position in the process manager:
876  SetUpFirstLastFlags();
877 
878  if ( fWrappedProcess != 0 )
879  {
880  fWrappedProcess->PrepareWorkerPhysicsTable(pd);
881  }
882 }
virtual void PrepareWorkerPhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.cc:207

Here is the call graph for this function:

void G4BiasingProcessInterface::ResetNumberOfInteractionLengthLeft ( )
virtual

Reimplemented from G4VProcess.

Definition at line 885 of file G4BiasingProcessInterface.cc.

886 {
887  if ( fWrappedProcess != 0 ) fWrappedProcess->ResetNumberOfInteractionLengthLeft();
888 }
virtual void ResetNumberOfInteractionLengthLeft()
Definition: G4VProcess.cc:95

Here is the call graph for this function:

G4bool G4BiasingProcessInterface::RetrievePhysicsTable ( const G4ParticleDefinition pd,
const G4String s,
G4bool  f 
)
virtual

Reimplemented from G4VProcess.

Definition at line 797 of file G4BiasingProcessInterface.cc.

798 {
799  if ( fWrappedProcess != 0 ) return fWrappedProcess->RetrievePhysicsTable(pd, s, f);
800  else return false;
801 }
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
Definition: G4VProcess.hh:236

Here is the call graph for this function:

void G4BiasingProcessInterface::SetMasterProcess ( G4VProcess masterP)
virtual

Reimplemented from G4VProcess.

Definition at line 728 of file G4BiasingProcessInterface.cc.

729 {
730  // -- Master for this process:
732  // -- Master for wrapped process:
733  if ( fWrappedProcess != 0 )
734  {
735  const G4BiasingProcessInterface* thisWrapperMaster = (const G4BiasingProcessInterface *)GetMasterProcess();
736  // -- paranoia check: (?)
737  G4VProcess* wrappedMaster = 0;
738  wrappedMaster = thisWrapperMaster->GetWrappedProcess();
739  fWrappedProcess->SetMasterProcess( wrappedMaster );
740  }
741 }
virtual void SetMasterProcess(G4VProcess *masterP)
Definition: G4VProcess.cc:212
const G4VProcess * GetMasterProcess() const
Definition: G4VProcess.hh:538
G4VProcess * GetWrappedProcess() const

Here is the call graph for this function:

void G4BiasingProcessInterface::SetProcessManager ( const G4ProcessManager mgr)
virtual

Reimplemented from G4VProcess.

Definition at line 804 of file G4BiasingProcessInterface.cc.

805 {
806  if ( fWrappedProcess != 0 ) fWrappedProcess->SetProcessManager(mgr);
808 
809  // -- initialize fSharedData pointer:
810  if ( G4BiasingProcessSharedData::fSharedDataMap.Find(mgr) == G4BiasingProcessSharedData::fSharedDataMap.End() )
811  {
812  fSharedData = new G4BiasingProcessSharedData( mgr );
813  G4BiasingProcessSharedData::fSharedDataMap[mgr] = fSharedData;
814  }
815  else fSharedData = G4BiasingProcessSharedData::fSharedDataMap[mgr] ;
816  // -- augment list of co-operating processes:
817  fSharedData-> fBiasingProcessInterfaces.push_back( this );
818  fSharedData-> fPublicBiasingProcessInterfaces.push_back( this );
819  if ( fIsPhysicsBasedBiasing )
820  {
821  fSharedData-> fPhysicsBiasingProcessInterfaces.push_back( this );
822  fSharedData-> fPublicPhysicsBiasingProcessInterfaces.push_back( this );
823  }
824  else
825  {
826  fSharedData-> fNonPhysicsBiasingProcessInterfaces.push_back( this );
827  fSharedData-> fPublicNonPhysicsBiasingProcessInterfaces.push_back( this );
828  }
829  // -- remember process manager:
830  fProcessManager = mgr;
831 }
virtual void SetProcessManager(const G4ProcessManager *)
Definition: G4VProcess.hh:508

Here is the call graph for this function:

void G4BiasingProcessInterface::SetProposedSafety ( G4double  sft)
inline

Definition at line 151 of file G4BiasingProcessInterface.hh.

151 { fProposedSafety = sft;}
void G4BiasingProcessInterface::StartTracking ( G4Track track)
virtual

Reimplemented from G4VProcess.

Definition at line 150 of file G4BiasingProcessInterface.cc.

151 {
152  fCurrentTrack = track;
153  if ( fIsPhysicsBasedBiasing ) fWrappedProcess->StartTracking(fCurrentTrack);
154  fOccurenceBiasingOperation = 0;
155  fPreviousOccurenceBiasingOperation = 0;
156  fFinalStateBiasingOperation = 0;
157  fPreviousFinalStateBiasingOperation = 0;
158  fNonPhysicsBiasingOperation = 0;
159  fPreviousNonPhysicsBiasingOperation = 0;
160  fBiasingInteractionLaw = 0;
161  fPreviousBiasingInteractionLaw = 0;
162 
163  fPreviousStepSize = -1.0;
164 
165  fResetWrappedProcessInteractionLength = false;
166 
167  if ( fCommonStart.Get() )
168  {
169  fCommonStart.Put( false );// = false;
170  fCommonEnd.Put(true);// = true;
171 
172  fSharedData-> fCurrentBiasingOperator = 0;
173  fSharedData->fPreviousBiasingOperator = 0;
174 
175  // -- §§ Add a "fSharedData->nStarting" here and outside bracket "fSharedData->nStarting++" and " if (fSharedData->nStarting) == fSharedData->(vector interface length)"
176  // -- §§ call to the loop "StartTracking" of operators"
177 
178  for ( size_t optr = 0 ; optr < ( G4VBiasingOperator::GetBiasingOperators() ).size() ; optr ++)
179  ( G4VBiasingOperator::GetBiasingOperators() )[optr]->StartTracking( fCurrentTrack );
180  }
181 }
value_type & Get() const
Definition: G4Cache.hh:282
virtual void StartTracking(G4Track *)
Definition: G4VProcess.cc:101
static const std::vector< G4VBiasingOperator * > & GetBiasingOperators()
void Put(const value_type &val) const
Definition: G4Cache.hh:286

Here is the call graph for this function:

G4bool G4BiasingProcessInterface::StorePhysicsTable ( const G4ParticleDefinition pd,
const G4String s,
G4bool  f 
)
virtual

Reimplemented from G4VProcess.

Definition at line 790 of file G4BiasingProcessInterface.cc.

791 {
792  if ( fWrappedProcess != 0 ) return fWrappedProcess->StorePhysicsTable(pd, s, f);
793  else return false;
794 }
virtual G4bool StorePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
Definition: G4VProcess.hh:231

Here is the call graph for this function:


The documentation for this class was generated from the following files: