Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 ()
 

Detailed Description

Definition at line 44 of file G4ImportanceAlgorithm.hh.

Constructor & Destructor Documentation

G4ImportanceAlgorithm::G4ImportanceAlgorithm ( )

Definition at line 42 of file G4ImportanceAlgorithm.cc.

42  : fWorned(false)
43 {
44 }
G4ImportanceAlgorithm::~G4ImportanceAlgorithm ( )
virtual

Definition at line 46 of file G4ImportanceAlgorithm.cc.

47 {
48 }

Member Function Documentation

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)
89  G4double r = G4UniformRand();
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)
101  G4double r = G4UniformRand();
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 }
const char * p
Definition: xmltok.h:285
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76

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