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

#include <G4ILawTruncatedExp.hh>

+ Inheritance diagram for G4ILawTruncatedExp:

Public Member Functions

 G4ILawTruncatedExp (G4String name="expForceInteractionLaw")
 
virtual ~G4ILawTruncatedExp ()
 
virtual G4double ComputeEffectiveCrossSectionAt (G4double length) const
 
virtual G4double ComputeNonInteractionProbabilityAt (G4double length) const
 
virtual G4double SampleInteractionLength ()
 
virtual G4double UpdateInteractionLengthForStep (G4double truePathLength)
 
virtual G4bool IsSingular () const
 
void SetForceCrossSection (G4double xs)
 
void SetMaximumDistance (G4double d)
 
G4double GetMaximumDistance () const
 
G4double GetInteractionDistance () const
 
- Public Member Functions inherited from G4VBiasingInteractionLaw
 G4VBiasingInteractionLaw (G4String name)
 
virtual ~G4VBiasingInteractionLaw ()
 
const G4StringGetName () 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 45 of file G4ILawTruncatedExp.hh.

Constructor & Destructor Documentation

◆ G4ILawTruncatedExp()

G4ILawTruncatedExp::G4ILawTruncatedExp ( G4String name = "expForceInteractionLaw")

Definition at line 31 of file G4ILawTruncatedExp.cc.

33 fMaximumDistance(0.0),
34 fCrossSection(0.0),
35 fCrossSectionDefined(false),
36 fIsSingular(false)
37{}

◆ ~G4ILawTruncatedExp()

G4ILawTruncatedExp::~G4ILawTruncatedExp ( )
virtual

Definition at line 39 of file G4ILawTruncatedExp.cc.

40{}

Member Function Documentation

◆ ComputeEffectiveCrossSectionAt()

G4double G4ILawTruncatedExp::ComputeEffectiveCrossSectionAt ( G4double length) const
virtual

Implements G4VBiasingInteractionLaw.

Definition at line 58 of file G4ILawTruncatedExp.cc.

59{
60 if ( !fCrossSectionDefined )
61 {
62 G4Exception("G4ILawTruncatedExp::ComputeEffectiveCrossSection(..)",
63 "BIAS.GEN.10",
65 "Cross-section value requested, but has not been defined yet. Assumes 0 !");
66 // -- zero cross-section, returns the limit form of the effective cross-section:
67 return 1.0 / ( fMaximumDistance - distance );
68 }
69 G4double denum = 1.0 - std::exp( -fCrossSection * ( fMaximumDistance - distance) );
70 return fCrossSection / denum;
71}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
double G4double
Definition G4Types.hh:83

Referenced by G4ILawCommonTruncatedExp::ComputeEffectiveCrossSectionAt().

◆ ComputeNonInteractionProbabilityAt()

G4double G4ILawTruncatedExp::ComputeNonInteractionProbabilityAt ( G4double length) const
virtual

Implements G4VBiasingInteractionLaw.

Definition at line 73 of file G4ILawTruncatedExp.cc.

74{
75 if (!fCrossSectionDefined)
76 {
77 G4Exception("G4ILawTruncatedExp::ComputeNonInteractionProbability(..)",
78 "BIAS.GEN.11",
80 "Non interaction probability value requested, but cross section has not been defined yet. Assumes it to be 0 !");
81 // -- return limit case of null cross-section:
82 return 1.0 - distance / fMaximumDistance;
83 }
84 G4double num = 1.0 - std::exp( -fCrossSection*distance );
85 G4double denum = 1.0 - std::exp( -fCrossSection*fMaximumDistance );
86 return 1.0 - num/denum;
87}

Referenced by G4ILawCommonTruncatedExp::ComputeNonInteractionProbabilityAt().

◆ GetInteractionDistance()

G4double G4ILawTruncatedExp::GetInteractionDistance ( ) const
inline

Definition at line 66 of file G4ILawTruncatedExp.hh.

66{ return fInteractionDistance; }

Referenced by G4ILawCommonTruncatedExp::GetInteractionDistance().

◆ GetMaximumDistance()

G4double G4ILawTruncatedExp::GetMaximumDistance ( ) const
inline

Definition at line 65 of file G4ILawTruncatedExp.hh.

65{ return fMaximumDistance;}

Referenced by G4ILawCommonTruncatedExp::GetMaximumDistance().

◆ IsSingular()

virtual G4bool G4ILawTruncatedExp::IsSingular ( ) const
inlinevirtual

Reimplemented from G4VBiasingInteractionLaw.

Definition at line 58 of file G4ILawTruncatedExp.hh.

58{return fIsSingular;}

Referenced by G4ILawCommonTruncatedExp::IsSingular().

◆ SampleInteractionLength()

G4double G4ILawTruncatedExp::SampleInteractionLength ( )
virtual

Implements G4VBiasingInteractionLaw.

Definition at line 89 of file G4ILawTruncatedExp.cc.

90{
91 if ( !fCrossSectionDefined )
92 {
93 G4Exception("G4ILawTruncatedExp::Sample(..)",
94 "BIAS.GEN.12",
96 "Trying to sample while cross-section is not defined, assuming 0 !");
97 fInteractionDistance = G4UniformRand() * fMaximumDistance;
98 return fInteractionDistance;
99 }
100 fInteractionDistance = -std::log(1.0 - G4UniformRand()* (1.0 - std::exp(-fCrossSection*fMaximumDistance)))/fCrossSection;
101 return fInteractionDistance;
102}
#define G4UniformRand()
Definition Randomize.hh:52

◆ SetForceCrossSection()

void G4ILawTruncatedExp::SetForceCrossSection ( G4double xs)

Definition at line 42 of file G4ILawTruncatedExp.cc.

43{
44 if (crossSection < 0.0)
45 {
46 G4Exception("G4ILawTruncatedExp::SetForceCrossSection(..)",
47 "BIAS.GEN.09",
49 "Cross-section value passed is negative. It is set to zero !");
50 fIsSingular = true;
51 crossSection = 0.0;
52 }
53 fIsSingular = false;
54 fCrossSectionDefined = true;
55 fCrossSection = crossSection;
56}

Referenced by G4ILawCommonTruncatedExp::SetForceCrossSection().

◆ SetMaximumDistance()

void G4ILawTruncatedExp::SetMaximumDistance ( G4double d)
inline

Definition at line 64 of file G4ILawTruncatedExp.hh.

64{ fMaximumDistance = d;}

Referenced by G4ILawCommonTruncatedExp::SetMaximumDistance().

◆ UpdateInteractionLengthForStep()

G4double G4ILawTruncatedExp::UpdateInteractionLengthForStep ( G4double truePathLength)
virtual

Reimplemented from G4VBiasingInteractionLaw.

Definition at line 105 of file G4ILawTruncatedExp.cc.

106{
107 fInteractionDistance -= truePathLength;
108 fMaximumDistance -= truePathLength;
109
110 if ( fInteractionDistance < 0 )
111 {
113 ed << " Negative number of interaction length for `" << GetName() << "' " << fInteractionDistance << ", set it to zero !" << G4endl;
114 G4Exception("G4ILawTruncatedExp::UpdateInteractionLengthForStep(...)",
115 "BIAS.GEN.13",
117 "Trying to sample while cross-section is not defined, assuming 0 !");
118 fInteractionDistance = 0.;
119 }
120
121 return fInteractionDistance;
122}
std::ostringstream G4ExceptionDescription
#define G4endl
Definition G4ios.hh:67
const G4String & GetName() const

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