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 std::vector< G4String > dummy;
80 fBiasedProcesses.push_back(dummy);
81 fBiasAllProcesses.push_back(
true);
88 fBiasedParticles.push_back(particleName);
89 fBiasedProcesses.push_back(processNames);
90 fBiasAllProcesses.push_back(
false);
97 fNonPhysBiasedParticles.push_back(particleName);
119 if ( PDGlow > PDGhigh )
G4cout <<
" G4GenericBiasingPhysics::PhysicsBiasAddPDGRange(...) : PDGlow > PDGhigh, call ignored." <<
G4endl;
120 fPhysBiasByPDGRangeLow .push_back( PDGlow );
121 fPhysBiasByPDGRangeHigh.push_back( PDGhigh );
122 if ( includeAntiParticle )
124 fPhysBiasByPDGRangeLow .push_back( -PDGhigh );
125 fPhysBiasByPDGRangeHigh.push_back( -PDGlow );
132 if ( PDGlow > PDGhigh )
G4cout <<
" G4GenericBiasingPhysics::NonPhysicsBiasAddPDGRange(...) : PDGlow > PDGhigh, call ignored." <<
G4endl;
133 fNonPhysBiasByPDGRangeLow .push_back( PDGlow );
134 fNonPhysBiasByPDGRangeHigh.push_back( PDGhigh );
135 if ( includeAntiParticle )
137 fNonPhysBiasByPDGRangeLow .push_back( -PDGhigh );
138 fNonPhysBiasByPDGRangeHigh.push_back( -PDGlow );
146 if ( PDGlow > PDGhigh )
G4cout <<
" G4GenericBiasingPhysics::BiasAddPDGRange(...) : PDGlow > PDGhigh, call ignored." <<
G4endl;
153 fPhysBiasAllCharged =
true;
154 fPhysBiasAllChargedISL = includeShortLived;
158 fNonPhysBiasAllCharged =
true;
159 fNonPhysBiasAllChargedISL = includeShortLived;
163 fPhysBiasAllCharged =
true;
164 fNonPhysBiasAllCharged =
true;
165 fPhysBiasAllChargedISL = includeShortLived;
166 fNonPhysBiasAllChargedISL = includeShortLived;
170 fPhysBiasAllNeutral =
true;
171 fPhysBiasAllNeutralISL = includeShortLived;
175 fNonPhysBiasAllNeutral =
true;
176 fNonPhysBiasAllNeutralISL = includeShortLived;
180 fPhysBiasAllNeutral =
true;
181 fNonPhysBiasAllNeutral =
true;
182 fPhysBiasAllNeutralISL = includeShortLived;
183 fNonPhysBiasAllNeutralISL = includeShortLived;
191 for (
G4String knownParticle : fParticlesWithParallelGeometries )
193 if ( knownParticle == particleName )
201 if ( !isKnown ) fParticlesWithParallelGeometries.push_back( particleName );
202 std::vector< G4String >& geometries = fParallelGeometriesForParticle[particleName];
205 for (
G4String knownGeometry : geometries )
207 if ( knownGeometry == parallelGeometryName )
213 if ( !isKnown ) geometries.push_back( parallelGeometryName );
224 if ( PDGlow > PDGhigh )
226 G4cout <<
"G4GenericBiasingPhysics::AddParallelGeometry( G4int PDGlow, G4int PDGhigh, const G4String& parallelGeometryName , G4bool includeAntiParticle = true ), PDGlow > PDGhigh : call ignored" <<
G4endl;
230 fPDGlowParallelGeometries .push_back( PDGlow );
231 fPDGhighParallelGeometries.push_back( PDGhigh );
232 G4int rangeIndex = fPDGlowParallelGeometries.size() - 1;
233 fPDGrangeParallelGeometries[rangeIndex].push_back( parallelGeometryName );
235 if ( includeAntiParticle )
237 fPDGlowParallelGeometries .push_back( -PDGhigh );
238 fPDGhighParallelGeometries.push_back( -PDGlow );
239 rangeIndex = fPDGlowParallelGeometries.size() - 1;
240 fPDGrangeParallelGeometries[rangeIndex].push_back( parallelGeometryName );
247 if ( PDGlow > PDGhigh )
249 G4cout <<
"G4GenericBiasingPhysics::AddParallelGeometry( G4int PDGlow, G4int PDGhigh, const std::vector< G4String >& parallelGeometryNames, G4bool includeAntiParticle = true ), PDGlow > PDGhigh : call ignored" <<
G4endl;
259 for (
G4String geometry : fParallelGeometriesForCharged )
261 if ( geometry == parallelGeometryName )
269 fParallelGeometriesForCharged .push_back( parallelGeometryName );
270 fAllChargedParallelGeometriesISL.push_back( includeShortLived );
282 for (
G4String geometry : fParallelGeometriesForNeutral )
284 if ( geometry == parallelGeometryName )
292 fParallelGeometriesForNeutral .push_back( parallelGeometryName );
293 fAllNeutralParallelGeometriesISL.push_back( includeShortLived );
325 if ( std::find(fNonPhysBiasedParticles.begin(),
326 fNonPhysBiasedParticles.end(),
327 particleName ) != fNonPhysBiasedParticles.end() )
333 std::vector< G4String >::const_iterator particleIt =
334 std::find(fBiasedParticles.begin(),
335 fBiasedParticles.end(),
337 if ( particleIt == fBiasedParticles.end() )
continue;
339 std::vector < G4String >& biasedProcesses = fBiasedProcesses [ particleIt - fBiasedParticles.begin() ];
340 G4bool biasAll = fBiasAllProcesses[ particleIt - fBiasedParticles.begin() ];
345 for (std::size_t ip = 0 ; ip < vprocess->
size() ; ++ip)
353 while ( restartLoop )
355 for (std::size_t ip = 0 ; ip < biasedProcesses.size() ; ++ip)
359 if ( restartLoop )
break;
376 if ( std::find( fNonPhysBiasedParticles.begin(),
377 fNonPhysBiasedParticles.end(),
378 particleName ) != fNonPhysBiasedParticles.end() )
continue;
380 if ( std::find( fBiasedParticles.begin(),
381 fBiasedParticles.end(),
382 particleName ) != fBiasedParticles.end() )
continue;
385 G4bool physBias(
false), nonPhysBias(
false);
390 for (
size_t i = 0 ; i < fPhysBiasByPDGRangeLow.size() ; i++ )
391 if ( ( PDG >= fPhysBiasByPDGRangeLow[i] ) && ( PDG <= fPhysBiasByPDGRangeHigh[i] ) )
396 for (
size_t i = 0 ; i < fNonPhysBiasByPDGRangeLow.size() ; i++ )
397 if ( ( PDG >= fNonPhysBiasByPDGRangeLow[i] ) && ( PDG <= fNonPhysBiasByPDGRangeHigh[i] ) )
404 if ( ( physBias ==
false ) && ( nonPhysBias ==
false ) )
408 if ( fPhysBiasAllCharged )
if ( fPhysBiasAllChargedISL || !particle->
IsShortLived() ) physBias =
true;
409 if ( fNonPhysBiasAllCharged )
if ( fNonPhysBiasAllChargedISL || !particle->
IsShortLived() ) nonPhysBias =
true;
413 if ( fPhysBiasAllNeutral )
if ( fPhysBiasAllNeutralISL || !particle->
IsShortLived() ) physBias =
true;
414 if ( fNonPhysBiasAllNeutral )
if ( fNonPhysBiasAllNeutralISL || !particle->
IsShortLived() ) nonPhysBias =
true;
423 std::vector < G4String > biasedProcesses;
425 for (std::size_t ip = 0 ; ip < vprocess->
size() ; ++ip)
432 while ( restartLoop )
434 for (std::size_t ip = 0 ; ip < biasedProcesses.size() ; ++ip)
438 if ( restartLoop )
break;
448 AssociateParallelGeometries();
468 for (std::size_t ip = 0 ; ip < vprocess->
size() ; ++ip)
482 processNames +=
"\n ";
493 G4cout << std::setw(14) << particleName <<
" **** : " << processNames <<
G4endl;
495 G4cout << std::setw(18) << particleName <<
" : " << processNames <<
G4endl;
503void G4GenericBiasingPhysics::AssociateParallelGeometries()
517 for (
G4String requestedParticles : fParticlesWithParallelGeometries )
519 if ( requestedParticles == particleName )
531 std::vector< G4String >& parallelWorlds = fParallelGeometriesForParticle[ particleName ];
540 for (
G4int PDGlow : fPDGlowParallelGeometries )
542 G4int PDGhigh = fPDGhighParallelGeometries[i];
543 auto & geometries = fPDGrangeParallelGeometries[i];
553 if ( ( particlePDG >= PDGlow ) && ( particlePDG <= PDGhigh ) )
570 G4bool islAllNeutral =
false;
571 for(
auto isln : fAllNeutralParallelGeometriesISL)
572 { islAllNeutral |= isln; }
573 G4bool islAllCharged =
false;
574 for(
auto islc : fAllChargedParallelGeometriesISL)
575 { islAllCharged |= islc; }
584 if(particle->
IsShortLived() && !islAllNeutral)
continue;
587 for(
G4String wNameN : fParallelGeometriesForCharged)
589 if(!(particle->
IsShortLived()) || fAllNeutralParallelGeometriesISL[j])
597 if(particle->
IsShortLived() && !islAllCharged)
continue;
600 for(
G4String wNameC : fParallelGeometriesForCharged)
602 if(!(particle->
IsShortLived()) || fAllChargedParallelGeometriesISL[j])
std::vector< G4InuclElementaryParticle >::iterator particleIterator
#define G4_DECLARE_PHYSCONSTR_FACTORY(physics_constructor)
G4GLOB_DLL std::ostream G4cout
static void ActivateNonPhysicsBiasing(G4ProcessManager *pmanager, G4String nonPhysicsProcessName="")
static G4ParallelGeometriesLimiterProcess * AddLimiterProcess(G4ProcessManager *pmanager, const G4String &processName="biasLimiter")
static G4bool ActivatePhysicsBiasing(G4ProcessManager *pmanager, G4String physicsProcessToBias, G4String wrappedName="")
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
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const
const G4String & GetProcessName() const