#include <G4WeightWindowAlgorithm.hh>
Inheritance diagram for G4WeightWindowAlgorithm:
Public Member Functions | |
G4WeightWindowAlgorithm (G4double upperLimitFaktor=5, G4double survivalFaktor=3, G4int maxNumberOfSplits=5) | |
virtual | ~G4WeightWindowAlgorithm () |
virtual G4Nsplit_Weight | Calculate (G4double init_w, G4double lowerWeightBound) const |
Definition at line 58 of file G4WeightWindowAlgorithm.hh.
G4WeightWindowAlgorithm::G4WeightWindowAlgorithm | ( | G4double | upperLimitFaktor = 5 , |
|
G4double | survivalFaktor = 3 , |
|||
G4int | maxNumberOfSplits = 5 | |||
) |
Definition at line 40 of file G4WeightWindowAlgorithm.cc.
00042 : 00043 fUpperLimitFaktor(upperLimitFaktor), 00044 fSurvivalFaktor(survivalFaktor), 00045 fMaxNumberOfSplits(maxNumberOfSplits) 00046 {}
G4WeightWindowAlgorithm::~G4WeightWindowAlgorithm | ( | ) | [virtual] |
G4Nsplit_Weight G4WeightWindowAlgorithm::Calculate | ( | G4double | init_w, | |
G4double | lowerWeightBound | |||
) | const [virtual] |
Implements G4VWeightWindowAlgorithm.
Definition at line 54 of file G4WeightWindowAlgorithm.cc.
References G4Nsplit_Weight::fN, G4Nsplit_Weight::fW, and G4UniformRand.
00055 { 00056 00057 G4double survivalWeight = lowerWeightBound * fSurvivalFaktor; 00058 G4double upperWeight = lowerWeightBound * fUpperLimitFaktor; 00059 00060 // initialize return value for case weight in window 00061 G4Nsplit_Weight nw; 00062 nw.fN = 1; 00063 nw.fW = init_w; 00064 00065 if (init_w > upperWeight) { 00066 // splitting 00067 00068 //TB G4double wi_ws = init_w/survivalWeight; 00069 //TB 00070 G4double temp_wi_ws = init_w/upperWeight; 00071 G4int split_i = static_cast<int>(temp_wi_ws); 00072 if(split_i != temp_wi_ws) split_i++; 00073 G4double wi_ws = init_w/split_i; 00074 00075 //TB 00076 //TB G4int int_wi_ws = static_cast<int>(wi_ws); 00077 00078 // values in case integer mode or in csae of double 00079 // mode and the lower number of splits will be diced 00080 //TB nw.fN = int_wi_ws; 00081 //TB nw.fW = survivalWeight; 00082 nw.fN = split_i; 00083 nw.fW = wi_ws; 00084 00085 //TB if (wi_ws <= fMaxNumberOfSplits) { 00086 //TB if (wi_ws > int_wi_ws) { 00087 //TB // double mode 00088 //TB G4double p2 = wi_ws - int_wi_ws; 00089 //TB G4double r = G4UniformRand(); 00090 //TB if (r<p2) { 00091 //TB nw.fN = int_wi_ws + 1; 00092 //TB } 00093 //TB } 00094 //TB } 00095 //TB else { 00096 //TB // fMaxNumberOfSplits < wi_ws 00097 //TB nw.fN = fMaxNumberOfSplits; 00098 //TB nw.fW = init_w/fMaxNumberOfSplits; 00099 //TB } 00100 00101 00102 } else if (init_w < lowerWeightBound) { 00103 // Russian roulette 00104 G4double wi_ws = init_w/survivalWeight; 00105 G4double p = std::max(wi_ws,1./fMaxNumberOfSplits); 00106 G4double r = G4UniformRand(); 00107 if (r<p){ 00108 nw.fW = init_w/p; 00109 nw.fN = 1; 00110 } else { 00111 nw.fW = 0; 00112 nw.fN = 0; 00113 } 00114 } 00115 // else do nothing 00116 00117 00118 return nw; 00119 }