61 fPhysBiasAllCharged(false), fNonPhysBiasAllCharged(false),
62 fPhysBiasAllChargedISL(false), fNonPhysBiasAllChargedISL(false),
63 fPhysBiasAllNeutral(false), fNonPhysBiasAllNeutral(false),
64 fPhysBiasAllNeutralISL(false), fNonPhysBiasAllNeutralISL(false),
78 fBiasedParticles.push_back(particleName);
79 fBiasedProcesses.emplace_back();
80 fBiasAllProcesses.push_back(
true);
87 fBiasedParticles.push_back(particleName);
88 fBiasedProcesses.push_back(processNames);
89 fBiasAllProcesses.push_back(
false);
96 fNonPhysBiasedParticles.push_back(particleName);
118 if ( PDGlow > PDGhigh )
G4cout <<
" G4GenericBiasingPhysics::PhysicsBiasAddPDGRange(...) : PDGlow > PDGhigh, call ignored." <<
G4endl;
119 fPhysBiasByPDGRangeLow .push_back( PDGlow );
120 fPhysBiasByPDGRangeHigh.push_back( PDGhigh );
121 if ( includeAntiParticle )
123 fPhysBiasByPDGRangeLow .push_back( -PDGhigh );
124 fPhysBiasByPDGRangeHigh.push_back( -PDGlow );
131 if ( PDGlow > PDGhigh )
G4cout <<
" G4GenericBiasingPhysics::NonPhysicsBiasAddPDGRange(...) : PDGlow > PDGhigh, call ignored." <<
G4endl;
132 fNonPhysBiasByPDGRangeLow .push_back( PDGlow );
133 fNonPhysBiasByPDGRangeHigh.push_back( PDGhigh );
134 if ( includeAntiParticle )
136 fNonPhysBiasByPDGRangeLow .push_back( -PDGhigh );
137 fNonPhysBiasByPDGRangeHigh.push_back( -PDGlow );
145 if ( PDGlow > PDGhigh )
G4cout <<
" G4GenericBiasingPhysics::BiasAddPDGRange(...) : PDGlow > PDGhigh, call ignored." <<
G4endl;
152 fPhysBiasAllCharged =
true;
153 fPhysBiasAllChargedISL = includeShortLived;
157 fNonPhysBiasAllCharged =
true;
158 fNonPhysBiasAllChargedISL = includeShortLived;
162 fPhysBiasAllCharged =
true;
163 fNonPhysBiasAllCharged =
true;
164 fPhysBiasAllChargedISL = includeShortLived;
165 fNonPhysBiasAllChargedISL = includeShortLived;
169 fPhysBiasAllNeutral =
true;
170 fPhysBiasAllNeutralISL = includeShortLived;
174 fNonPhysBiasAllNeutral =
true;
175 fNonPhysBiasAllNeutralISL = includeShortLived;
179 fPhysBiasAllNeutral =
true;
180 fNonPhysBiasAllNeutral =
true;
181 fPhysBiasAllNeutralISL = includeShortLived;
182 fNonPhysBiasAllNeutralISL = includeShortLived;
190 for (
G4String knownParticle : fParticlesWithParallelGeometries )
192 if ( knownParticle == particleName )
200 if ( !isKnown ) fParticlesWithParallelGeometries.push_back( particleName );
201 std::vector< G4String >& geometries = fParallelGeometriesForParticle[particleName];
204 for (
G4String knownGeometry : geometries )
206 if ( knownGeometry == parallelGeometryName )
212 if ( !isKnown ) geometries.push_back( parallelGeometryName );
223 if ( PDGlow > PDGhigh )
225 G4cout <<
"G4GenericBiasingPhysics::AddParallelGeometry( G4int PDGlow, G4int PDGhigh, const G4String& parallelGeometryName , G4bool includeAntiParticle = true ), PDGlow > PDGhigh : call ignored" <<
G4endl;
229 fPDGlowParallelGeometries .push_back( PDGlow );
230 fPDGhighParallelGeometries.push_back( PDGhigh );
231 G4int rangeIndex =
G4int(fPDGlowParallelGeometries.size() - 1);
232 fPDGrangeParallelGeometries[rangeIndex].push_back( parallelGeometryName );
234 if ( includeAntiParticle )
236 fPDGlowParallelGeometries .push_back( -PDGhigh );
237 fPDGhighParallelGeometries.push_back( -PDGlow );
238 rangeIndex =
G4int(fPDGlowParallelGeometries.size() - 1);
239 fPDGrangeParallelGeometries[rangeIndex].push_back( parallelGeometryName );
246 if ( PDGlow > PDGhigh )
248 G4cout <<
"G4GenericBiasingPhysics::AddParallelGeometry( G4int PDGlow, G4int PDGhigh, const std::vector< G4String >& parallelGeometryNames, G4bool includeAntiParticle = true ), PDGlow > PDGhigh : call ignored" <<
G4endl;
258 for (
G4String geometry : fParallelGeometriesForCharged )
260 if ( geometry == parallelGeometryName )
268 fParallelGeometriesForCharged .push_back( parallelGeometryName );
269 fAllChargedParallelGeometriesISL.push_back( includeShortLived );
281 for (
G4String geometry : fParallelGeometriesForNeutral )
283 if ( geometry == parallelGeometryName )
291 fParallelGeometriesForNeutral .push_back( parallelGeometryName );
292 fAllNeutralParallelGeometriesISL.push_back( includeShortLived );
324 if ( std::find(fNonPhysBiasedParticles.begin(),
325 fNonPhysBiasedParticles.end(),
326 particleName ) != fNonPhysBiasedParticles.end() )
332 std::vector< G4String >::const_iterator particleIt =
333 std::find(fBiasedParticles.begin(),
334 fBiasedParticles.end(),
336 if ( particleIt == fBiasedParticles.end() )
continue;
338 std::vector < G4String >& biasedProcesses = fBiasedProcesses [ particleIt - fBiasedParticles.begin() ];
339 G4bool biasAll = fBiasAllProcesses[ particleIt - fBiasedParticles.begin() ];
352 while ( restartLoop )
354 for (std::size_t ip = 0 ; ip < biasedProcesses.size() ; ++ip)
358 if ( restartLoop )
break;
375 if ( std::find( fNonPhysBiasedParticles.begin(),
376 fNonPhysBiasedParticles.end(),
377 particleName ) != fNonPhysBiasedParticles.end() )
continue;
379 if ( std::find( fBiasedParticles.begin(),
380 fBiasedParticles.end(),
381 particleName ) != fBiasedParticles.end() )
continue;
384 G4bool physBias(
false), nonPhysBias(
false);
389 for ( std::size_t i = 0 ; i < fPhysBiasByPDGRangeLow.size() ; i++ )
390 if ( ( PDG >= fPhysBiasByPDGRangeLow[i] ) && ( PDG <= fPhysBiasByPDGRangeHigh[i] ) )
395 for ( std::size_t i = 0 ; i < fNonPhysBiasByPDGRangeLow.size() ; i++ )
396 if ( ( PDG >= fNonPhysBiasByPDGRangeLow[i] ) && ( PDG <= fNonPhysBiasByPDGRangeHigh[i] ) )
403 if ( ( physBias ==
false ) && ( nonPhysBias ==
false ) )
407 if ( fPhysBiasAllCharged )
if ( fPhysBiasAllChargedISL || !particle->
IsShortLived() ) physBias =
true;
408 if ( fNonPhysBiasAllCharged )
if ( fNonPhysBiasAllChargedISL || !particle->
IsShortLived() ) nonPhysBias =
true;
412 if ( fPhysBiasAllNeutral )
if ( fPhysBiasAllNeutralISL || !particle->
IsShortLived() ) physBias =
true;
413 if ( fNonPhysBiasAllNeutral )
if ( fNonPhysBiasAllNeutralISL || !particle->
IsShortLived() ) nonPhysBias =
true;
422 std::vector < G4String > biasedProcesses;
431 while ( restartLoop )
433 for (std::size_t ip = 0 ; ip < biasedProcesses.size() ; ++ip)
437 if ( restartLoop )
break;
447 AssociateParallelGeometries();
481 processNames +=
"\n ";
492 G4cout << std::setw(14) << particleName <<
" **** : " << processNames <<
G4endl;
494 G4cout << std::setw(18) << particleName <<
" : " << processNames <<
G4endl;
502void G4GenericBiasingPhysics::AssociateParallelGeometries()
516 for (
G4String requestedParticles : fParticlesWithParallelGeometries )
518 if ( requestedParticles == particleName )
530 std::vector< G4String >& parallelWorlds = fParallelGeometriesForParticle[ particleName ];
539 for (
G4int PDGlow : fPDGlowParallelGeometries )
541 G4int PDGhigh = fPDGhighParallelGeometries[i];
542 auto & geometries = fPDGrangeParallelGeometries[i];
552 if ( ( particlePDG >= PDGlow ) && ( particlePDG <= PDGhigh ) )
569 G4bool islAllNeutral =
false;
570 for(
auto isln : fAllNeutralParallelGeometriesISL)
571 { islAllNeutral |= isln; }
572 G4bool islAllCharged =
false;
573 for(
auto islc : fAllChargedParallelGeometriesISL)
574 { islAllCharged |= islc; }
583 if(particle->
IsShortLived() && !islAllNeutral)
continue;
586 for(G4String wNameN : fParallelGeometriesForCharged)
588 if(!(particle->
IsShortLived()) || fAllNeutralParallelGeometriesISL[j])
596 if(particle->
IsShortLived() && !islAllCharged)
continue;
599 for(G4String wNameC : fParallelGeometriesForCharged)
601 if(!(particle->
IsShortLived()) || fAllChargedParallelGeometriesISL[j])
std::vector< G4InuclElementaryParticle >::iterator particleIterator
#define G4_DECLARE_PHYSCONSTR_FACTORY(physics_constructor)
G4GLOB_DLL std::ostream G4cout
static G4bool ActivatePhysicsBiasing(G4ProcessManager *pmanager, const G4String &physicsProcessToBias, const G4String &wrappedName="")
static void ActivateNonPhysicsBiasing(G4ProcessManager *pmanager, const G4String &nonPhysicsProcessName="")
static G4ParallelGeometriesLimiterProcess * AddLimiterProcess(G4ProcessManager *pmanager, const G4String &processName="biasLimiter")
void BiasAllNeutral(G4bool includeShortLived=false)
void NonPhysicsBiasAllNeutral(G4bool includeShortLived=false)
virtual void ConstructProcess()
G4GenericBiasingPhysics(const G4String &name="BiasingP")
void BiasAddPDGRange(G4int PDGlow, G4int PDGhigh, G4bool includeAntiParticle=true)
void AddParallelGeometry(const G4String &particleName, const G4String ¶llelGeometryName)
void NonPhysicsBiasAddPDGRange(G4int PDGlow, G4int PDGhigh, G4bool includeAntiParticle=true)
void PhysicsBias(const G4String &particleName)
void PhysicsBiasAddPDGRange(G4int PDGlow, G4int PDGhigh, G4bool includeAntiParticle=true)
void AddParallelGeometryAllNeutral(const G4String ¶llelGeometryName, G4bool includeShortLived=false)
void NonPhysicsBias(const G4String &particleName)
void AddParallelGeometryAllCharged(const G4String ¶llelGeometryName, G4bool includeShortLived=false)
virtual void ConstructParticle()
void PhysicsBiasAllCharged(G4bool includeShortLived=false)
void Bias(const G4String &particleName)
void BiasAllCharged(G4bool includeShortLived=false)
virtual ~G4GenericBiasingPhysics()
void PhysicsBiasAllNeutral(G4bool includeShortLived=false)
void NonPhysicsBiasAllCharged(G4bool includeShortLived=false)
void AddParallelWorld(const G4String ¶llelWorldName)
G4ProcessManager * GetProcessManager() const
G4bool IsShortLived() const
G4int GetPDGEncoding() const
G4double GetPDGCharge() const
const G4String & GetParticleName() const
G4ProcessVector * GetProcessList() const
G4VPhysicsConstructor(const G4String &="")
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const
const G4String & GetProcessName() const