Geant4  10.02.p03
G4ImportanceAlgorithm Class Reference

#include <G4ImportanceAlgorithm.hh>

Inheritance diagram for G4ImportanceAlgorithm:
Collaboration 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 ()
 

Private Member Functions

void Error (const G4String &m) const
 
void Warning (const G4String &m) const
 

Private Attributes

G4bool fWorned
 

Detailed Description

Definition at line 44 of file G4ImportanceAlgorithm.hh.

Constructor & Destructor Documentation

◆ G4ImportanceAlgorithm()

G4ImportanceAlgorithm::G4ImportanceAlgorithm ( )

Definition at line 42 of file G4ImportanceAlgorithm.cc.

42  : fWorned(false)
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  G4Nsplit_Weight nw = {0,0};
56  if (ipost>0.){
57  if (!(ipre>0.)){
58  Error("Calculate() - ipre==0.");
59  }
60  G4double ipre_over_ipost = ipre/ipost;
61  if ((ipre_over_ipost<0.25 || ipre_over_ipost> 4) && !fWorned) {
62  std::ostringstream os;
63  os << "Calculate() - ipre_over_ipost ! in [0.25, 4]." << G4endl
64  << "ipre_over_ipost = " << ipre_over_ipost << ".";
65  Warning(os.str());
66  fWorned = true;
67  if (ipre_over_ipost<=0) {
68  Error("Calculate() - ipre_over_ipost<=0.");
69  }
70  }
71  if (init_w<=0.) {
72  Error("Calculate() - iniitweight<= 0. found!");
73  }
74 
75  // default geometrical splitting
76  // in integer mode
77  // for ipre_over_ipost <= 1
78  G4double inv = 1./ipre_over_ipost;
79  nw.fN = static_cast<G4int>(inv);
80  nw.fW = init_w * ipre_over_ipost;
81 
82  // geometrical splitting for double mode
83  if (ipre_over_ipost<1) {
84  if ( static_cast<G4double>(nw.fN) != inv) {
85  // double mode
86  // probability p for splitting into n+1 tracks
87  G4double p = inv - nw.fN;
88  // get a random number out of [0,1)
90  if (r<p) {
91  nw.fN++;
92  }
93  }
94  }
95  // ipre_over_ipost > 1
96  // russian roulett
97  else if (ipre_over_ipost>1) {
98  // probabiity for killing track
99  G4double p = 1-inv;
100  // get a random number out of [0,1)
102  if (r<p) {
103  // kill track
104  nw.fN = 0;
105  nw.fW = 0;
106  }
107  else {
108  nw.fN = 1;
109  }
110  }
111  }
112  return nw;
113 }
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
void Error(const G4String &m) const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void Warning(const G4String &m) const
Here is the call graph for this function:

◆ Error()

void G4ImportanceAlgorithm::Error ( const G4String m) const
private

Definition at line 115 of file G4ImportanceAlgorithm.cc.

116 {
117  G4Exception("G4ImportanceAlgorithm::Error()",
118  "GeomBias0002", FatalException, msg);
119 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Warning()

void G4ImportanceAlgorithm::Warning ( const G4String m) const
private

Definition at line 121 of file G4ImportanceAlgorithm.cc.

122 {
123  G4Exception("G4ImportanceAlgorithm::Warning()",
124  "GeomBias1001", JustWarning, msg);
125 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fWorned

G4bool G4ImportanceAlgorithm::fWorned
mutableprivate

Definition at line 68 of file G4ImportanceAlgorithm.hh.


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