Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 47 of file G4ImportanceAlgorithm.cc.

47  : fWorned(false)
48 {
49 }
G4ImportanceAlgorithm::~G4ImportanceAlgorithm ( )
virtual

Definition at line 51 of file G4ImportanceAlgorithm.cc.

52 {
53 }

Member Function Documentation

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

Implements G4VImportanceAlgorithm.

Definition at line 56 of file G4ImportanceAlgorithm.cc.

59 {
60 
61 #ifdef G4MULTITHREADED
62  G4MUTEXLOCK(&G4ImportanceAlgorithm::ImportanceMutex);
63 #endif
64 
65  G4Nsplit_Weight nw = {0,0};
66  if (ipost>0.){
67  if (!(ipre>0.)){
68  Error("Calculate() - ipre==0.");
69  }
70  G4double ipre_over_ipost = ipre/ipost;
71  if ((ipre_over_ipost<0.25 || ipre_over_ipost> 4) && !fWorned) {
72  std::ostringstream os;
73  os << "Calculate() - ipre_over_ipost ! in [0.25, 4]." << G4endl
74  << "ipre_over_ipost = " << ipre_over_ipost << ".";
75  Warning(os.str());
76  fWorned = true;
77  if (ipre_over_ipost<=0) {
78  Error("Calculate() - ipre_over_ipost<=0.");
79  }
80  }
81  if (init_w<=0.) {
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  if ( static_cast<G4double>(nw.fN) != inv) {
95  // double mode
96  // probability p for splitting into n+1 tracks
97  G4double p = inv - nw.fN;
98  // get a random number out of [0,1)
99  G4double r = G4UniformRand();
100  if (r<p) {
101  nw.fN++;
102  }
103  }
104  }
105  // ipre_over_ipost > 1
106  // russian roulett
107  else if (ipre_over_ipost>1) {
108  // probabiity for killing track
109  G4double p = 1-inv;
110  // get a random number out of [0,1)
111  G4double r = G4UniformRand();
112  if (r<p) {
113  // kill track
114  nw.fN = 0;
115  nw.fW = 0;
116  }
117  else {
118  nw.fN = 1;
119  }
120  }
121  }
122 #ifdef G4MULTITHREADED
123  G4MUTEXUNLOCK(&G4ImportanceAlgorithm::ImportanceMutex);
124 #endif
125  return nw;
126 }
#define G4MUTEXUNLOCK
Definition: G4Threading.hh:180
const char * p
Definition: xmltok.h:285
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
#define G4MUTEXLOCK
Definition: G4Threading.hh:179
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76

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