G4EmBiasingManager Class Reference

#include <G4EmBiasingManager.hh>


Public Member Functions

 G4EmBiasingManager ()
 ~G4EmBiasingManager ()
void Initialise (const G4ParticleDefinition &part, const G4String &procName, G4int verbose)
void ActivateForcedInteraction (G4double length=0.0, const G4String &r="")
void ActivateSecondaryBiasing (const G4String &region, G4double factor, G4double energyLimit)
G4double GetStepLimit (G4int coupleIdx, G4double previousStep)
G4double ApplySecondaryBiasing (std::vector< G4DynamicParticle * > &, const G4Track &track, G4VEmModel *currentModel, G4ParticleChangeForGamma *pParticleChange, G4double &eloss, G4int coupleIdx, G4double tcut, G4double safety=0.0)
G4double ApplySecondaryBiasing (std::vector< G4DynamicParticle * > &, const G4Track &track, G4VEmModel *currentModel, G4ParticleChangeForLoss *pParticleChange, G4double &eloss, G4int coupleIdx, G4double tcut, G4double safety=0.0)
G4double ApplySecondaryBiasing (std::vector< G4Track * > &, G4int coupleIdx)
G4bool SecondaryBiasingRegion (G4int coupleIdx)
G4bool ForcedInteractionRegion (G4int coupleIdx)
void ResetForcedInteraction ()


Detailed Description

Definition at line 67 of file G4EmBiasingManager.hh.


Constructor & Destructor Documentation

G4EmBiasingManager::G4EmBiasingManager (  ) 

Definition at line 65 of file G4EmBiasingManager.cc.

References G4Electron::Electron().

00066   : nForcedRegions(0),nSecBiasedRegions(0),eIonisation(0),
00067     currentStepLimit(0.0),startTracking(true)
00068 {
00069   fSafetyMin = 1.e-6*mm;
00070   theElectron = G4Electron::Electron();
00071 }

G4EmBiasingManager::~G4EmBiasingManager (  ) 

Definition at line 75 of file G4EmBiasingManager.cc.

00076 {}


Member Function Documentation

void G4EmBiasingManager::ActivateForcedInteraction ( G4double  length = 0.0,
const G4String r = "" 
)

Definition at line 146 of file G4EmBiasingManager.cc.

References G4cout, G4endl, G4RegionStore::GetInstance(), and G4RegionStore::GetRegion().

Referenced by G4VEnergyLossProcess::ActivateForcedInteraction(), and G4VEmProcess::ActivateForcedInteraction().

00148 {
00149   G4RegionStore* regionStore = G4RegionStore::GetInstance();
00150   G4String name = rname;
00151   if(name == "" || name == "world" || name == "World") {
00152     name = "DefaultRegionForTheWorld";
00153   }
00154   const G4Region* reg = regionStore->GetRegion(name, false);
00155   if(!reg) { 
00156     G4cout << "### G4EmBiasingManager::ForcedInteraction WARNING: "
00157            << " G4Region <"
00158            << rname << "> is unknown" << G4endl;
00159     return; 
00160   }
00161 
00162   // the region is in the list
00163   if (0 < nForcedRegions) {
00164     for (G4int i=0; i<nForcedRegions; ++i) {
00165       if (reg == forcedRegions[i]) {
00166         lengthForRegion[i] = val; 
00167         return;
00168       }
00169     }
00170   }
00171   if(val < 0.0) { 
00172     G4cout << "### G4EmBiasingManager::ForcedInteraction WARNING: "
00173            << val << " < 0.0, so no activation for the G4Region <"
00174            << rname << ">" << G4endl;
00175     return; 
00176   }
00177 
00178   // new region 
00179   forcedRegions.push_back(reg);
00180   lengthForRegion.push_back(val);
00181   ++nForcedRegions;
00182 }

void G4EmBiasingManager::ActivateSecondaryBiasing ( const G4String region,
G4double  factor,
G4double  energyLimit 
)

Definition at line 187 of file G4EmBiasingManager.cc.

References G4cout, G4endl, G4lrint(), G4RegionStore::GetInstance(), and G4RegionStore::GetRegion().

Referenced by G4VEnergyLossProcess::ActivateSecondaryBiasing(), and G4VEmProcess::ActivateSecondaryBiasing().

00190 {
00191   //G4cout << "G4EmBiasingManager::ActivateSecondaryBiasing: "
00192   //     << rname << " F= " << factor << " E(MeV)= " << energyLimit/MeV
00193   //     << G4endl; 
00194   G4RegionStore* regionStore = G4RegionStore::GetInstance();
00195   G4String name = rname;
00196   if(name == "" || name == "world" || name == "World") {
00197     name = "DefaultRegionForTheWorld";
00198   }
00199   const G4Region* reg = regionStore->GetRegion(name, false);
00200   if(!reg) { 
00201     G4cout << "### G4EmBiasingManager::ActivateBremsstrahlungSplitting WARNING: "
00202            << " G4Region <"
00203            << rname << "> is unknown" << G4endl;
00204     return; 
00205   }
00206 
00207   // Range cut
00208   G4int nsplit = 0;
00209   G4double w = factor;
00210 
00211   // splitting
00212   if(factor >= 1.0) {
00213     nsplit = G4lrint(factor);
00214     w = 1.0/G4double(nsplit);
00215 
00216     // Russian roulette 
00217   } else if(0.0 < factor) { 
00218     nsplit = 1;
00219     w = 1.0/factor;
00220   }
00221 
00222   // the region is in the list - overwrite parameters
00223   if (0 < nSecBiasedRegions) {
00224     for (G4int i=0; i<nSecBiasedRegions; ++i) {
00225       if (reg == secBiasedRegions[i]) {
00226         secBiasedWeight[i] = w;
00227         nBremSplitting[i]  = nsplit; 
00228         secBiasedEnegryLimit[i] = energyLimit;
00229         return;
00230       }
00231     }
00232   }
00233   /*
00234     G4cout << "### G4EmBiasingManager::ActivateSecondaryBiasing: "
00235            << " nsplit= " << nsplit << " for the G4Region <"
00236            << rname << ">" << G4endl; 
00237   */
00238 
00239   // new region 
00240   secBiasedRegions.push_back(reg);
00241   secBiasedWeight.push_back(w);
00242   nBremSplitting.push_back(nsplit);
00243   secBiasedEnegryLimit.push_back(energyLimit);
00244   ++nSecBiasedRegions;
00245   //G4cout << "nSecBiasedRegions= " << nSecBiasedRegions << G4endl;
00246 }

G4double G4EmBiasingManager::ApplySecondaryBiasing ( std::vector< G4Track * > &  ,
G4int  coupleIdx 
)

Definition at line 368 of file G4EmBiasingManager.cc.

References G4UniformRand, and CLHEP::detail::n.

00370 {
00371   G4int index = idxSecBiasedCouple[coupleIdx];
00372   G4double weight = 1.0;
00373   if(0 <= index) {
00374     size_t n = track.size();
00375 
00376     // the check cannot be applied per secondary particle
00377     // because weight correction is common, so the first
00378     // secondary is checked
00379     if(0 < n && track[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
00380 
00381       G4int nsplit = nBremSplitting[index];
00382 
00383         // Russian Roulette only
00384       if(1 == nsplit) { 
00385         weight = secBiasedWeight[index];
00386         for(size_t k=0; k<n; ++k) {
00387           if(G4UniformRand()*weight > 1.0) {
00388             const G4Track* t = track[k];
00389             delete t;
00390             track[k] = 0;
00391           }
00392         }
00393       }
00394     }
00395   }
00396   return weight;
00397 }

G4double G4EmBiasingManager::ApplySecondaryBiasing ( std::vector< G4DynamicParticle * > &  ,
const G4Track track,
G4VEmModel currentModel,
G4ParticleChangeForLoss pParticleChange,
G4double eloss,
G4int  coupleIdx,
G4double  tcut,
G4double  safety = 0.0 
)

Definition at line 272 of file G4EmBiasingManager.cc.

References G4ParticleChangeForLoss::GetProposedKineticEnergy(), G4ParticleChangeForLoss::GetProposedMomentumDirection(), CLHEP::detail::n, G4ParticleChangeForLoss::ProposeMomentumDirection(), and G4ParticleChangeForLoss::SetProposedKineticEnergy().

00281 {
00282   G4int index = idxSecBiasedCouple[coupleIdx];
00283   G4double weight = 1.0;
00284   if(0 <= index) {
00285     size_t n = vd.size();
00286 
00287     // the check cannot be applied per secondary particle
00288     // because weight correction is common, so the first
00289     // secondary is checked
00290     if(0 < n && vd[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
00291 
00292       G4int nsplit = nBremSplitting[index];
00293 
00294       // Range cut
00295       if(0 == nsplit) { 
00296         if(safety > fSafetyMin) { ApplyRangeCut(vd, track, eloss, safety); }
00297 
00298         // Russian Roulette
00299       } if(1 == nsplit) { 
00300         weight = ApplyRussianRoulette(vd, index);
00301 
00302         // Splitting
00303       } else {
00304         G4double tmpEnergy = pPartChange->GetProposedKineticEnergy();
00305         G4ThreeVector tmpMomDir = pPartChange->GetProposedMomentumDirection();
00306 
00307         weight = ApplySplitting(vd, track, currentModel, index, tcut);
00308 
00309         pPartChange->SetProposedKineticEnergy(tmpEnergy);
00310         pPartChange->ProposeMomentumDirection(tmpMomDir);
00311       }
00312     }
00313   }
00314   return weight;
00315 }

G4double G4EmBiasingManager::ApplySecondaryBiasing ( std::vector< G4DynamicParticle * > &  ,
const G4Track track,
G4VEmModel currentModel,
G4ParticleChangeForGamma pParticleChange,
G4double eloss,
G4int  coupleIdx,
G4double  tcut,
G4double  safety = 0.0 
)

Definition at line 320 of file G4EmBiasingManager.cc.

References G4ParticleChangeForGamma::GetProposedKineticEnergy(), G4ParticleChangeForGamma::GetProposedMomentumDirection(), CLHEP::detail::n, G4ParticleChangeForGamma::ProposeMomentumDirection(), and G4ParticleChangeForGamma::SetProposedKineticEnergy().

Referenced by G4VEnergyLossProcess::PostStepDoIt(), and G4VEmProcess::PostStepDoIt().

00329 {
00330   G4int index = idxSecBiasedCouple[coupleIdx];
00331   G4double weight = 1.0;
00332   if(0 <= index) {
00333     size_t n = vd.size();
00334 
00335     // the check cannot be applied per secondary particle
00336     // because weight correction is common, so the first
00337     // secondary is checked
00338     if(0 < n && vd[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
00339 
00340       G4int nsplit = nBremSplitting[index];
00341 
00342       // Range cut
00343       if(0 == nsplit) { 
00344         if(safety > fSafetyMin) { ApplyRangeCut(vd, track, eloss, safety); }
00345 
00346         // Russian Roulette
00347       } if(1 == nsplit) { 
00348         weight = ApplyRussianRoulette(vd, index);
00349 
00350         // Splitting
00351       } else {
00352         G4double tmpEnergy = pPartChange->GetProposedKineticEnergy();
00353         G4ThreeVector tmpMomDir = pPartChange->GetProposedMomentumDirection();
00354 
00355         weight = ApplySplitting(vd, track, currentModel, index, tcut);
00356 
00357         pPartChange->SetProposedKineticEnergy(tmpEnergy);
00358         pPartChange->ProposeMomentumDirection(tmpMomDir);
00359       }
00360     }
00361   }
00362   return weight;
00363 }

G4bool G4EmBiasingManager::ForcedInteractionRegion ( G4int  coupleIdx  )  [inline]

Definition at line 177 of file G4EmBiasingManager.hh.

Referenced by G4VEnergyLossProcess::PostStepDoIt(), G4VEmProcess::PostStepDoIt(), and G4VEnergyLossProcess::PostStepGetPhysicalInteractionLength().

00178 {
00179   G4bool res = false;
00180   if(nForcedRegions > 0) {
00181     if(idxForcedCouple[coupleIdx] >= 0) { res = true; }
00182   }
00183   return res;
00184 }

G4double G4EmBiasingManager::GetStepLimit ( G4int  coupleIdx,
G4double  previousStep 
)

Definition at line 250 of file G4EmBiasingManager.cc.

References DBL_MAX, and G4UniformRand.

Referenced by G4VEnergyLossProcess::PostStepGetPhysicalInteractionLength().

00252 {
00253   if(startTracking) {
00254     startTracking = false;
00255     G4int i = idxForcedCouple[coupleIdx];
00256     if(i < 0) {
00257       currentStepLimit = DBL_MAX;
00258     } else {
00259       currentStepLimit = lengthForRegion[i];
00260       if(currentStepLimit > 0.0) { currentStepLimit *= G4UniformRand(); }
00261     }
00262   } else {
00263     currentStepLimit -= previousStep;
00264   }
00265   if(currentStepLimit < 0.0) { currentStepLimit = 0.0; }
00266   return currentStepLimit;
00267 }

void G4EmBiasingManager::Initialise ( const G4ParticleDefinition part,
const G4String procName,
G4int  verbose 
)

Definition at line 80 of file G4EmBiasingManager.cc.

References G4cout, G4endl, G4ProductionCutsTable::GetMaterialCutsCouple(), G4ParticleDefinition::GetParticleName(), G4MaterialCutsCouple::GetProductionCuts(), G4ProductionCutsTable::GetProductionCutsTable(), and G4ProductionCutsTable::GetTableSize().

Referenced by G4VEnergyLossProcess::PreparePhysicsTable(), and G4VEmProcess::PreparePhysicsTable().

00082 {
00083   //G4cout << "G4EmBiasingManager::Initialise for "
00084   //     << part.GetParticleName()
00085   //     << " and " << procName << G4endl;
00086   const G4ProductionCutsTable* theCoupleTable=
00087     G4ProductionCutsTable::GetProductionCutsTable();
00088   size_t numOfCouples = theCoupleTable->GetTableSize();
00089 
00090   if(0 < nForcedRegions) { idxForcedCouple.resize(numOfCouples, -1); }
00091   if(0 < nSecBiasedRegions) { idxSecBiasedCouple.resize(numOfCouples, -1); }
00092 
00093   // Deexcitation
00094   for (size_t j=0; j<numOfCouples; ++j) {
00095     const G4MaterialCutsCouple* couple =
00096       theCoupleTable->GetMaterialCutsCouple(j);
00097     const G4ProductionCuts* pcuts = couple->GetProductionCuts();
00098     if(0 <  nForcedRegions) {
00099       for(G4int i=0; i<nForcedRegions; ++i) {
00100         if(forcedRegions[i]) {
00101           if(pcuts == forcedRegions[i]->GetProductionCuts()) { 
00102             idxForcedCouple[j] = i;
00103             break; 
00104           }
00105         }
00106       }
00107     }
00108     if(0 < nSecBiasedRegions) { 
00109       for(G4int i=0; i<nSecBiasedRegions; ++i) {
00110         if(secBiasedRegions[i]) {
00111           if(pcuts == secBiasedRegions[i]->GetProductionCuts()) { 
00112             idxSecBiasedCouple[j] = i;
00113             break; 
00114           }
00115         }
00116       }
00117     }
00118   }
00119   if (nForcedRegions > 0 && 0 < verbose) {
00120     G4cout << " Forced Interaction is activated for "
00121            << part.GetParticleName() << " and " 
00122            << procName 
00123            << " inside G4Regions: " << G4endl;
00124     for (G4int i=0; i<nForcedRegions; ++i) {
00125       const G4Region* r = forcedRegions[i];
00126       if(r) { G4cout << "           " << r->GetName() << G4endl; }
00127     }
00128   }
00129   if (nSecBiasedRegions > 0 && 0 < verbose) {
00130     G4cout << " Secondary biasing is activated for " 
00131            << part.GetParticleName() << " and " 
00132            << procName 
00133            << " inside G4Regions: " << G4endl;
00134     for (G4int i=0; i<nSecBiasedRegions; ++i) {
00135       const G4Region* r = secBiasedRegions[i];
00136       if(r) { 
00137         G4cout << "           " << r->GetName() 
00138                << "  BiasingWeight= " << secBiasedWeight[i] << G4endl; 
00139       }
00140     }
00141   }
00142 }

void G4EmBiasingManager::ResetForcedInteraction (  )  [inline]

Definition at line 186 of file G4EmBiasingManager.hh.

Referenced by G4VEnergyLossProcess::StartTracking(), and G4VEmProcess::StartTracking().

00187 {
00188   startTracking = true;
00189 }

G4bool G4EmBiasingManager::SecondaryBiasingRegion ( G4int  coupleIdx  )  [inline]

Definition at line 168 of file G4EmBiasingManager.hh.

Referenced by G4VEnergyLossProcess::PostStepDoIt(), and G4VEmProcess::PostStepDoIt().

00169 {
00170   G4bool res = false;
00171   if(nSecBiasedRegions > 0) {
00172     if(idxSecBiasedCouple[coupleIdx] >= 0) { res = true; }
00173   }
00174   return res;
00175 }


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