43 if (crossSection < 0.0)
45 G4Exception(
"G4ILawTruncatedExp::SetForceCrossSection(..)",
47 "Cross-section value passed is negative. It is set to zero !");
52 fCrossSectionDefined =
true;
53 fCrossSection = crossSection;
59 if ( !fCrossSectionDefined )
61 G4Exception(
"G4ILawTruncatedExp::ComputeEffectiveCrossSection(..)",
63 "Cross-section value requested, but has not been defined yet. Assumes 0 !");
65 return 1.0 / ( fMaximumDistance - distance );
68 G4double denum = 1.0 - std::exp(-fCrossSection *(fMaximumDistance-distance));
69 return fCrossSection/denum;
75 if (!fCrossSectionDefined)
77 G4Exception(
"G4ILawTruncatedExp::ComputeNonInteractionProbability(..)",
79 "Non interaction probability value requested, but cross section has not been defined yet. Assumes it to be 0 !");
81 return 1.0 - distance / fMaximumDistance;
83 G4double num = 1.0 - std::exp( -fCrossSection*distance );
84 G4double denum = 1.0 - std::exp( -fCrossSection*fMaximumDistance );
85 return 1.0 - num/denum;
90 if ( !fCrossSectionDefined )
94 "Trying to sample while cross-section is not defined, assuming 0 !");
96 return fInteractionDistance;
98 fInteractionDistance = -std::log(1.0-
G4UniformRand()*(1.0-std::exp(-fCrossSection*fMaximumDistance)))/fCrossSection;
99 return fInteractionDistance;
105 fInteractionDistance -= truePathLength;
106 fMaximumDistance -= truePathLength;
108 if ( fInteractionDistance < 0 )
111 ed <<
" Negative number of interaction length for `" <<
GetName()
112 <<
"' " << fInteractionDistance <<
", set it to zero !" <<
G4endl;
113 G4Exception(
"G4ILawTruncatedExp::UpdateInteractionLengthForStep(...)",
115 "Trying to sample while cross-section is not defined, assuming 0 !");
116 fInteractionDistance = 0.;
119 return fInteractionDistance;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4ILawTruncatedExp(const G4String &name="expForceInteractionLaw")
virtual G4double SampleInteractionLength()
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength)
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const
void SetForceCrossSection(G4double xs)
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const
virtual ~G4ILawTruncatedExp()
const G4String & GetName() const
G4VBiasingInteractionLaw(const G4String &name)