33 fMaximumDistance(0.0),
35 fCrossSectionDefined(false),
44 if (crossSection < 0.0)
46 G4Exception(
"G4ILawTruncatedExp::SetForceCrossSection(..)",
49 "Cross-section value passed is negative. It is set to zero !");
54 fCrossSectionDefined =
true;
55 fCrossSection = crossSection;
60 if ( !fCrossSectionDefined )
62 G4Exception(
"G4ILawTruncatedExp::ComputeEffectiveCrossSection(..)",
65 "Cross-section value requested, but has not been defined yet. Assumes 0 !");
67 return 1.0 / ( fMaximumDistance - distance );
69 G4double denum = 1.0 - std::exp( -fCrossSection * ( fMaximumDistance - distance) );
70 return fCrossSection / denum;
75 if (!fCrossSectionDefined)
77 G4Exception(
"G4ILawTruncatedExp::ComputeNonInteractionProbability(..)",
80 "Non interaction probability value requested, but cross section has not been defined yet. Assumes it to be 0 !");
82 return 1.0 - distance / fMaximumDistance;
84 G4double num = 1.0 - std::exp( -fCrossSection*distance );
85 G4double denum = 1.0 - std::exp( -fCrossSection*fMaximumDistance );
86 return 1.0 - num/denum;
91 if ( !fCrossSectionDefined )
96 "Trying to sample while cross-section is not defined, assuming 0 !");
98 return fInteractionDistance;
100 fInteractionDistance = -std::log(1.0 -
G4UniformRand()* (1.0 - std::exp(-fCrossSection*fMaximumDistance)))/fCrossSection;
101 return fInteractionDistance;
107 fInteractionDistance -= truePathLength;
108 fMaximumDistance -= truePathLength;
110 if ( fInteractionDistance < 0 )
113 ed <<
" Negative number of interaction length for `" <<
GetName() <<
"' " << fInteractionDistance <<
", set it to zero !" <<
G4endl;
114 G4Exception(
"G4ILawTruncatedExp::UpdateInteractionLengthForStep(...)",
117 "Trying to sample while cross-section is not defined, assuming 0 !");
118 fInteractionDistance = 0.;
121 return fInteractionDistance;
virtual ~G4ILawTruncatedExp()
std::ostringstream G4ExceptionDescription
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const
virtual G4double SampleInteractionLength()
G4ILawTruncatedExp(G4String name="expForceInteractionLaw")
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength)
const G4String & GetName() const
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const
void SetForceCrossSection(G4double xs)