34 fMaximumDistance(0.0),
36 fCrossSectionDefined(false),
45 if (crossSection < 0.0)
47 G4Exception(
"G4ILawTruncatedExp::SetForceCrossSection(..)",
50 "Cross-section value passed is negative. It is set to zero !");
55 fCrossSectionDefined =
true;
56 fCrossSection = crossSection;
61 if ( !fCrossSectionDefined )
63 G4Exception(
"G4ILawTruncatedExp::ComputeEffectiveCrossSection(..)",
66 "Cross-section value requested, but has not been defined yet. Assumes 0 !");
68 return 1.0 / ( fMaximumDistance - distance );
70 G4double denum = 1.0 - std::exp( -fCrossSection * ( fMaximumDistance - distance) );
71 return fCrossSection / denum;
76 if (!fCrossSectionDefined)
78 G4Exception(
"G4ILawTruncatedExp::ComputeNonInteractionProbability(..)",
81 "Non interaction probability value requested, but cross section has not been defined yet. Assumes it to be 0 !");
83 return 1.0 - distance / fMaximumDistance;
85 G4double num = 1.0 - std::exp( -fCrossSection*distance);
86 G4double denum = 1.0 - std::exp( -fCrossSection*fMaximumDistance);
87 return 1.0 - num/denum;
92 if ( !fCrossSectionDefined )
97 "Trying to sample while cross-section is not defined, assuming 0 !");
99 return fInteractionDistance;
101 fInteractionDistance = -std::log(1.0 -
G4UniformRand()* (1.0 - std::exp(-fCrossSection*fMaximumDistance)))/fCrossSection;
102 return fInteractionDistance;
108 fInteractionDistance -= truePathLength;
109 fMaximumDistance -= truePathLength;
111 if ( fInteractionDistance < 0 )
114 ed <<
" Negative number of interaction length for `" <<
GetName() <<
"' " << fInteractionDistance <<
", set it to zero !" <<
G4endl;
115 G4Exception(
"G4ILawTruncatedExp::UpdateInteractionLengthForStep(...)",
118 "Trying to sample while cross-section is not defined, assuming 0 !");
119 fInteractionDistance = 0.;
122 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)