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) {
125 const G4Region* r = forcedRegions[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) {
135 const G4Region* r = secBiasedRegions[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 WARNING: "
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,
282 G4int index = idxSecBiasedCouple[coupleIdx];
285 size_t n = vd.size();
290 if(0 < n && vd[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
292 G4int nsplit = nBremSplitting[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,
330 G4int index = idxSecBiasedCouple[coupleIdx];
333 size_t n = vd.size();
338 if(0 < n && vd[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
340 G4int nsplit = nBremSplitting[index];
344 if(safety > fSafetyMin) { ApplyRangeCut(vd, track, eloss, safety); }
348 weight = ApplyRussianRoulette(vd, index);
355 weight = ApplySplitting(vd, track, currentModel, index, tcut);
371 G4int index = idxSecBiasedCouple[coupleIdx];
374 size_t n = track.size();
379 if(0 < n && track[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
381 G4int nsplit = nBremSplitting[index];
385 weight = secBiasedWeight[index];
386 for(
size_t k=0; k<n; ++k) {
402G4EmBiasingManager::ApplyRangeCut(std::vector<G4DynamicParticle*>& vd,
406 size_t n = vd.size();
411 for(
size_t k=0; k<
n; ++k) {
428G4EmBiasingManager::ApplySplitting(std::vector<G4DynamicParticle*>& vd,
437 size_t n = vd.size();
438 G4double w = secBiasedWeight[index];
440 if(1 != n || 1.0 <= w) {
return weight; }
445 G4int nsplit = nBremSplitting[index];
448 if(1 < nsplit && trackWeight>w) {
452 if(nsplit > (
G4int)tmpSecondaries.size()) {
453 tmpSecondaries.reserve(nsplit);
456 for(
G4int k=1; k<nsplit; ++k) {
457 tmpSecondaries.clear();
459 for (
size_t kk=0; kk<tmpSecondaries.size(); ++kk) {
460 vd.push_back(tmpSecondaries[kk]);
G4DLLIMPORT std::ostream G4cout
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
static G4Electron * Electron()
G4double ApplySecondaryBiasing(std::vector< G4DynamicParticle * > &, const G4Track &track, G4VEmModel *currentModel, G4ParticleChangeForGamma *pParticleChange, G4double &eloss, G4int coupleIdx, G4double tcut, G4double safety=0.0)
void ActivateSecondaryBiasing(const G4String ®ion, G4double factor, G4double energyLimit)
void Initialise(const G4ParticleDefinition &part, const G4String &procName, G4int verbose)
void ActivateForcedInteraction(G4double length=0.0, const G4String &r="")
G4double GetStepLimit(G4int coupleIdx, G4double previousStep)
static G4LossTableManager * Instance()
G4VEnergyLossProcess * GetEnergyLossProcess(const G4ParticleDefinition *)
G4ProductionCuts * GetProductionCuts() const
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
G4double GetProposedKineticEnergy() const
const G4ThreeVector & GetProposedMomentumDirection() const
G4double GetProposedKineticEnergy() const
void SetProposedKineticEnergy(G4double proposedKinEnergy)
const G4ThreeVector & GetProposedMomentumDirection() const
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
const G4String & GetParticleName() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
static G4RegionStore * GetInstance()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
const G4String & GetName() const
G4double GetWeight() const
const G4DynamicParticle * GetDynamicParticle() const
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin=0.0, G4double tmax=DBL_MAX)=0
G4double GetRangeForLoss(G4double &kineticEnergy, const G4MaterialCutsCouple *)