Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4ILawTruncatedExp Class Reference

#include <G4ILawTruncatedExp.hh>

Inheritance diagram for G4ILawTruncatedExp:
G4VBiasingInteractionLaw

Public Member Functions

 G4ILawTruncatedExp (G4String name="expForceInteractionLaw")
 
virtual ~G4ILawTruncatedExp ()
 
virtual G4double ComputeEffectiveCrossSectionAt (G4double length) const
 
virtual G4double ComputeNonInteractionProbabilityAt (G4double length) const
 
virtual G4double SampleInteractionLength ()
 
virtual G4double UpdateInteractionLengthForStep (G4double truePathLength)
 
virtual G4bool IsSingular () const
 
void SetForceCrossSection (G4double xs)
 
void SetMaximumDistance (G4double d)
 
G4double GetMaximumDistance () const
 
G4double GetInteractionDistance () const
 
- Public Member Functions inherited from G4VBiasingInteractionLaw
 G4VBiasingInteractionLaw (G4String name)
 
virtual ~G4VBiasingInteractionLaw ()
 
const G4StringGetName () const
 
virtual G4bool IsEffectiveCrossSectionInfinite () const
 
G4double Sample ()
 
G4double UpdateForStep (G4double truePathLength)
 
G4double GetSampledInteractionLength () const
 

Additional Inherited Members

Detailed Description

Definition at line 46 of file G4ILawTruncatedExp.hh.

Constructor & Destructor Documentation

G4ILawTruncatedExp::G4ILawTruncatedExp ( G4String  name = "expForceInteractionLaw")

Definition at line 32 of file G4ILawTruncatedExp.cc.

34  fMaximumDistance(0.0),
35  fCrossSection(0.0),
36  fCrossSectionDefined(false),
37  fIsSingular(false)
38 {}
G4ILawTruncatedExp::~G4ILawTruncatedExp ( )
virtual

Definition at line 40 of file G4ILawTruncatedExp.cc.

41 {}

Member Function Documentation

G4double G4ILawTruncatedExp::ComputeEffectiveCrossSectionAt ( G4double  length) const
virtual

Implements G4VBiasingInteractionLaw.

Definition at line 59 of file G4ILawTruncatedExp.cc.

References G4Exception(), and JustWarning.

Referenced by G4ILawCommonTruncatedExp::ComputeEffectiveCrossSectionAt().

60 {
61  if ( !fCrossSectionDefined )
62  {
63  G4Exception("G4ILawTruncatedExp::ComputeEffectiveCrossSection(..)",
64  "BIAS.GEN.10",
66  "Cross-section value requested, but has not been defined yet. Assumes 0 !");
67  // -- zero cross-section, returns the limit form of the effective cross-section:
68  return 1.0 / ( fMaximumDistance - distance );
69  }
70  G4double denum = 1.0 - std::exp( -fCrossSection * ( fMaximumDistance - distance) );
71  return fCrossSection / denum;
72 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
G4double G4ILawTruncatedExp::ComputeNonInteractionProbabilityAt ( G4double  length) const
virtual

Implements G4VBiasingInteractionLaw.

Definition at line 74 of file G4ILawTruncatedExp.cc.

References G4Exception(), and JustWarning.

Referenced by G4ILawCommonTruncatedExp::ComputeNonInteractionProbabilityAt().

75 {
76  if (!fCrossSectionDefined)
77  {
78  G4Exception("G4ILawTruncatedExp::ComputeNonInteractionProbability(..)",
79  "BIAS.GEN.11",
81  "Non interaction probability value requested, but cross section has not been defined yet. Assumes it to be 0 !");
82  // -- return limit case of null cross-section:
83  return 1.0 - distance / fMaximumDistance;
84  }
85  G4double num = 1.0 - std::exp( -fCrossSection*distance);
86  G4double denum = 1.0 - std::exp( -fCrossSection*fMaximumDistance);
87  return 1.0 - num/denum;
88 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
G4double G4ILawTruncatedExp::GetInteractionDistance ( ) const
inline

Definition at line 67 of file G4ILawTruncatedExp.hh.

Referenced by G4ILawCommonTruncatedExp::GetInteractionDistance().

67 { return fInteractionDistance; }
G4double G4ILawTruncatedExp::GetMaximumDistance ( ) const
inline

Definition at line 66 of file G4ILawTruncatedExp.hh.

Referenced by G4ILawCommonTruncatedExp::GetMaximumDistance().

66 { return fMaximumDistance;}
virtual G4bool G4ILawTruncatedExp::IsSingular ( ) const
inlinevirtual

Reimplemented from G4VBiasingInteractionLaw.

Definition at line 59 of file G4ILawTruncatedExp.hh.

Referenced by G4ILawCommonTruncatedExp::IsSingular().

59 {return fIsSingular;}
G4double G4ILawTruncatedExp::SampleInteractionLength ( )
virtual

Implements G4VBiasingInteractionLaw.

Definition at line 90 of file G4ILawTruncatedExp.cc.

References G4Exception(), G4UniformRand, and JustWarning.

91 {
92  if ( !fCrossSectionDefined )
93  {
94  G4Exception("G4ILawTruncatedExp::Sample(..)",
95  "BIAS.GEN.12",
97  "Trying to sample while cross-section is not defined, assuming 0 !");
98  fInteractionDistance = G4UniformRand() * fMaximumDistance;
99  return fInteractionDistance;
100  }
101  fInteractionDistance = -std::log(1.0 - G4UniformRand()* (1.0 - std::exp(-fCrossSection*fMaximumDistance)))/fCrossSection;
102  return fInteractionDistance;
103 }
#define G4UniformRand()
Definition: Randomize.hh:87
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void G4ILawTruncatedExp::SetForceCrossSection ( G4double  xs)

Definition at line 43 of file G4ILawTruncatedExp.cc.

References G4Exception(), and JustWarning.

Referenced by G4ILawCommonTruncatedExp::SetForceCrossSection().

44 {
45  if (crossSection < 0.0)
46  {
47  G4Exception("G4ILawTruncatedExp::SetForceCrossSection(..)",
48  "BIAS.GEN.09",
50  "Cross-section value passed is negative. It is set to zero !");
51  fIsSingular = true;
52  crossSection = 0.0;
53  }
54  fIsSingular = false;
55  fCrossSectionDefined = true;
56  fCrossSection = crossSection;
57 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void G4ILawTruncatedExp::SetMaximumDistance ( G4double  d)
inline

Definition at line 65 of file G4ILawTruncatedExp.hh.

Referenced by G4ILawCommonTruncatedExp::SetMaximumDistance().

65 { fMaximumDistance = d;}
G4double G4ILawTruncatedExp::UpdateInteractionLengthForStep ( G4double  truePathLength)
virtual

Reimplemented from G4VBiasingInteractionLaw.

Definition at line 106 of file G4ILawTruncatedExp.cc.

References G4endl, G4Exception(), G4VBiasingInteractionLaw::GetName(), and JustWarning.

107 {
108  fInteractionDistance -= truePathLength;
109  fMaximumDistance -= truePathLength;
110 
111  if ( fInteractionDistance < 0 )
112  {
114  ed << " Negative number of interaction length for `" << GetName() << "' " << fInteractionDistance << ", set it to zero !" << G4endl;
115  G4Exception("G4ILawTruncatedExp::UpdateInteractionLengthForStep(...)",
116  "BIAS.GEN.13",
117  JustWarning,
118  "Trying to sample while cross-section is not defined, assuming 0 !");
119  fInteractionDistance = 0.;
120  }
121 
122  return fInteractionDistance;
123 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
const G4String & GetName() const

The documentation for this class was generated from the following files: