G4ImportanceAlgorithm Class Reference

#include <G4ImportanceAlgorithm.hh>

Inheritance diagram for G4ImportanceAlgorithm:

G4VImportanceAlgorithm

Public Member Functions

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

Detailed Description

Definition at line 44 of file G4ImportanceAlgorithm.hh.


Constructor & Destructor Documentation

G4ImportanceAlgorithm::G4ImportanceAlgorithm (  ) 

Definition at line 42 of file G4ImportanceAlgorithm.cc.

00042                                             : fWorned(false)
00043 {
00044 }

G4ImportanceAlgorithm::~G4ImportanceAlgorithm (  )  [virtual]

Definition at line 46 of file G4ImportanceAlgorithm.cc.

00047 {
00048 }


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.

References G4Nsplit_Weight::fN, G4Nsplit_Weight::fW, G4endl, and G4UniformRand.

00054 {
00055   G4Nsplit_Weight nw = {0,0};
00056   if (ipost>0.){
00057     if (!(ipre>0.)){
00058       Error("Calculate() - ipre==0.");
00059     }
00060     G4double ipre_over_ipost = ipre/ipost;
00061     if ((ipre_over_ipost<0.25 || ipre_over_ipost> 4) && !fWorned) {
00062       std::ostringstream os;
00063       os << "Calculate() - ipre_over_ipost ! in [0.25, 4]." << G4endl
00064          << "ipre_over_ipost = " << ipre_over_ipost << ".";
00065       Warning(os.str());
00066       fWorned = true;
00067       if (ipre_over_ipost<=0) {
00068         Error("Calculate() - ipre_over_ipost<=0.");
00069       }
00070     }
00071     if (init_w<=0.) {
00072       Error("Calculate() - iniitweight<= 0. found!");
00073     }
00074 
00075     // default geometrical splitting 
00076     // in integer mode 
00077     // for ipre_over_ipost <= 1
00078     G4double inv = 1./ipre_over_ipost;
00079     nw.fN = static_cast<G4int>(inv);
00080     nw.fW = init_w * ipre_over_ipost;
00081     
00082     // geometrical splitting for double mode
00083     if (ipre_over_ipost<1) {
00084       if ( static_cast<G4double>(nw.fN) != inv) {
00085         // double mode
00086         // probability p for splitting into n+1 tracks
00087         G4double p = inv - nw.fN;
00088         // get a random number out of [0,1)
00089         G4double r = G4UniformRand();
00090         if (r<p) {
00091           nw.fN++;
00092         } 
00093       }  
00094     }
00095     // ipre_over_ipost > 1
00096     //  russian roulett
00097     else if (ipre_over_ipost>1) {
00098       // probabiity for killing track
00099       G4double p = 1-inv;
00100       // get a random number out of [0,1)
00101       G4double r = G4UniformRand();
00102       if (r<p) {
00103         // kill track
00104         nw.fN = 0;
00105         nw.fW = 0;
00106       }
00107       else {
00108         nw.fN = 1;     
00109       }
00110     }
00111   }
00112   return nw;
00113 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:15 2013 for Geant4 by  doxygen 1.4.7