Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Rework particles_selected handling in Python Examples #3423

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions Examples/Python/python/acts/examples/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,21 +452,22 @@ def addFatras(

# Selector
if preSelectParticles is not None:
particles_selected = "particles_selected"
particlesSelected = "fatras_particles_preselected"
addParticleSelection(
s,
preSelectParticles,
inputParticles=inputParticles,
outputParticles=particles_selected,
outputParticles=particlesSelected,
)
s.addWhiteboardAlias("particles_selected", particlesSelected)
else:
particles_selected = inputParticles
particlesSelected = inputParticles

# Simulation
alg = acts.examples.FatrasSimulation(
**acts.examples.defaultKWArgs(
level=customLogLevel(),
inputParticles=particles_selected,
inputParticles=particlesSelected,
outputParticlesInitial=outputParticlesInitial,
outputParticlesFinal=outputParticlesFinal,
outputSimHits=outputSimHits,
Expand Down Expand Up @@ -502,6 +503,7 @@ def addFatras(
inputParticles=alg.config.outputParticlesFinal,
outputParticles=particlesFinal,
)
s.addWhiteboardAlias("particles_selected", particlesFinal)
else:
particlesInitial = alg.config.outputParticlesInitial
particlesFinal = alg.config.outputParticlesFinal
Expand Down Expand Up @@ -673,15 +675,16 @@ def addGeant4(

# Selector
if preSelectParticles is not None:
particles_selected = "particles_selected"
particlesSelected = "geant4_particles_preselected"
addParticleSelection(
s,
preSelectParticles,
inputParticles=inputParticles,
outputParticles=particles_selected,
outputParticles=particlesSelected,
)
s.addWhiteboardAlias("particles_selected", particlesSelected)
else:
particles_selected = inputParticles
particlesSelected = inputParticles

if g4DetectorConstructionFactory is None:
if detector is None:
Expand All @@ -705,7 +708,7 @@ def addGeant4(
geant4Handle=__geant4Handle,
detectorConstructionFactory=g4DetectorConstructionFactory,
randomNumbers=rnd,
inputParticles=particles_selected,
inputParticles=particlesSelected,
outputParticlesInitial=outputParticlesInitial,
outputParticlesFinal=outputParticlesFinal,
outputSimHits=outputSimHits,
Expand All @@ -728,21 +731,22 @@ def addGeant4(

# Selector
if postSelectParticles is not None:
particlesInitial = "geant4_particles_initial_selected"
particlesInitial = "geant4_particles_initial_postselected"
addParticleSelection(
s,
postSelectParticles,
inputParticles=alg.config.outputParticlesInitial,
outputParticles=particlesInitial,
)

particlesFinal = "geant4_particles_final_selected"
particlesFinal = "geant4_particles_final_postselected"
addParticleSelection(
s,
postSelectParticles,
inputParticles=alg.config.outputParticlesFinal,
outputParticles=particlesFinal,
)
s.addWhiteboardAlias("particles_selected", particlesFinal)
else:
particlesInitial = alg.config.outputParticlesInitial
particlesFinal = alg.config.outputParticlesFinal
Expand Down
Loading