Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ImportanceAlgorithm Class Reference

#include <G4ImportanceAlgorithm.hh>

+ Inheritance diagram for G4ImportanceAlgorithm:

Public Member Functions

 G4ImportanceAlgorithm ()
 
virtual ~G4ImportanceAlgorithm ()
 
virtual G4Nsplit_Weight Calculate (G4double ipre, G4double ipost, G4double init_w) const
 
- Public Member Functions inherited from G4VImportanceAlgorithm
 G4VImportanceAlgorithm ()
 
virtual ~G4VImportanceAlgorithm ()
 
virtual G4Nsplit_Weight Calculate (G4double ipre, G4double ipost, G4double init_w) const =0
 

Detailed Description

Definition at line 40 of file G4ImportanceAlgorithm.hh.

Constructor & Destructor Documentation

◆ G4ImportanceAlgorithm()

G4ImportanceAlgorithm::G4ImportanceAlgorithm ( )

Definition at line 42 of file G4ImportanceAlgorithm.cc.

43{
44}

◆ ~G4ImportanceAlgorithm()

G4ImportanceAlgorithm::~G4ImportanceAlgorithm ( )
virtual

Definition at line 46 of file G4ImportanceAlgorithm.cc.

47{
48}

Member Function Documentation

◆ Calculate()

G4Nsplit_Weight G4ImportanceAlgorithm::Calculate ( G4double  ipre,
G4double  ipost,
G4double  init_w 
) const
virtual

Implements G4VImportanceAlgorithm.

Definition at line 51 of file G4ImportanceAlgorithm.cc.

54{
55
56#ifdef G4MULTITHREADED
57 G4MUTEXLOCK(&G4ImportanceAlgorithm::ImportanceMutex);
58#endif
59
61 if (ipost>0.)
62 {
63 if (!(ipre>0.))
64 {
65 Error("Calculate() - ipre==0.");
66 }
67 G4double ipre_over_ipost = ipre/ipost;
68 if ((ipre_over_ipost<0.25 || ipre_over_ipost> 4) && !fWarned)
69 {
70 std::ostringstream os;
71 os << "Calculate() - ipre_over_ipost ! in [0.25, 4]." << G4endl
72 << "ipre_over_ipost = " << ipre_over_ipost << ".";
73 Warning(os.str());
74 fWarned = true;
75 if (ipre_over_ipost<=0)
76 {
77 Error("Calculate() - ipre_over_ipost<=0.");
78 }
79 }
80 if (init_w<=0.)
81 {
82 Error("Calculate() - iniitweight<= 0. found!");
83 }
84
85 // default geometrical splitting
86 // in integer mode
87 // for ipre_over_ipost <= 1
88 G4double inv = 1./ipre_over_ipost;
89 nw.fN = static_cast<G4int>(inv);
90 nw.fW = init_w * ipre_over_ipost;
91
92 // geometrical splitting for double mode
93 if (ipre_over_ipost<1)
94 {
95 if ( static_cast<G4double>(nw.fN) != inv)
96 {
97 // double mode
98 // probability p for splitting into n+1 tracks
99 G4double p = inv - nw.fN;
100 // get a random number out of [0,1)
102 if (r<p)
103 {
104 ++nw.fN;
105 }
106 }
107 }
108 else if (ipre_over_ipost>1) // russian roulette
109 {
110 // probabiity for killing track
111 G4double p = 1-inv;
112 // get a random number out of [0,1)
114 if (r<p)
115 {
116 // kill track
117 nw.fN = 0;
118 nw.fW = 0;
119 }
120 else
121 {
122 nw.fN = 1;
123 }
124 }
125 }
126#ifdef G4MULTITHREADED
127 G4MUTEXUNLOCK(&G4ImportanceAlgorithm::ImportanceMutex);
128#endif
129 return nw;
130}
#define G4MUTEXLOCK(mutex)
Definition: G4Threading.hh:251
#define G4MUTEXUNLOCK(mutex)
Definition: G4Threading.hh:254
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
#define G4UniformRand()
Definition: Randomize.hh:52

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