Skip to content

Commit

Permalink
refactor: Split particle selection in Examples (#3969)
Browse files Browse the repository at this point in the history
- split particle selection into three stages: after generation, after simulation, after digitization
- this allows to perform cuts on the particle collections independent from the algorithms processing them
- after digitization cuts allow to cut on measurement count
- elevates particle selection into reconstruction chain

blocked by
- #4035

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

# Release Notes: Particle Processing and Naming Convention Update

## Overview
This release introduces significant improvements to particle processing workflows, focusing on more precise particle selection and standardized naming conventions.

## Key Changes

### Particle Selection
- Added new functions for particle selection at different stages:
  - `addGenParticleSelection`: Selects particles during generation
  - `addSimParticleSelection`: Selects particles during simulation
  - `addDigiParticleSelection`: Selects particles during digitization

### Naming Conventions
- Updated particle-related variable names from `particles_input` to `particles_generated`
- Standardized input/output particle identifiers across multiple scripts and workflows

### Particle Filtering
- Simplified particle selection logic
- Removed inline particle selection configurations
- Enhanced modularity in particle processing

## Impact
- Improved clarity in particle handling
- More flexible and consistent particle selection
- Better separation of concerns in simulation workflows

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
andiwand authored Jan 21, 2025
1 parent 5e07807 commit 89ad5d0
Show file tree
Hide file tree
Showing 34 changed files with 420 additions and 374 deletions.
Binary file modified CI/physmon/reference/simulation/particles_fatras_hist.root
Binary file not shown.
Binary file modified CI/physmon/reference/simulation/particles_geant4_hist.root
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 4 additions & 9 deletions CI/physmon/workflows/physmon_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from acts.examples.simulation import (
addFatras,
addGeant4,
ParticleSelectorConfig,
addPythia8,
)

Expand Down Expand Up @@ -58,7 +57,7 @@
acts.PdgParticle.eElectron,
]
],
outputParticles="particles_input",
outputParticles="particles_generated",
outputVertices="vertices_input",
randomNumbers=rnd,
)
Expand All @@ -67,7 +66,7 @@
s.addWriter(
acts.examples.RootParticleWriter(
level=acts.logging.INFO,
inputParticles="particles_input",
inputParticles="particles_generated",
filePath=tp / "particles.root",
)
)
Expand All @@ -78,9 +77,7 @@
setup.field,
rnd,
enableInteractions=True,
preSelectParticles=None,
postSelectParticles=ParticleSelectorConfig(removeSecondaries=True),
inputParticles="particles_input",
inputParticles="particles_generated",
outputParticles="particles_fatras",
outputSimHits="simhits_fatras",
outputDirRoot=tp / "fatras",
Expand All @@ -92,12 +89,10 @@
setup.trackingGeometry,
setup.field,
rnd,
preSelectParticles=None,
postSelectParticles=ParticleSelectorConfig(removeSecondaries=True),
killVolume=setup.trackingGeometry.highestTrackingVolume,
killAfterTime=25 * u.ns,
killSecondaries=True,
inputParticles="particles_input",
inputParticles="particles_generated",
outputParticles="particles_geant4",
outputSimHits="simhits_geant4",
outputDirRoot=tp / "geant4",
Expand Down
17 changes: 11 additions & 6 deletions CI/physmon/workflows/physmon_trackfinding_1muon.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
EtaConfig,
PhiConfig,
ParticleConfig,
ParticleSelectorConfig,
addFatras,
addDigitization,
ParticleSelectorConfig,
addDigiParticleSelection,
)

from acts.examples.reconstruction import (
Expand Down Expand Up @@ -72,11 +73,6 @@ def run_ckf_tracking(label, seeding):
setup.field,
enableInteractions=True,
rnd=rnd,
postSelectParticles=ParticleSelectorConfig(
pt=(0.9 * u.GeV, None),
hits=(9, None),
removeNeutral=True,
),
)

addDigitization(
Expand All @@ -87,6 +83,15 @@ def run_ckf_tracking(label, seeding):
rnd=rnd,
)

addDigiParticleSelection(
s,
ParticleSelectorConfig(
pt=(0.9 * u.GeV, None),
measurements=(9, None),
removeNeutral=True,
),
)

addSeeding(
s,
setup.trackingGeometry,
Expand Down
17 changes: 11 additions & 6 deletions CI/physmon/workflows/physmon_trackfinding_4muon_50vertices.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
EtaConfig,
PhiConfig,
ParticleConfig,
ParticleSelectorConfig,
addFatras,
addDigitization,
ParticleSelectorConfig,
addDigiParticleSelection,
)
from acts.examples.reconstruction import (
addSeeding,
Expand Down Expand Up @@ -69,11 +70,6 @@
setup.trackingGeometry,
setup.field,
rnd=rnd,
postSelectParticles=ParticleSelectorConfig(
pt=(0.9 * u.GeV, None),
hits=(9, None),
removeNeutral=True,
),
)

addDigitization(
Expand All @@ -84,6 +80,15 @@
rnd=rnd,
)

addDigiParticleSelection(
s,
ParticleSelectorConfig(
pt=(0.9 * u.GeV, None),
measurements=(9, None),
removeNeutral=True,
),
)

addSeeding(
s,
setup.trackingGeometry,
Expand Down
30 changes: 20 additions & 10 deletions CI/physmon/workflows/physmon_trackfinding_ttbar_pu200.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import acts
from acts.examples.simulation import (
addPythia8,
ParticleSelectorConfig,
addGenParticleSelection,
addFatras,
addDigitization,
ParticleSelectorConfig,
addDigiParticleSelection,
)
from acts.examples.reconstruction import (
addSeeding,
Expand Down Expand Up @@ -61,20 +63,19 @@
outputDirRoot=tp,
)

addGenParticleSelection(
s,
ParticleSelectorConfig(
rho=(0.0, 24 * u.mm),
absZ=(0.0, 1.0 * u.m),
),
)

addFatras(
s,
setup.trackingGeometry,
setup.field,
rnd=rnd,
preSelectParticles=ParticleSelectorConfig(
rho=(0.0, 24 * u.mm),
absZ=(0.0, 1.0 * u.m),
),
postSelectParticles=ParticleSelectorConfig(
pt=(0.5 * u.GeV, None),
hits=(9, None),
removeNeutral=True,
),
)

addDigitization(
Expand All @@ -85,6 +86,15 @@
rnd=rnd,
)

addDigiParticleSelection(
s,
ParticleSelectorConfig(
pt=(0.5 * u.GeV, None),
measurements=(9, None),
removeNeutral=True,
),
)

addSeeding(
s,
setup.trackingGeometry,
Expand Down
6 changes: 3 additions & 3 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2149,9 +2149,9 @@ def addVertexFitting(
trackParameters = converter.config.outputTrackParameters

tracks = tracks if tracks is not None else ""
inputParticles = "particles_input"
inputParticles = "particles"
selectedParticles = "particles_selected"
inputTruthVertices = "vertices_input"
inputTruthVertices = "vertices_truth"

if vertexFinder == VertexFinder.Truth:
findVertices = TruthVertexFinder(
Expand Down Expand Up @@ -2245,7 +2245,7 @@ def addSingleSeedVertexFinding(
)
s.addAlgorithm(findSingleSeedVertex)

inputParticles = "particles_input"
inputParticles = "particles"
selectedParticles = "particles_selected"

if outputDirRoot is not None:
Expand Down
Loading

0 comments on commit 89ad5d0

Please sign in to comment.