Geant4-11
G4ILawTruncatedExp.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26#include "G4ILawTruncatedExp.hh"
27#include "Randomize.hh"
28#include "G4Track.hh"
29
30
33 fMaximumDistance(0.0),
34 fCrossSection(0.0),
35 fCrossSectionDefined(false),
36 fIsSingular(false)
37{}
38
40{}
41
43{
44 if (crossSection < 0.0)
45 {
46 G4Exception("G4ILawTruncatedExp::SetForceCrossSection(..)",
47 "BIAS.GEN.09",
49 "Cross-section value passed is negative. It is set to zero !");
50 fIsSingular = true;
51 crossSection = 0.0;
52 }
53 fIsSingular = false;
55 fCrossSection = crossSection;
56}
57
59{
61 {
62 G4Exception("G4ILawTruncatedExp::ComputeEffectiveCrossSection(..)",
63 "BIAS.GEN.10",
65 "Cross-section value requested, but has not been defined yet. Assumes 0 !");
66 // -- zero cross-section, returns the limit form of the effective cross-section:
67 return 1.0 / ( fMaximumDistance - distance );
68 }
69 G4double denum = 1.0 - std::exp( -fCrossSection * ( fMaximumDistance - distance) );
70 return fCrossSection / denum;
71}
72
74{
76 {
77 G4Exception("G4ILawTruncatedExp::ComputeNonInteractionProbability(..)",
78 "BIAS.GEN.11",
80 "Non interaction probability value requested, but cross section has not been defined yet. Assumes it to be 0 !");
81 // -- return limit case of null cross-section:
82 return 1.0 - distance / fMaximumDistance;
83 }
84 G4double num = 1.0 - std::exp( -fCrossSection*distance );
85 G4double denum = 1.0 - std::exp( -fCrossSection*fMaximumDistance );
86 return 1.0 - num/denum;
87}
88
90{
92 {
93 G4Exception("G4ILawTruncatedExp::Sample(..)",
94 "BIAS.GEN.12",
96 "Trying to sample while cross-section is not defined, assuming 0 !");
99 }
100 fInteractionDistance = -std::log(1.0 - G4UniformRand()* (1.0 - std::exp(-fCrossSection*fMaximumDistance)))/fCrossSection;
102}
103
104
106{
107 fInteractionDistance -= truePathLength;
108 fMaximumDistance -= truePathLength;
109
110 if ( fInteractionDistance < 0 )
111 {
113 ed << " Negative number of interaction length for `" << GetName() << "' " << fInteractionDistance << ", set it to zero !" << G4endl;
114 G4Exception("G4ILawTruncatedExp::UpdateInteractionLengthForStep(...)",
115 "BIAS.GEN.13",
117 "Trying to sample while cross-section is not defined, assuming 0 !");
119 }
120
122}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
double G4double
Definition: G4Types.hh:83
#define G4endl
Definition: G4ios.hh:57
#define G4UniformRand()
Definition: Randomize.hh:52
G4ILawTruncatedExp(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
const G4String & GetName() const
const char * name(G4int ptype)