32 fCrossSectionDefined(false),
33 fNumberOfInteractionLength(-1.0)
41 if (crossSection < 0.0)
43 G4Exception(
"G4InteractionLawPhysical::SetPhysicalCrossSection(..)",
46 "Cross-section value passed is negative. It is set to zero !");
49 fCrossSectionDefined =
true;
50 fCrossSection = crossSection;
55 if (!fCrossSectionDefined)
G4Exception(
"G4InteractionLawPhysical::ComputeEffectiveCrossSection(..)",
58 "Cross-section value requested, but has not been defined yet. Assumes 0 !");
64 if (!fCrossSectionDefined)
G4Exception(
"G4InteractionLawPhysical::ComputeNonInteractionProbability(..)",
67 "Non interaction probabitlity value requested, but cross section has not been defined yet. Assumes it to be 0 !");
69 if ( fCrossSection == 0.0 )
return 1.0;
70 else return std::exp(-fCrossSection*stepLength);
75 if ( !fCrossSectionDefined || fCrossSection < 0.0 )
G4Exception(
"G4InteractionLawPhysical::Sample(..)",
78 "Trying to sample while cross-section is not defined or < 0 !");
79 if ( fCrossSection == 0.0 )
return DBL_MAX;
82 return fNumberOfInteractionLength/fCrossSection;
88 fNumberOfInteractionLength -= truePathLength*fCrossSection;
90 if ( fNumberOfInteractionLength < 0 )
93 ed <<
" Negative number of interaction length for `" <<
GetName() <<
"' " << fNumberOfInteractionLength <<
", set it to zero !" <<
G4endl;
94 G4Exception(
"G4InteractionLawPhysical::UpdateInteractionLengthForStep(...)",
98 fNumberOfInteractionLength = 0.;
100 return fNumberOfInteractionLength/fCrossSection;
virtual G4double ComputeNonInteractionProbabilityAt(G4double length) const
std::ostringstream G4ExceptionDescription
virtual G4double UpdateInteractionLengthForStep(G4double truePathLength)
G4InteractionLawPhysical(G4String name="exponentialLaw")
virtual G4double SampleInteractionLength()
virtual G4double ComputeEffectiveCrossSectionAt(G4double length) const
void SetPhysicalCrossSection(G4double crossSection)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual ~G4InteractionLawPhysical()
const G4String & GetName() const