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;
89 if ( fNumberOfInteractionLength < 0 )
92 ed <<
" Negative number of interaction length for `" <<
GetName() <<
"' " << fNumberOfInteractionLength <<
", set it to zero !" <<
G4endl;
93 G4Exception(
"G4InteractionLawPhysical::UpdateInteractionLengthForStep(...)",
97 fNumberOfInteractionLength = 0.;
99 return fNumberOfInteractionLength;
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