66 : nForcedRegions(0),nSecBiasedRegions(0),eIonisation(0),
67 currentStepLimit(0.0),startTracking(true)
69 fSafetyMin = 1.e-6*
mm;
90 if(0 < nForcedRegions) { idxForcedCouple.resize(numOfCouples, -1); }
91 if(0 < nSecBiasedRegions) { idxSecBiasedCouple.resize(numOfCouples, -1); }
94 for (
size_t j=0; j<numOfCouples; ++j) {
98 if(0 < nForcedRegions) {
99 for(
G4int i=0; i<nForcedRegions; ++i) {
100 if(forcedRegions[i]) {
101 if(pcuts == forcedRegions[i]->GetProductionCuts()) {
102 idxForcedCouple[j] = i;
108 if(0 < nSecBiasedRegions) {
109 for(
G4int i=0; i<nSecBiasedRegions; ++i) {
110 if(secBiasedRegions[i]) {
111 if(pcuts == secBiasedRegions[i]->GetProductionCuts()) {
112 idxSecBiasedCouple[j] = i;
119 if (nForcedRegions > 0 && 0 < verbose) {
120 G4cout <<
" Forced Interaction is activated for "
123 <<
" inside G4Regions: " <<
G4endl;
124 for (
G4int i=0; i<nForcedRegions; ++i) {
129 if (nSecBiasedRegions > 0 && 0 < verbose) {
130 G4cout <<
" Secondary biasing is activated for "
133 <<
" inside G4Regions: " <<
G4endl;
134 for (
G4int i=0; i<nSecBiasedRegions; ++i) {
138 <<
" BiasingWeight= " << secBiasedWeight[i] <<
G4endl;
151 if(name ==
"" || name ==
"world" || name ==
"World") {
152 name =
"DefaultRegionForTheWorld";
156 G4cout <<
"### G4EmBiasingManager::ForcedInteraction WARNING: "
158 << rname <<
"> is unknown" <<
G4endl;
163 if (0 < nForcedRegions) {
164 for (
G4int i=0; i<nForcedRegions; ++i) {
165 if (reg == forcedRegions[i]) {
166 lengthForRegion[i] = val;
172 G4cout <<
"### G4EmBiasingManager::ForcedInteraction WARNING: "
173 << val <<
" < 0.0, so no activation for the G4Region <"
174 << rname <<
">" <<
G4endl;
179 forcedRegions.push_back(reg);
180 lengthForRegion.push_back(val);
196 if(name ==
"" || name ==
"world" || name ==
"World") {
197 name =
"DefaultRegionForTheWorld";
201 G4cout <<
"### G4EmBiasingManager::ActivateBremsstrahlungSplitting "
202 <<
"WARNING: G4Region <"
203 << rname <<
"> is unknown" <<
G4endl;
217 }
else if(0.0 < factor) {
223 if (0 < nSecBiasedRegions) {
224 for (
G4int i=0; i<nSecBiasedRegions; ++i) {
225 if (reg == secBiasedRegions[i]) {
226 secBiasedWeight[i] = w;
227 nBremSplitting[i] = nsplit;
228 secBiasedEnegryLimit[i] = energyLimit;
240 secBiasedRegions.push_back(reg);
241 secBiasedWeight.push_back(w);
242 nBremSplitting.push_back(nsplit);
243 secBiasedEnegryLimit.push_back(energyLimit);
254 startTracking =
false;
255 G4int i = idxForcedCouple[coupleIdx];
259 currentStepLimit = lengthForRegion[i];
260 if(currentStepLimit > 0.0) { currentStepLimit *=
G4UniformRand(); }
263 currentStepLimit -= previousStep;
265 if(currentStepLimit < 0.0) { currentStepLimit = 0.0; }
266 return currentStepLimit;
273 std::vector<G4DynamicParticle*>& vd,
285 size_t n = vd.size();
290 if(0 < n && vd[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
296 if(safety > fSafetyMin) { ApplyRangeCut(vd, track, eloss, safety); }
300 weight = ApplyRussianRoulette(vd, index);
307 weight = ApplySplitting(vd, track, currentModel, index, tcut);
321 std::vector<G4DynamicParticle*>& vd,
333 size_t n = vd.size();
338 if(0 < n && vd[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
344 if(safety > fSafetyMin) { ApplyRangeCut(vd, track, eloss, safety); }
347 }
else if(1 == nsplit) {
348 weight = ApplyRussianRoulette(vd, index);
355 weight = ApplySplitting(vd, track, currentModel, index, tcut);
374 size_t n = track.size();
379 if(0 < n && track[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
385 weight = secBiasedWeight[
index];
386 for(
size_t k=0; k<
n; ++k) {
402 G4EmBiasingManager::ApplyRangeCut(std::vector<G4DynamicParticle*>& vd,
406 size_t n = vd.size();
412 for(
size_t k=0; k<
n; ++k) {
430 G4EmBiasingManager::ApplySplitting(std::vector<G4DynamicParticle*>& vd,
439 size_t n = vd.size();
442 if(1 != n || 1.0 <= w) {
return weight; }
450 if(1 < nsplit && trackWeight>w) {
454 if(nsplit > (
G4int)tmpSecondaries.size()) {
455 tmpSecondaries.reserve(nsplit);
458 for(
G4int k=1; k<nsplit; ++k) {
459 tmpSecondaries.clear();
462 for (
size_t kk=0; kk<tmpSecondaries.size(); ++kk) {
463 vd.push_back(tmpSecondaries[kk]);
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
const G4String & GetName() const
static G4LossTableManager * Instance()
void ActivateForcedInteraction(G4double length=0.0, const G4String &r="")
G4double ApplySecondaryBiasing(std::vector< G4DynamicParticle * > &, const G4Track &track, G4VEmModel *currentModel, G4ParticleChangeForGamma *pParticleChange, G4double &eloss, G4int coupleIdx, G4double tcut, G4double safety=0.0)
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin=0.0, G4double tmax=DBL_MAX)=0
G4double GetKineticEnergy() const
const G4DynamicParticle * GetDynamicParticle() const
G4double GetRangeForLoss(G4double &kineticEnergy, const G4MaterialCutsCouple *)
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
const G4ThreeVector & GetProposedMomentumDirection() const
G4ParticleDefinition * GetDefinition() const
G4double GetProposedKineticEnergy() const
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
const G4String & GetParticleName() const
void Initialise(const G4ParticleDefinition &part, const G4String &procName, G4int verbose)
static G4RegionStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
size_t GetTableSize() const
G4double GetStepLimit(G4int coupleIdx, G4double previousStep)
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void ActivateSecondaryBiasing(const G4String ®ion, G4double factor, G4double energyLimit)
G4VEnergyLossProcess * GetEnergyLossProcess(const G4ParticleDefinition *)
static G4ProductionCutsTable * GetProductionCutsTable()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
G4double GetProposedKineticEnergy() const
G4double GetWeight() const
static G4Electron * Electron()
void SetProposedKineticEnergy(G4double proposedKinEnergy)
G4ProductionCuts * GetProductionCuts() const
const G4ThreeVector & GetProposedMomentumDirection() const