Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4InteractionLawPhysical Class Reference

#include <G4InteractionLawPhysical.hh>

+ Inheritance diagram for G4InteractionLawPhysical:

Public Member Functions

 G4InteractionLawPhysical (G4String name="exponentialLaw")
 
virtual ~G4InteractionLawPhysical ()
 
void SetPhysicalCrossSection (G4double crossSection)
 
G4double GetPhysicalCrossSection () const
 
virtual G4double ComputeEffectiveCrossSectionAt (G4double length) const
 
virtual G4double ComputeNonInteractionProbabilityAt (G4double length) const
 
virtual G4double SampleInteractionLength ()
 
virtual G4double UpdateInteractionLengthForStep (G4double truePathLength)
 
- Public Member Functions inherited from G4VBiasingInteractionLaw
 G4VBiasingInteractionLaw (G4String name)
 
virtual ~G4VBiasingInteractionLaw ()
 
const G4StringGetName () const
 
virtual G4bool IsSingular () const
 
virtual G4bool IsEffectiveCrossSectionInfinite () const
 
G4double Sample ()
 
G4double UpdateForStep (G4double truePathLength)
 
G4double GetSampledInteractionLength () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4VBiasingInteractionLaw

Detailed Description

Definition at line 44 of file G4InteractionLawPhysical.hh.

Constructor & Destructor Documentation

◆ G4InteractionLawPhysical()

G4InteractionLawPhysical::G4InteractionLawPhysical ( G4String name = "exponentialLaw")

Definition at line 29 of file G4InteractionLawPhysical.cc.

31 fCrossSection(0.0),
32 fCrossSectionDefined(false),
33 fNumberOfInteractionLength(-1.0)
34{}

◆ ~G4InteractionLawPhysical()

G4InteractionLawPhysical::~G4InteractionLawPhysical ( )
virtual

Definition at line 36 of file G4InteractionLawPhysical.cc.

37{}

Member Function Documentation

◆ ComputeEffectiveCrossSectionAt()

G4double G4InteractionLawPhysical::ComputeEffectiveCrossSectionAt ( G4double length) const
virtual

Implements G4VBiasingInteractionLaw.

Definition at line 53 of file G4InteractionLawPhysical.cc.

54{
55 if (!fCrossSectionDefined) G4Exception("G4InteractionLawPhysical::ComputeEffectiveCrossSection(..)",
56 "BIAS.GEN.15",
58 "Cross-section value requested, but has not been defined yet. Assumes 0 !");
59 return fCrossSection;
60}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)

Referenced by G4BiasingProcessInterface::PostStepDoIt().

◆ ComputeNonInteractionProbabilityAt()

G4double G4InteractionLawPhysical::ComputeNonInteractionProbabilityAt ( G4double length) const
virtual

Implements G4VBiasingInteractionLaw.

Definition at line 62 of file G4InteractionLawPhysical.cc.

63{
64 if (!fCrossSectionDefined) G4Exception("G4InteractionLawPhysical::ComputeNonInteractionProbability(..)",
65 "BIAS.GEN.16",
67 "Non interaction probabitlity value requested, but cross section has not been defined yet. Assumes it to be 0 !");
68 // -- allows zero cross-section case, by convention:
69 if ( fCrossSection == 0.0 ) return 1.0;
70 else return std::exp(-fCrossSection*stepLength);
71}

Referenced by G4BiasingProcessInterface::AlongStepDoIt().

◆ GetPhysicalCrossSection()

G4double G4InteractionLawPhysical::GetPhysicalCrossSection ( ) const
inline

Definition at line 52 of file G4InteractionLawPhysical.hh.

52{return fCrossSection;}

Referenced by G4BOptnChangeCrossSection::GetBiasedCrossSection().

◆ SampleInteractionLength()

G4double G4InteractionLawPhysical::SampleInteractionLength ( )
virtual

Implements G4VBiasingInteractionLaw.

Definition at line 73 of file G4InteractionLawPhysical.cc.

74{
75 if ( !fCrossSectionDefined || fCrossSection < 0.0 ) G4Exception("G4InteractionLawPhysical::Sample(..)",
76 "BIAS.GEN.17",
78 "Trying to sample while cross-section is not defined or < 0 !");
79 if ( fCrossSection == 0.0 ) return DBL_MAX;
80
81 fNumberOfInteractionLength = -std::log( G4UniformRand() );
82 return fNumberOfInteractionLength/fCrossSection;
83}
@ FatalException
#define G4UniformRand()
Definition Randomize.hh:52
#define DBL_MAX
Definition templates.hh:62

◆ SetPhysicalCrossSection()

void G4InteractionLawPhysical::SetPhysicalCrossSection ( G4double crossSection)

Definition at line 39 of file G4InteractionLawPhysical.cc.

40{
41 if (crossSection < 0.0)
42 {
43 G4Exception("G4InteractionLawPhysical::SetPhysicalCrossSection(..)",
44 "BIAS.GEN.14",
46 "Cross-section value passed is negative. It is set to zero !");
47 crossSection = 0.0;
48 }
49 fCrossSectionDefined = true;
50 fCrossSection = crossSection;
51}

Referenced by G4BiasingProcessInterface::PostStepGetPhysicalInteractionLength(), and G4BOptnChangeCrossSection::SetBiasedCrossSection().

◆ UpdateInteractionLengthForStep()

G4double G4InteractionLawPhysical::UpdateInteractionLengthForStep ( G4double truePathLength)
virtual

Reimplemented from G4VBiasingInteractionLaw.

Definition at line 86 of file G4InteractionLawPhysical.cc.

87{
88 fNumberOfInteractionLength -= truePathLength*fCrossSection;
89
90 if ( fNumberOfInteractionLength < 0 )
91 {
93 ed << " Negative number of interaction length for `" << GetName() << "' " << fNumberOfInteractionLength << ", set it to zero !" << G4endl;
94 G4Exception("G4InteractionLawPhysical::UpdateInteractionLengthForStep(...)",
95 "BIAS.GEN.13",
97 ed);
98 fNumberOfInteractionLength = 0.;
99 }
100 return fNumberOfInteractionLength/fCrossSection;
101}
std::ostringstream G4ExceptionDescription
#define G4endl
Definition G4ios.hh:67
const G4String & GetName() const

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